Version Description
- Require PHP 5.3+
- Fix all PHPCS errors and warnings.
- Fix a vulnerability where Object Injection could take place if someone has a valid nonce.
- Force all settings to be sanitized and escaped before saving and during display.
- Add filter
ot_validate_setting_input_safe
which is used to validate the input value of a custom setting type. All values must be validated! - Add a notice to let users know that a custom setting type is not properly validating saved data and do a best-effort sanitize of the user data before saving it.
- Fix issue with Composer autoload and only load OptionTree if we have access to WordPress. props @infomaniac50
- Fix deprecated
create_function
notice in PHP 7.2+. props @modesthatred - Fix notice "Only variables should be passed by reference". props @SergeAx
- Add
wordpress-plugin
project type to composer file. props @egifford - Removed translation files.
- Removed the deprecated XML file import method.
- Fix SQL syntax issue. props @ryanlabelle
- Fix metabox radio & checkbox style issues. props @ryanlabelle
Download this release
Release Info
Developer | valendesigns |
Plugin | OptionTree |
Version | 2.7.0 |
Comparing to | |
See all releases |
Code changes from version 2.6.0 to 2.7.0
- LICENSE +339 -0
- assets/css/ot-admin.css +24 -6
- assets/js/ot-admin.js +90 -88
- assets/theme-mode/demo-meta-boxes.php +72 -70
- assets/theme-mode/demo-theme-options.php +799 -797
- composer.json +48 -4
- includes/class-ot-cleanup.php +297 -0
- includes/class-ot-meta-box.php +375 -0
- includes/class-ot-post-formats.php +122 -0
- includes/class-ot-settings.php +1012 -0
- includes/ot-cleanup-api.php +0 -295
- includes/ot-functions-admin.php +5714 -5779
- includes/ot-functions-compat.php +283 -321
- includes/ot-functions-deprecated.php +82 -87
- includes/ot-functions-docs-page.php +768 -621
- includes/ot-functions-option-types.php +2947 -3012
- includes/ot-functions-settings-page.php +456 -541
- includes/ot-functions.php +308 -342
- includes/ot-meta-box-api.php +0 -363
- includes/ot-post-formats-api.php +0 -131
- includes/ot-settings-api.php +0 -899
LICENSE
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.
|
assets/css/ot-admin.css
CHANGED
@@ -1187,6 +1187,19 @@
|
|
1187 |
-moz-border-radius: 0 0 2px 2px;
|
1188 |
border-radius: 0 0 2px 2px;
|
1189 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1190 |
|
1191 |
/* --------------------------------------------------
|
1192 |
:: Header
|
@@ -2157,6 +2170,9 @@ li ul .format-setting-label {
|
|
2157 |
width: 14px;
|
2158 |
z-index: 10;
|
2159 |
}
|
|
|
|
|
|
|
2160 |
.ot-icon-circle.ot-option-group--icon:before {
|
2161 |
left: 1px;
|
2162 |
position: relative;
|
@@ -2304,12 +2320,10 @@ select.option-tree-ui-select option {
|
|
2304 |
---------------------------------------------------*/
|
2305 |
.format-setting.type-checkbox input,
|
2306 |
.format-setting.type-radio input {
|
2307 |
-
|
2308 |
-
margin: 2px 5px 0 1px;
|
2309 |
}
|
2310 |
.format-setting.type-checkbox label,
|
2311 |
.format-setting.type-radio label {
|
2312 |
-
float: left;
|
2313 |
max-width: 90%;
|
2314 |
padding: 0px;
|
2315 |
}
|
@@ -2506,6 +2520,9 @@ select.option-tree-ui-select option {
|
|
2506 |
.hide-color-picker {
|
2507 |
display: none;
|
2508 |
}
|
|
|
|
|
|
|
2509 |
.option-tree-ui-colorpicker-input-wrap .option-tree-ui-colorpicker-label {
|
2510 |
height: 30px;
|
2511 |
line-height: 30px;
|
@@ -2534,7 +2551,7 @@ select.option-tree-ui-select option {
|
|
2534 |
margin: 0 0 5px 0 !important;
|
2535 |
}
|
2536 |
.option-tree-ui-colorpicker-input-wrap .wp-color-result {
|
2537 |
-
height:
|
2538 |
outline: 0;
|
2539 |
margin: 0 5px 5px 0px;
|
2540 |
top: 0px;
|
@@ -2542,7 +2559,8 @@ select.option-tree-ui-select option {
|
|
2542 |
-moz-box-shadow: none;
|
2543 |
box-shadow: none;
|
2544 |
}
|
2545 |
-
.option-tree-ui-colorpicker-input-wrap .wp-color-result:after
|
|
|
2546 |
line-height: 27px;
|
2547 |
}
|
2548 |
.option-tree-ui-colorpicker-input-wrap .wp-picker-container .iris-picker {
|
@@ -3970,4 +3988,4 @@ a.ui-datepicker-next {
|
|
3970 |
.ot-metabox-tabs.ui-tabs .ot-metabox-panel {
|
3971 |
clear: both;
|
3972 |
}
|
3973 |
-
}
|
1187 |
-moz-border-radius: 0 0 2px 2px;
|
1188 |
border-radius: 0 0 2px 2px;
|
1189 |
}
|
1190 |
+
.postbox.ot-meta-box {
|
1191 |
+
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
#poststuff .postbox.ot-meta-box .inside {
|
1195 |
+
background-color: #f3f4f5;
|
1196 |
+
margin: 0;
|
1197 |
+
padding: 6px 12px 12px;
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
#poststuff .postbox.ot-meta-box .is-panel {
|
1201 |
+
display: none !important;
|
1202 |
+
}
|
1203 |
|
1204 |
/* --------------------------------------------------
|
1205 |
:: Header
|
2170 |
width: 14px;
|
2171 |
z-index: 10;
|
2172 |
}
|
2173 |
+
.postbox.ot-meta-box .ot-option-group--icon {
|
2174 |
+
width: 28px;
|
2175 |
+
}
|
2176 |
.ot-icon-circle.ot-option-group--icon:before {
|
2177 |
left: 1px;
|
2178 |
position: relative;
|
2320 |
---------------------------------------------------*/
|
2321 |
.format-setting.type-checkbox input,
|
2322 |
.format-setting.type-radio input {
|
2323 |
+
margin: 2px 5px 0 2px;
|
|
|
2324 |
}
|
2325 |
.format-setting.type-checkbox label,
|
2326 |
.format-setting.type-radio label {
|
|
|
2327 |
max-width: 90%;
|
2328 |
padding: 0px;
|
2329 |
}
|
2520 |
.hide-color-picker {
|
2521 |
display: none;
|
2522 |
}
|
2523 |
+
.wp-picker-active .hide-color-picker {
|
2524 |
+
display: inline-block;
|
2525 |
+
}
|
2526 |
.option-tree-ui-colorpicker-input-wrap .option-tree-ui-colorpicker-label {
|
2527 |
height: 30px;
|
2528 |
line-height: 30px;
|
2551 |
margin: 0 0 5px 0 !important;
|
2552 |
}
|
2553 |
.option-tree-ui-colorpicker-input-wrap .wp-color-result {
|
2554 |
+
height: 29px !important;
|
2555 |
outline: 0;
|
2556 |
margin: 0 5px 5px 0px;
|
2557 |
top: 0px;
|
2559 |
-moz-box-shadow: none;
|
2560 |
box-shadow: none;
|
2561 |
}
|
2562 |
+
.option-tree-ui-colorpicker-input-wrap .wp-color-result:after,
|
2563 |
+
.option-tree-ui-colorpicker-input-wrap .wp-color-result-text {
|
2564 |
line-height: 27px;
|
2565 |
}
|
2566 |
.option-tree-ui-colorpicker-input-wrap .wp-picker-container .iris-picker {
|
3988 |
.ot-metabox-tabs.ui-tabs .ot-metabox-panel {
|
3989 |
clear: both;
|
3990 |
}
|
3991 |
+
}
|
assets/js/ot-admin.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
/**
|
2 |
* Option Tree UI
|
3 |
-
*
|
4 |
* Dependencies: jQuery, jQuery UI, ColorPicker
|
5 |
*
|
6 |
* @author Derek Herman (derek@valendesigns.com)
|
@@ -318,8 +318,8 @@
|
|
318 |
|
319 |
while( match = regex.exec( condition ) ) {
|
320 |
conditions.push({
|
321 |
-
'check': match[1],
|
322 |
-
'rule': match[2],
|
323 |
'value': match[3] || ''
|
324 |
});
|
325 |
}
|
@@ -361,7 +361,7 @@
|
|
361 |
break;
|
362 |
case 'contains':
|
363 |
result = ( v1.indexOf(v2) !== -1 ? true : false );
|
364 |
-
break;
|
365 |
case 'is':
|
366 |
result = ( v1 == v2 );
|
367 |
break;
|
@@ -383,7 +383,7 @@
|
|
383 |
passed = ( passed && result );
|
384 |
break;
|
385 |
}
|
386 |
-
|
387 |
});
|
388 |
|
389 |
if ( passed ) {
|
@@ -391,7 +391,7 @@
|
|
391 |
} else {
|
392 |
$(this).animate({opacity: 'hide' , height: 'hide'}, 200);
|
393 |
}
|
394 |
-
|
395 |
delete passed;
|
396 |
|
397 |
});
|
@@ -618,8 +618,9 @@
|
|
618 |
dataType: 'json',
|
619 |
data: {
|
620 |
action: 'ot_google_font',
|
621 |
-
family: input.val(),
|
622 |
-
field_id: input.attr('id')
|
|
|
623 |
}
|
624 |
}).done(function(response) {
|
625 |
if ( response.hasOwnProperty('variants') ) {
|
@@ -728,7 +729,7 @@
|
|
728 |
editor.setTheme("ace/theme/chrome");
|
729 |
editor.getSession().setMode("ace/mode/css");
|
730 |
editor.setShowPrintMargin( false );
|
731 |
-
|
732 |
editor.getSession().setValue(this_textarea.val());
|
733 |
editor.getSession().on('change', function(){
|
734 |
this_textarea.val(editor.getSession().getValue());
|
@@ -818,8 +819,9 @@
|
|
818 |
url: ajaxurl,
|
819 |
dataType: 'html',
|
820 |
data: {
|
821 |
-
action: 'gallery_update'
|
822 |
-
|
|
|
823 |
},
|
824 |
success: function(res) {
|
825 |
parent.children('.ot-gallery-list').html(res);
|
@@ -860,50 +862,50 @@
|
|
860 |
|
861 |
if ( _.isUndefined( shortcode.get('ids') ) && ! input.hasClass('ot-gallery-shortcode') && ids )
|
862 |
shortcode.set( 'ids', ids )
|
863 |
-
|
864 |
if ( _.isUndefined( shortcode.get('ids') ) )
|
865 |
shortcode.set( 'ids', '0' )
|
866 |
-
|
867 |
attachments = wp.media.gallery.attachments( shortcode )
|
868 |
|
869 |
selection = new wp.media.model.Selection( attachments.models, {
|
870 |
props: attachments.props.toJSON()
|
871 |
, multiple: true
|
872 |
})
|
873 |
-
|
874 |
selection.gallery = attachments.gallery
|
875 |
-
|
876 |
// Fetch the query's attachments, and then break ties from the query to allow for sorting.
|
877 |
selection.more().done( function () {
|
878 |
selection.props.set({ query: false })
|
879 |
selection.unmirror()
|
880 |
selection.props.unset('orderby')
|
881 |
})
|
882 |
-
|
883 |
return selection
|
884 |
-
|
885 |
}
|
886 |
-
|
887 |
, open: function (elm) {
|
888 |
-
|
889 |
ot_gallery.frame(elm).open()
|
890 |
-
|
891 |
}
|
892 |
-
|
893 |
, remove: function (elm) {
|
894 |
-
|
895 |
if ( confirm( option_tree.confirm ) ) {
|
896 |
-
|
897 |
$(elm).parents('.format-setting-inner').children('.ot-gallery-value').attr('value', '');
|
898 |
$(elm).parents('.format-setting-inner').children('.ot-gallery-list').remove();
|
899 |
$(elm).next('.ot-gallery-edit').text( option_tree.create );
|
900 |
$(elm).remove();
|
901 |
OT_UI.parse_condition();
|
902 |
-
|
903 |
}
|
904 |
|
905 |
}
|
906 |
-
|
907 |
}
|
908 |
|
909 |
// Gallery delete
|
@@ -911,13 +913,13 @@
|
|
911 |
e.preventDefault()
|
912 |
ot_gallery.remove($(this))
|
913 |
})
|
914 |
-
|
915 |
// Gallery edit
|
916 |
$(document).on('click.ot_gallery.data-api', '.ot-gallery-edit', function (e) {
|
917 |
e.preventDefault()
|
918 |
ot_gallery.open($(this))
|
919 |
})
|
920 |
-
|
921 |
}(window.jQuery);
|
922 |
|
923 |
/*!
|
@@ -925,43 +927,43 @@
|
|
925 |
*/
|
926 |
!function ($) {
|
927 |
|
928 |
-
$(document).
|
929 |
-
|
930 |
// Loop over the metaboxes
|
931 |
$('.ot-metabox-wrapper').each( function() {
|
932 |
-
|
933 |
// Only if there is a tab option
|
934 |
if ( $(this).find('.type-tab').length ) {
|
935 |
-
|
936 |
// Add .ot-metabox-panels
|
937 |
$(this).find('.type-tab').parents('.ot-metabox-wrapper').wrapInner('<div class="ot-metabox-panels" />')
|
938 |
-
|
939 |
// Wrapp with .ot-metabox-tabs & add .ot-metabox-nav before .ot-metabox-panels
|
940 |
$(this).find('.ot-metabox-panels').wrap('<div class="ot-metabox-tabs" />').before('<ul class="ot-metabox-nav" />')
|
941 |
-
|
942 |
// Loop over settings and build the tabs nav
|
943 |
$(this).find('.format-settings').each( function() {
|
944 |
-
|
945 |
if ( $(this).find('.type-tab').length > 0 ) {
|
946 |
var title = $(this).find('.type-tab').prev().find('label').text()
|
947 |
, id = $(this).attr('id')
|
948 |
-
|
949 |
-
// Add a class, hide & append nav item
|
950 |
$(this).addClass('is-panel').hide()
|
951 |
$(this).parents('.ot-metabox-panels').prev('.ot-metabox-nav').append('<li><a href="#' + id + '">' + title + '</a></li>')
|
952 |
-
|
953 |
}
|
954 |
-
|
955 |
})
|
956 |
-
|
957 |
// Loop over the panels and wrap and ID them.
|
958 |
$(this).find('.is-panel').each( function() {
|
959 |
var id = $(this).attr('id')
|
960 |
-
|
961 |
$(this).add( $(this).nextUntil('.is-panel') ).wrapAll('<div id="' + id + '" class="tab-content" />')
|
962 |
-
|
963 |
})
|
964 |
-
|
965 |
// Create the tabs
|
966 |
$(this).find('.ot-metabox-tabs').tabs({
|
967 |
activate: function( event, ui ) {
|
@@ -974,10 +976,10 @@
|
|
974 |
OT_UI.load_editors();
|
975 |
}
|
976 |
})
|
977 |
-
|
978 |
// Move the orphaned settings to the top
|
979 |
$(this).find('.ot-metabox-panels > .format-settings').prependTo($(this))
|
980 |
-
|
981 |
// Remove a bunch of classes to stop style conflicts.
|
982 |
$(this).find('.ot-metabox-tabs').removeClass('ui-widget ui-widget-content ui-corner-all')
|
983 |
$(this).find('.ot-metabox-nav').removeClass('ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all')
|
@@ -985,11 +987,11 @@
|
|
985 |
$(this).find('.ot-metabox-nav li').on('mouseenter mouseleave', function() { $(this).removeClass('ui-state-hover') })
|
986 |
|
987 |
}
|
988 |
-
|
989 |
})
|
990 |
-
|
991 |
})
|
992 |
-
|
993 |
}(window.jQuery);
|
994 |
|
995 |
/*!
|
@@ -997,69 +999,69 @@
|
|
997 |
*/
|
998 |
!function ($) {
|
999 |
|
1000 |
-
$(document).
|
1001 |
-
|
1002 |
// Loop over the theme options
|
1003 |
$('#option-tree-settings-api .inside').each( function() {
|
1004 |
-
|
1005 |
// Only if there is a tab option
|
1006 |
if ( $(this).find('.type-tab').length ) {
|
1007 |
-
|
1008 |
// Add .ot-theme-option-panels
|
1009 |
$(this).find('.type-tab').parents('.inside').wrapInner('<div class="ot-theme-option-panels" />')
|
1010 |
-
|
1011 |
// Wrap with .ot-theme-option-tabs & add .ot-theme-option-nav before .ot-theme-option-panels
|
1012 |
$(this).find('.ot-theme-option-panels').wrap('<div class="ot-theme-option-tabs" />').before('<ul class="ot-theme-option-nav" />')
|
1013 |
-
|
1014 |
// Loop over settings and build the tabs nav
|
1015 |
$(this).find('.format-settings').each( function() {
|
1016 |
-
|
1017 |
if ( $(this).find('.type-tab').length > 0 ) {
|
1018 |
var title = $(this).find('.type-tab').prev().find('.label').text()
|
1019 |
, id = $(this).attr('id')
|
1020 |
-
|
1021 |
-
// Add a class, hide & append nav item
|
1022 |
$(this).addClass('is-panel').hide()
|
1023 |
$(this).parents('.ot-theme-option-panels').prev('.ot-theme-option-nav').append('<li><a href="#' + id + '">' + title + '</a></li>')
|
1024 |
-
|
1025 |
} else {
|
1026 |
-
|
1027 |
}
|
1028 |
-
|
1029 |
})
|
1030 |
-
|
1031 |
// Loop over the panels and wrap and ID them.
|
1032 |
$(this).find('.is-panel').each( function() {
|
1033 |
var id = $(this).attr('id')
|
1034 |
-
|
1035 |
$(this).add( $(this).nextUntil('.is-panel') ).wrapAll('<div id="' + id + '" class="tab-content" />')
|
1036 |
-
|
1037 |
})
|
1038 |
-
|
1039 |
// Create the tabs
|
1040 |
$(this).find('.ot-theme-option-tabs').tabs({
|
1041 |
activate: function( event, ui ) {
|
1042 |
OT_UI.load_editors();
|
1043 |
}
|
1044 |
})
|
1045 |
-
|
1046 |
// Move the orphaned settings to the top
|
1047 |
$(this).find('.ot-theme-option-panels > .format-settings').prependTo($(this).find('.ot-theme-option-tabs'))
|
1048 |
-
|
1049 |
}
|
1050 |
-
|
1051 |
})
|
1052 |
-
|
1053 |
})
|
1054 |
-
|
1055 |
}(window.jQuery);
|
1056 |
|
1057 |
/*!
|
1058 |
* Fixes the state of metabox radio buttons after a Drag & Drop event.
|
1059 |
*/
|
1060 |
!function ($) {
|
1061 |
-
|
1062 |
-
$(document).
|
1063 |
|
1064 |
// detect mousedown and store all checked radio buttons
|
1065 |
$('.hndle').on('mousedown', function () {
|
@@ -1071,47 +1073,47 @@
|
|
1071 |
// set live event listener for mouse up on the content .wrap
|
1072 |
// then give the dragged div time to settle before firing the reclick function
|
1073 |
$('.wrap').on('mouseup', function () {
|
1074 |
-
|
1075 |
var ot_checked_radios = {}
|
1076 |
-
|
1077 |
// loop over all checked radio buttons inside of parent element
|
1078 |
$('#' + parent_id + ' input[type="radio"]').each( function () {
|
1079 |
-
|
1080 |
// stores checked radio buttons
|
1081 |
if ( $(this).is(':checked') ) {
|
1082 |
-
|
1083 |
ot_checked_radios[$(this).attr('name')] = $(this).val()
|
1084 |
-
|
1085 |
}
|
1086 |
-
|
1087 |
// write to the object
|
1088 |
$(document).data('ot_checked_radios', ot_checked_radios)
|
1089 |
-
|
1090 |
})
|
1091 |
|
1092 |
// restore all checked radio buttons
|
1093 |
setTimeout( function () {
|
1094 |
-
|
1095 |
// get object of checked radio button names and values
|
1096 |
var checked = $(document).data('ot_checked_radios')
|
1097 |
-
|
1098 |
// step thru each object element and trigger a click on it's corresponding radio button
|
1099 |
for ( key in checked ) {
|
1100 |
-
|
1101 |
$('input[name="' + key + '"]').filter('[value="' + checked[key] + '"]').trigger('click')
|
1102 |
-
|
1103 |
}
|
1104 |
-
|
1105 |
$('.wrap').unbind('mouseup')
|
1106 |
-
|
1107 |
}, 50 )
|
1108 |
-
|
1109 |
})
|
1110 |
-
|
1111 |
})
|
1112 |
-
|
1113 |
})
|
1114 |
-
|
1115 |
}(window.jQuery);
|
1116 |
|
1117 |
/*!
|
@@ -1290,4 +1292,4 @@
|
|
1290 |
$('.hide-color-picker.ot-colorpicker-opacity').ot_wpColorPicker();
|
1291 |
});
|
1292 |
|
1293 |
-
})( jQuery, window, document );
|
1 |
/**
|
2 |
* Option Tree UI
|
3 |
+
*
|
4 |
* Dependencies: jQuery, jQuery UI, ColorPicker
|
5 |
*
|
6 |
* @author Derek Herman (derek@valendesigns.com)
|
318 |
|
319 |
while( match = regex.exec( condition ) ) {
|
320 |
conditions.push({
|
321 |
+
'check': match[1],
|
322 |
+
'rule': match[2],
|
323 |
'value': match[3] || ''
|
324 |
});
|
325 |
}
|
361 |
break;
|
362 |
case 'contains':
|
363 |
result = ( v1.indexOf(v2) !== -1 ? true : false );
|
364 |
+
break;
|
365 |
case 'is':
|
366 |
result = ( v1 == v2 );
|
367 |
break;
|
383 |
passed = ( passed && result );
|
384 |
break;
|
385 |
}
|
386 |
+
|
387 |
});
|
388 |
|
389 |
if ( passed ) {
|
391 |
} else {
|
392 |
$(this).animate({opacity: 'hide' , height: 'hide'}, 200);
|
393 |
}
|
394 |
+
|
395 |
delete passed;
|
396 |
|
397 |
});
|
618 |
dataType: 'json',
|
619 |
data: {
|
620 |
action: 'ot_google_font',
|
621 |
+
family: input.val(),
|
622 |
+
field_id: input.attr( 'id' ),
|
623 |
+
nonce: option_tree.nonce
|
624 |
}
|
625 |
}).done(function(response) {
|
626 |
if ( response.hasOwnProperty('variants') ) {
|
729 |
editor.setTheme("ace/theme/chrome");
|
730 |
editor.getSession().setMode("ace/mode/css");
|
731 |
editor.setShowPrintMargin( false );
|
732 |
+
|
733 |
editor.getSession().setValue(this_textarea.val());
|
734 |
editor.getSession().on('change', function(){
|
735 |
this_textarea.val(editor.getSession().getValue());
|
819 |
url: ajaxurl,
|
820 |
dataType: 'html',
|
821 |
data: {
|
822 |
+
action: 'gallery_update',
|
823 |
+
ids: ids,
|
824 |
+
nonce: option_tree.nonce
|
825 |
},
|
826 |
success: function(res) {
|
827 |
parent.children('.ot-gallery-list').html(res);
|
862 |
|
863 |
if ( _.isUndefined( shortcode.get('ids') ) && ! input.hasClass('ot-gallery-shortcode') && ids )
|
864 |
shortcode.set( 'ids', ids )
|
865 |
+
|
866 |
if ( _.isUndefined( shortcode.get('ids') ) )
|
867 |
shortcode.set( 'ids', '0' )
|
868 |
+
|
869 |
attachments = wp.media.gallery.attachments( shortcode )
|
870 |
|
871 |
selection = new wp.media.model.Selection( attachments.models, {
|
872 |
props: attachments.props.toJSON()
|
873 |
, multiple: true
|
874 |
})
|
875 |
+
|
876 |
selection.gallery = attachments.gallery
|
877 |
+
|
878 |
// Fetch the query's attachments, and then break ties from the query to allow for sorting.
|
879 |
selection.more().done( function () {
|
880 |
selection.props.set({ query: false })
|
881 |
selection.unmirror()
|
882 |
selection.props.unset('orderby')
|
883 |
})
|
884 |
+
|
885 |
return selection
|
886 |
+
|
887 |
}
|
888 |
+
|
889 |
, open: function (elm) {
|
890 |
+
|
891 |
ot_gallery.frame(elm).open()
|
892 |
+
|
893 |
}
|
894 |
+
|
895 |
, remove: function (elm) {
|
896 |
+
|
897 |
if ( confirm( option_tree.confirm ) ) {
|
898 |
+
|
899 |
$(elm).parents('.format-setting-inner').children('.ot-gallery-value').attr('value', '');
|
900 |
$(elm).parents('.format-setting-inner').children('.ot-gallery-list').remove();
|
901 |
$(elm).next('.ot-gallery-edit').text( option_tree.create );
|
902 |
$(elm).remove();
|
903 |
OT_UI.parse_condition();
|
904 |
+
|
905 |
}
|
906 |
|
907 |
}
|
908 |
+
|
909 |
}
|
910 |
|
911 |
// Gallery delete
|
913 |
e.preventDefault()
|
914 |
ot_gallery.remove($(this))
|
915 |
})
|
916 |
+
|
917 |
// Gallery edit
|
918 |
$(document).on('click.ot_gallery.data-api', '.ot-gallery-edit', function (e) {
|
919 |
e.preventDefault()
|
920 |
ot_gallery.open($(this))
|
921 |
})
|
922 |
+
|
923 |
}(window.jQuery);
|
924 |
|
925 |
/*!
|
927 |
*/
|
928 |
!function ($) {
|
929 |
|
930 |
+
$( document ).ready( function() {
|
931 |
+
|
932 |
// Loop over the metaboxes
|
933 |
$('.ot-metabox-wrapper').each( function() {
|
934 |
+
|
935 |
// Only if there is a tab option
|
936 |
if ( $(this).find('.type-tab').length ) {
|
937 |
+
|
938 |
// Add .ot-metabox-panels
|
939 |
$(this).find('.type-tab').parents('.ot-metabox-wrapper').wrapInner('<div class="ot-metabox-panels" />')
|
940 |
+
|
941 |
// Wrapp with .ot-metabox-tabs & add .ot-metabox-nav before .ot-metabox-panels
|
942 |
$(this).find('.ot-metabox-panels').wrap('<div class="ot-metabox-tabs" />').before('<ul class="ot-metabox-nav" />')
|
943 |
+
|
944 |
// Loop over settings and build the tabs nav
|
945 |
$(this).find('.format-settings').each( function() {
|
946 |
+
|
947 |
if ( $(this).find('.type-tab').length > 0 ) {
|
948 |
var title = $(this).find('.type-tab').prev().find('label').text()
|
949 |
, id = $(this).attr('id')
|
950 |
+
|
951 |
+
// Add a class, hide & append nav item
|
952 |
$(this).addClass('is-panel').hide()
|
953 |
$(this).parents('.ot-metabox-panels').prev('.ot-metabox-nav').append('<li><a href="#' + id + '">' + title + '</a></li>')
|
954 |
+
|
955 |
}
|
956 |
+
|
957 |
})
|
958 |
+
|
959 |
// Loop over the panels and wrap and ID them.
|
960 |
$(this).find('.is-panel').each( function() {
|
961 |
var id = $(this).attr('id')
|
962 |
+
|
963 |
$(this).add( $(this).nextUntil('.is-panel') ).wrapAll('<div id="' + id + '" class="tab-content" />')
|
964 |
+
|
965 |
})
|
966 |
+
|
967 |
// Create the tabs
|
968 |
$(this).find('.ot-metabox-tabs').tabs({
|
969 |
activate: function( event, ui ) {
|
976 |
OT_UI.load_editors();
|
977 |
}
|
978 |
})
|
979 |
+
|
980 |
// Move the orphaned settings to the top
|
981 |
$(this).find('.ot-metabox-panels > .format-settings').prependTo($(this))
|
982 |
+
|
983 |
// Remove a bunch of classes to stop style conflicts.
|
984 |
$(this).find('.ot-metabox-tabs').removeClass('ui-widget ui-widget-content ui-corner-all')
|
985 |
$(this).find('.ot-metabox-nav').removeClass('ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all')
|
987 |
$(this).find('.ot-metabox-nav li').on('mouseenter mouseleave', function() { $(this).removeClass('ui-state-hover') })
|
988 |
|
989 |
}
|
990 |
+
|
991 |
})
|
992 |
+
|
993 |
})
|
994 |
+
|
995 |
}(window.jQuery);
|
996 |
|
997 |
/*!
|
999 |
*/
|
1000 |
!function ($) {
|
1001 |
|
1002 |
+
$( document ).ready( function() {
|
1003 |
+
|
1004 |
// Loop over the theme options
|
1005 |
$('#option-tree-settings-api .inside').each( function() {
|
1006 |
+
|
1007 |
// Only if there is a tab option
|
1008 |
if ( $(this).find('.type-tab').length ) {
|
1009 |
+
|
1010 |
// Add .ot-theme-option-panels
|
1011 |
$(this).find('.type-tab').parents('.inside').wrapInner('<div class="ot-theme-option-panels" />')
|
1012 |
+
|
1013 |
// Wrap with .ot-theme-option-tabs & add .ot-theme-option-nav before .ot-theme-option-panels
|
1014 |
$(this).find('.ot-theme-option-panels').wrap('<div class="ot-theme-option-tabs" />').before('<ul class="ot-theme-option-nav" />')
|
1015 |
+
|
1016 |
// Loop over settings and build the tabs nav
|
1017 |
$(this).find('.format-settings').each( function() {
|
1018 |
+
|
1019 |
if ( $(this).find('.type-tab').length > 0 ) {
|
1020 |
var title = $(this).find('.type-tab').prev().find('.label').text()
|
1021 |
, id = $(this).attr('id')
|
1022 |
+
|
1023 |
+
// Add a class, hide & append nav item
|
1024 |
$(this).addClass('is-panel').hide()
|
1025 |
$(this).parents('.ot-theme-option-panels').prev('.ot-theme-option-nav').append('<li><a href="#' + id + '">' + title + '</a></li>')
|
1026 |
+
|
1027 |
} else {
|
1028 |
+
|
1029 |
}
|
1030 |
+
|
1031 |
})
|
1032 |
+
|
1033 |
// Loop over the panels and wrap and ID them.
|
1034 |
$(this).find('.is-panel').each( function() {
|
1035 |
var id = $(this).attr('id')
|
1036 |
+
|
1037 |
$(this).add( $(this).nextUntil('.is-panel') ).wrapAll('<div id="' + id + '" class="tab-content" />')
|
1038 |
+
|
1039 |
})
|
1040 |
+
|
1041 |
// Create the tabs
|
1042 |
$(this).find('.ot-theme-option-tabs').tabs({
|
1043 |
activate: function( event, ui ) {
|
1044 |
OT_UI.load_editors();
|
1045 |
}
|
1046 |
})
|
1047 |
+
|
1048 |
// Move the orphaned settings to the top
|
1049 |
$(this).find('.ot-theme-option-panels > .format-settings').prependTo($(this).find('.ot-theme-option-tabs'))
|
1050 |
+
|
1051 |
}
|
1052 |
+
|
1053 |
})
|
1054 |
+
|
1055 |
})
|
1056 |
+
|
1057 |
}(window.jQuery);
|
1058 |
|
1059 |
/*!
|
1060 |
* Fixes the state of metabox radio buttons after a Drag & Drop event.
|
1061 |
*/
|
1062 |
!function ($) {
|
1063 |
+
|
1064 |
+
$( document ).ready( function() {
|
1065 |
|
1066 |
// detect mousedown and store all checked radio buttons
|
1067 |
$('.hndle').on('mousedown', function () {
|
1073 |
// set live event listener for mouse up on the content .wrap
|
1074 |
// then give the dragged div time to settle before firing the reclick function
|
1075 |
$('.wrap').on('mouseup', function () {
|
1076 |
+
|
1077 |
var ot_checked_radios = {}
|
1078 |
+
|
1079 |
// loop over all checked radio buttons inside of parent element
|
1080 |
$('#' + parent_id + ' input[type="radio"]').each( function () {
|
1081 |
+
|
1082 |
// stores checked radio buttons
|
1083 |
if ( $(this).is(':checked') ) {
|
1084 |
+
|
1085 |
ot_checked_radios[$(this).attr('name')] = $(this).val()
|
1086 |
+
|
1087 |
}
|
1088 |
+
|
1089 |
// write to the object
|
1090 |
$(document).data('ot_checked_radios', ot_checked_radios)
|
1091 |
+
|
1092 |
})
|
1093 |
|
1094 |
// restore all checked radio buttons
|
1095 |
setTimeout( function () {
|
1096 |
+
|
1097 |
// get object of checked radio button names and values
|
1098 |
var checked = $(document).data('ot_checked_radios')
|
1099 |
+
|
1100 |
// step thru each object element and trigger a click on it's corresponding radio button
|
1101 |
for ( key in checked ) {
|
1102 |
+
|
1103 |
$('input[name="' + key + '"]').filter('[value="' + checked[key] + '"]').trigger('click')
|
1104 |
+
|
1105 |
}
|
1106 |
+
|
1107 |
$('.wrap').unbind('mouseup')
|
1108 |
+
|
1109 |
}, 50 )
|
1110 |
+
|
1111 |
})
|
1112 |
+
|
1113 |
})
|
1114 |
+
|
1115 |
})
|
1116 |
+
|
1117 |
}(window.jQuery);
|
1118 |
|
1119 |
/*!
|
1292 |
$('.hide-color-picker.ot-colorpicker-opacity').ot_wpColorPicker();
|
1293 |
});
|
1294 |
|
1295 |
+
})( jQuery, window, document );
|
assets/theme-mode/demo-meta-boxes.php
CHANGED
@@ -1,7 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Initialize the custom Meta Boxes.
|
|
|
|
|
4 |
*/
|
|
|
5 |
add_action( 'admin_init', 'custom_meta_boxes' );
|
6 |
|
7 |
/**
|
@@ -9,75 +12,74 @@ add_action( 'admin_init', 'custom_meta_boxes' );
|
|
9 |
*
|
10 |
* You can find all the available option types in demo-theme-options.php.
|
11 |
*
|
12 |
-
* @
|
13 |
-
* @since 2.0
|
14 |
*/
|
15 |
function custom_meta_boxes() {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Create a custom meta boxes array that we pass to
|
19 |
-
* the OptionTree Meta Box API Class.
|
20 |
-
*/
|
21 |
-
$my_meta_box = array(
|
22 |
-
'id' => 'demo_meta_box',
|
23 |
-
'title' => __( 'Demo Meta Box', 'theme-text-domain' ),
|
24 |
-
'desc' => '',
|
25 |
-
'pages' => array( 'post' ),
|
26 |
-
'context' => 'normal',
|
27 |
-
'priority' => 'high',
|
28 |
-
'fields' => array(
|
29 |
-
array(
|
30 |
-
'label' => __( 'Conditions', 'theme-text-domain' ),
|
31 |
-
'id' => 'demo_conditions',
|
32 |
-
'type' => 'tab'
|
33 |
-
),
|
34 |
-
array(
|
35 |
-
'label' => __( 'Show Gallery', 'theme-text-domain' ),
|
36 |
-
'id' => 'demo_show_gallery',
|
37 |
-
'type' => 'on-off',
|
38 |
-
'desc' => sprintf( __( 'Shows the Gallery when set to %s.', 'theme-text-domain' ), '<code>on</code>' ),
|
39 |
-
'std' => 'off'
|
40 |
-
),
|
41 |
-
array(
|
42 |
-
'label' => '',
|
43 |
-
'id' => 'demo_textblock',
|
44 |
-
'type' => 'textblock',
|
45 |
-
'desc' => __( 'Congratulations, you created a gallery!', 'theme-text-domain' ),
|
46 |
-
'operator' => 'and',
|
47 |
-
'condition' => 'demo_show_gallery:is(on),demo_gallery:not()'
|
48 |
-
),
|
49 |
-
array(
|
50 |
-
'label' => __( 'Gallery', 'theme-text-domain' ),
|
51 |
-
'id' => 'demo_gallery',
|
52 |
-
'type' => 'gallery',
|
53 |
-
'desc' => sprintf( __( 'This is a Gallery option type. It displays when %s.', 'theme-text-domain' ), '<code>demo_show_gallery:is(on)</code>' ),
|
54 |
-
'condition' => 'demo_show_gallery:is(on)'
|
55 |
-
),
|
56 |
-
array(
|
57 |
-
'label' => __( 'More Options', 'theme-text-domain' ),
|
58 |
-
'id' => 'demo_more_options',
|
59 |
-
'type' => 'tab'
|
60 |
-
),
|
61 |
-
array(
|
62 |
-
'label' => __( 'Text', 'theme-text-domain' ),
|
63 |
-
'id' => 'demo_text',
|
64 |
-
'type' => 'text',
|
65 |
-
'desc' => __( 'This is a demo Text field.', 'theme-text-domain' )
|
66 |
-
),
|
67 |
-
array(
|
68 |
-
'label' => __( 'Textarea', 'theme-text-domain' ),
|
69 |
-
'id' => 'demo_textarea',
|
70 |
-
'type' => 'textarea',
|
71 |
-
'desc' => __( 'This is a demo Textarea field.', 'theme-text-domain' )
|
72 |
-
)
|
73 |
-
)
|
74 |
-
);
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Register our meta boxes using the
|
78 |
-
* ot_register_meta_box() function.
|
79 |
-
*/
|
80 |
-
if ( function_exists( 'ot_register_meta_box' ) )
|
81 |
-
ot_register_meta_box( $my_meta_box );
|
82 |
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Initialize the custom Meta Boxes.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
*/
|
7 |
+
|
8 |
add_action( 'admin_init', 'custom_meta_boxes' );
|
9 |
|
10 |
/**
|
12 |
*
|
13 |
* You can find all the available option types in demo-theme-options.php.
|
14 |
*
|
15 |
+
* @since 2.0
|
|
|
16 |
*/
|
17 |
function custom_meta_boxes() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
/**
|
20 |
+
* Create a custom meta boxes array that we pass to
|
21 |
+
* the OptionTree Meta Box API Class.
|
22 |
+
*/
|
23 |
+
$my_meta_box = array(
|
24 |
+
'id' => 'demo_meta_box',
|
25 |
+
'title' => __( 'Demo Meta Box', 'theme-text-domain' ),
|
26 |
+
'desc' => '',
|
27 |
+
'pages' => array( 'post' ),
|
28 |
+
'context' => 'normal',
|
29 |
+
'priority' => 'high',
|
30 |
+
'fields' => array(
|
31 |
+
array(
|
32 |
+
'label' => __( 'Conditions', 'theme-text-domain' ),
|
33 |
+
'id' => 'demo_conditions',
|
34 |
+
'type' => 'tab',
|
35 |
+
),
|
36 |
+
array(
|
37 |
+
'label' => __( 'Show Gallery', 'theme-text-domain' ),
|
38 |
+
'id' => 'demo_show_gallery',
|
39 |
+
'type' => 'on-off',
|
40 |
+
'desc' => sprintf( __( 'Shows the Gallery when set to %s.', 'theme-text-domain' ), '<code>on</code>' ),
|
41 |
+
'std' => 'off',
|
42 |
+
),
|
43 |
+
array(
|
44 |
+
'label' => '',
|
45 |
+
'id' => 'demo_textblock',
|
46 |
+
'type' => 'textblock',
|
47 |
+
'desc' => __( 'Congratulations, you created a gallery!', 'theme-text-domain' ),
|
48 |
+
'operator' => 'and',
|
49 |
+
'condition' => 'demo_show_gallery:is(on),demo_gallery:not()',
|
50 |
+
),
|
51 |
+
array(
|
52 |
+
'label' => __( 'Gallery', 'theme-text-domain' ),
|
53 |
+
'id' => 'demo_gallery',
|
54 |
+
'type' => 'gallery',
|
55 |
+
'desc' => sprintf( __( 'This is a Gallery option type. It displays when %s.', 'theme-text-domain' ), '<code>demo_show_gallery:is(on)</code>' ),
|
56 |
+
'condition' => 'demo_show_gallery:is(on)',
|
57 |
+
),
|
58 |
+
array(
|
59 |
+
'label' => __( 'More Options', 'theme-text-domain' ),
|
60 |
+
'id' => 'demo_more_options',
|
61 |
+
'type' => 'tab',
|
62 |
+
),
|
63 |
+
array(
|
64 |
+
'label' => __( 'Text', 'theme-text-domain' ),
|
65 |
+
'id' => 'demo_text',
|
66 |
+
'type' => 'text',
|
67 |
+
'desc' => __( 'This is a demo Text field.', 'theme-text-domain' ),
|
68 |
+
),
|
69 |
+
array(
|
70 |
+
'label' => __( 'Textarea', 'theme-text-domain' ),
|
71 |
+
'id' => 'demo_textarea',
|
72 |
+
'type' => 'textarea',
|
73 |
+
'desc' => __( 'This is a demo Textarea field.', 'theme-text-domain' ),
|
74 |
+
),
|
75 |
+
),
|
76 |
+
);
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Register our meta boxes using the
|
80 |
+
* ot_register_meta_box() function.
|
81 |
+
*/
|
82 |
+
if ( function_exists( 'ot_register_meta_box' ) ) {
|
83 |
+
ot_register_meta_box( $my_meta_box );
|
84 |
+
}
|
85 |
+
}
|
assets/theme-mode/demo-theme-options.php
CHANGED
@@ -1,812 +1,814 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Initialize the custom Theme Options.
|
|
|
|
|
4 |
*/
|
|
|
5 |
add_action( 'init', 'custom_theme_options' );
|
6 |
|
7 |
/**
|
8 |
* Build the custom settings & update OptionTree.
|
9 |
*
|
10 |
-
* @
|
11 |
-
* @since 2.0
|
12 |
*/
|
13 |
function custom_theme_options() {
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
array(
|
180 |
-
'id' => 'demo_css',
|
181 |
-
'label' => __( 'CSS', 'theme-text-domain' ),
|
182 |
-
'desc' => '<p>' . sprintf( __( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named %s at the root level of your theme and change permissions using %s so the server can write to the file. I have had the most success setting this single file to %s but feel free to play around with permissions until everything is working. A good starting point is %s. When the server can save to the file, CSS will automatically be updated when you save your Theme Options.', 'theme-text-domain' ), '<code>dynamic.css</code>', '<code>chmod</code>', '<code>0777</code>', '<code>0666</code>' ) . '</p><p>' . sprintf( __( 'This example assumes you have an option with the ID of %1$s. Which means this option will automatically insert the value of %1$s into the %2$s when the Theme Options are saved.', 'theme-text-domain' ), '<code>demo_background</code>', '<code>dynamic.css</code>' ) . '</p>',
|
183 |
-
'std' => '#custom {
|
184 |
{{demo_background}}
|
185 |
}',
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
* Initialize the custom Theme Options.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
*/
|
7 |
+
|
8 |
add_action( 'init', 'custom_theme_options' );
|
9 |
|
10 |
/**
|
11 |
* Build the custom settings & update OptionTree.
|
12 |
*
|
13 |
+
* @since 2.0
|
|
|
14 |
*/
|
15 |
function custom_theme_options() {
|
16 |
|
17 |
+
// OptionTree is not loaded yet, or this is not an admin request.
|
18 |
+
if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() ) {
|
19 |
+
return false;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get a copy of the saved settings array.
|
24 |
+
*/
|
25 |
+
$saved_settings = get_option( ot_settings_id(), array() );
|
26 |
|
27 |
+
/**
|
28 |
+
* Custom settings array that will eventually be
|
29 |
+
* passes to the OptionTree Settings API Class.
|
30 |
+
*/
|
31 |
+
$custom_settings = array(
|
32 |
+
'contextual_help' => array(
|
33 |
+
'content' => array(
|
34 |
+
array(
|
35 |
+
'id' => 'option_types_help',
|
36 |
+
'title' => __( 'Option Types', 'theme-text-domain' ),
|
37 |
+
'content' => '<p>' . __( 'Help content goes here!', 'theme-text-domain' ) . '</p>',
|
38 |
+
),
|
39 |
+
),
|
40 |
+
'sidebar' => '<p>' . __( 'Sidebar content goes here!', 'theme-text-domain' ) . '</p>',
|
41 |
+
),
|
42 |
+
'sections' => array(
|
43 |
+
array(
|
44 |
+
'id' => 'option_types',
|
45 |
+
'title' => __( 'Option Types', 'theme-text-domain' ),
|
46 |
+
),
|
47 |
+
),
|
48 |
+
'settings' => array(
|
49 |
+
array(
|
50 |
+
'id' => 'demo_background',
|
51 |
+
'label' => __( 'Background', 'theme-text-domain' ),
|
52 |
+
'desc' => sprintf( __( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with %1$s. The Background option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'theme-text-domain' ), '<code>ot_get_option()</code>', '<code>ot_recognized_background_fields</code>', '<code>ot_recognized_background_repeat</code>, <code>ot_recognized_background_attachment</code>, <code>ot_recognized_background_position</code>, ' . __( 'and', 'theme-text-domain' ) . ' <code>ot_type_background_size_choices</code>' ),
|
53 |
+
'std' => '',
|
54 |
+
'type' => 'background',
|
55 |
+
'section' => 'option_types',
|
56 |
+
'rows' => '',
|
57 |
+
'post_type' => '',
|
58 |
+
'taxonomy' => '',
|
59 |
+
'min_max_step' => '',
|
60 |
+
'class' => '',
|
61 |
+
'condition' => '',
|
62 |
+
'operator' => 'and',
|
63 |
+
),
|
64 |
+
array(
|
65 |
+
'id' => 'demo_border',
|
66 |
+
'label' => __( 'Border', 'theme-text-domain' ),
|
67 |
+
'desc' => __( 'The Border option type is used to set width, unit, style, and color values.', 'theme-text-domain' ),
|
68 |
+
'std' => '',
|
69 |
+
'type' => 'border',
|
70 |
+
'section' => 'option_types',
|
71 |
+
'rows' => '',
|
72 |
+
'post_type' => '',
|
73 |
+
'taxonomy' => '',
|
74 |
+
'min_max_step' => '',
|
75 |
+
'class' => '',
|
76 |
+
'condition' => '',
|
77 |
+
'operator' => 'and',
|
78 |
+
),
|
79 |
+
array(
|
80 |
+
'id' => 'demo_box_shadow',
|
81 |
+
'label' => __( 'Box Shadow', 'theme-text-domain' ),
|
82 |
+
'desc' => sprintf( __( 'The Box Shadow option type is used to set %1$s, %2$s, %3$s, %4$s, %5$s, and %6$s values.', 'theme-text-domain' ), '<code>inset</code>', '<code>offset-x</code>', '<code>offset-y</code>', '<code>blur-radius</code>', '<code>spread-radius</code>', '<code>color</code>' ),
|
83 |
+
'std' => '',
|
84 |
+
'type' => 'box-shadow',
|
85 |
+
'section' => 'option_types',
|
86 |
+
'rows' => '',
|
87 |
+
'post_type' => '',
|
88 |
+
'taxonomy' => '',
|
89 |
+
'min_max_step' => '',
|
90 |
+
'class' => '',
|
91 |
+
'condition' => '',
|
92 |
+
'operator' => 'and',
|
93 |
+
),
|
94 |
+
array(
|
95 |
+
'id' => 'demo_category_checkbox',
|
96 |
+
'label' => __( 'Category Checkbox', 'theme-text-domain' ),
|
97 |
+
'desc' => __( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ),
|
98 |
+
'std' => '',
|
99 |
+
'type' => 'category-checkbox',
|
100 |
+
'section' => 'option_types',
|
101 |
+
'rows' => '',
|
102 |
+
'post_type' => '',
|
103 |
+
'taxonomy' => '',
|
104 |
+
'min_max_step' => '',
|
105 |
+
'class' => '',
|
106 |
+
'condition' => '',
|
107 |
+
'operator' => 'and',
|
108 |
+
),
|
109 |
+
array(
|
110 |
+
'id' => 'demo_category_select',
|
111 |
+
'label' => __( 'Category Select', 'theme-text-domain' ),
|
112 |
+
'desc' => __( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ),
|
113 |
+
'std' => '',
|
114 |
+
'type' => 'category-select',
|
115 |
+
'section' => 'option_types',
|
116 |
+
'rows' => '',
|
117 |
+
'post_type' => '',
|
118 |
+
'taxonomy' => '',
|
119 |
+
'min_max_step' => '',
|
120 |
+
'class' => '',
|
121 |
+
'condition' => '',
|
122 |
+
'operator' => 'and',
|
123 |
+
),
|
124 |
+
array(
|
125 |
+
'id' => 'demo_checkbox',
|
126 |
+
'label' => __( 'Checkbox', 'theme-text-domain' ),
|
127 |
+
'desc' => __( 'The Checkbox option type displays a group of choices. It allows the user to check multiple choices and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ),
|
128 |
+
'std' => '',
|
129 |
+
'type' => 'checkbox',
|
130 |
+
'section' => 'option_types',
|
131 |
+
'rows' => '',
|
132 |
+
'post_type' => '',
|
133 |
+
'taxonomy' => '',
|
134 |
+
'min_max_step' => '',
|
135 |
+
'class' => '',
|
136 |
+
'condition' => '',
|
137 |
+
'operator' => 'and',
|
138 |
+
'choices' => array(
|
139 |
+
array(
|
140 |
+
'value' => 'no',
|
141 |
+
'label' => __( 'No', 'theme-text-domain' ),
|
142 |
+
'src' => '',
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'value' => 'Yes',
|
146 |
+
'label' => __( 'Yes', 'theme-text-domain' ),
|
147 |
+
'src' => '',
|
148 |
+
),
|
149 |
+
),
|
150 |
+
),
|
151 |
+
array(
|
152 |
+
'id' => 'demo_colorpicker',
|
153 |
+
'label' => __( 'Colorpicker', 'theme-text-domain' ),
|
154 |
+
'desc' => __( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'theme-text-domain' ),
|
155 |
+
'std' => '',
|
156 |
+
'type' => 'colorpicker',
|
157 |
+
'section' => 'option_types',
|
158 |
+
'rows' => '',
|
159 |
+
'post_type' => '',
|
160 |
+
'taxonomy' => '',
|
161 |
+
'min_max_step' => '',
|
162 |
+
'class' => '',
|
163 |
+
'condition' => '',
|
164 |
+
'operator' => 'and',
|
165 |
+
),
|
166 |
+
array(
|
167 |
+
'id' => 'demo_colorpicker_opacity',
|
168 |
+
'label' => __( 'Colorpicker Opacity', 'theme-text-domain' ),
|
169 |
+
'desc' => __( 'Colorpicker Opacity', 'option-tree-theme' ),
|
170 |
+
'desc' => sprintf( __( 'The Colorpicker Opacity option type saves an rgba color value for use in CSS. To add opacity to other colorpickers add the %1$s class to the %2$s array.', 'option-tree' ), '<code>ot-colorpicker-opacity</code>', '<code>$args</code>' ),
|
171 |
+
'std' => '',
|
172 |
+
'type' => 'colorpicker-opacity',
|
173 |
+
'section' => 'option_types',
|
174 |
+
'rows' => '',
|
175 |
+
'post_type' => '',
|
176 |
+
'taxonomy' => '',
|
177 |
+
'min_max_step' => '',
|
178 |
+
'class' => '',
|
179 |
+
'condition' => '',
|
180 |
+
'operator' => 'and',
|
181 |
+
),
|
182 |
+
array(
|
183 |
+
'id' => 'demo_css',
|
184 |
+
'label' => __( 'CSS', 'theme-text-domain' ),
|
185 |
+
'desc' => '<p>' . sprintf( __( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named %1$s at the root level of your theme and change permissions using %2$s so the server can write to the file. I have had the most success setting this single file to %3$s but feel free to play around with permissions until everything is working. A good starting point is %4$s. When the server can save to the file, CSS will automatically be updated when you save your Theme Options.', 'theme-text-domain' ), '<code>dynamic.css</code>', '<code>chmod</code>', '<code>0777</code>', '<code>0666</code>' ) . '</p><p>' . sprintf( __( 'This example assumes you have an option with the ID of %1$s. Which means this option will automatically insert the value of %1$s into the %2$s when the Theme Options are saved.', 'theme-text-domain' ), '<code>demo_background</code>', '<code>dynamic.css</code>' ) . '</p>',
|
186 |
+
'std' => '#custom {
|
|
|
|
|
|
|
|
|
|
|
187 |
{{demo_background}}
|
188 |
}',
|
189 |
+
'type' => 'css',
|
190 |
+
'section' => 'option_types',
|
191 |
+
'rows' => '20',
|
192 |
+
'post_type' => '',
|
193 |
+
'taxonomy' => '',
|
194 |
+
'min_max_step' => '',
|
195 |
+
'class' => '',
|
196 |
+
'condition' => '',
|
197 |
+
'operator' => 'and',
|
198 |
+
),
|
199 |
+
array(
|
200 |
+
'id' => 'demo_custom_post_type_checkbox',
|
201 |
+
'label' => __( 'Custom Post Type Checkbox', 'theme-text-domain' ),
|
202 |
+
'desc' => sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'theme-text-domain' ), '<code>post_type</code>' ),
|
203 |
+
'std' => '',
|
204 |
+
'type' => 'custom-post-type-checkbox',
|
205 |
+
'section' => 'option_types',
|
206 |
+
'rows' => '',
|
207 |
+
'post_type' => 'post',
|
208 |
+
'taxonomy' => '',
|
209 |
+
'min_max_step' => '',
|
210 |
+
'class' => '',
|
211 |
+
'condition' => '',
|
212 |
+
'operator' => 'and',
|
213 |
+
),
|
214 |
+
array(
|
215 |
+
'id' => 'demo_custom_post_type_select',
|
216 |
+
'label' => __( 'Custom Post Type Select', 'theme-text-domain' ),
|
217 |
+
'desc' => sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'theme-text-domain' ), '<code>post_type</code>' ),
|
218 |
+
'std' => '',
|
219 |
+
'type' => 'custom-post-type-select',
|
220 |
+
'section' => 'option_types',
|
221 |
+
'rows' => '',
|
222 |
+
'post_type' => 'post',
|
223 |
+
'taxonomy' => '',
|
224 |
+
'min_max_step' => '',
|
225 |
+
'class' => '',
|
226 |
+
'condition' => '',
|
227 |
+
'operator' => 'and',
|
228 |
+
),
|
229 |
+
array(
|
230 |
+
'id' => 'demo_date_picker',
|
231 |
+
'label' => __( 'Date Picker', 'theme-text-domain' ),
|
232 |
+
'desc' => __( 'The Date Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date when focus is given to the input field. The returned value is a date formatted string.', 'theme-text-domain' ),
|
233 |
+
'std' => '',
|
234 |
+
'type' => 'date-picker',
|
235 |
+
'section' => 'option_types',
|
236 |
+
'rows' => '',
|
237 |
+
'post_type' => '',
|
238 |
+
'taxonomy' => '',
|
239 |
+
'min_max_step' => '',
|
240 |
+
'class' => '',
|
241 |
+
'condition' => '',
|
242 |
+
'operator' => 'and',
|
243 |
+
),
|
244 |
+
array(
|
245 |
+
'id' => 'demo_date_time_picker',
|
246 |
+
'label' => __( 'Date Time Picker', 'theme-text-domain' ),
|
247 |
+
'desc' => __( 'The Date Time Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date and time when focus is given to the input field. The returned value is a date and time formatted string.', 'theme-text-domain' ),
|
248 |
+
'std' => '',
|
249 |
+
'type' => 'date-time-picker',
|
250 |
+
'section' => 'option_types',
|
251 |
+
'rows' => '',
|
252 |
+
'post_type' => '',
|
253 |
+
'taxonomy' => '',
|
254 |
+
'min_max_step' => '',
|
255 |
+
'class' => '',
|
256 |
+
'condition' => '',
|
257 |
+
'operator' => 'and',
|
258 |
+
),
|
259 |
+
array(
|
260 |
+
'id' => 'demo_dimension',
|
261 |
+
'label' => __( 'Dimension', 'theme-text-domain' ),
|
262 |
+
'desc' => __( 'The Dimension option type is used to set width and height values.', 'theme-text-domain' ),
|
263 |
+
'std' => '',
|
264 |
+
'type' => 'dimension',
|
265 |
+
'section' => 'option_types',
|
266 |
+
'rows' => '',
|
267 |
+
'post_type' => '',
|
268 |
+
'taxonomy' => '',
|
269 |
+
'min_max_step' => '',
|
270 |
+
'class' => '',
|
271 |
+
'condition' => '',
|
272 |
+
'operator' => 'and',
|
273 |
+
),
|
274 |
+
array(
|
275 |
+
'id' => 'demo_gallery',
|
276 |
+
'label' => __( 'Gallery', 'theme-text-domain' ),
|
277 |
+
'desc' => __( 'The Gallery option type saves a comma separated list of image attachment IDs. You will need to create a front-end function to display the images in your theme.', 'theme-text-domain' ),
|
278 |
+
'std' => '',
|
279 |
+
'type' => 'gallery',
|
280 |
+
'section' => 'option_types',
|
281 |
+
'rows' => '',
|
282 |
+
'post_type' => '',
|
283 |
+
'taxonomy' => '',
|
284 |
+
'min_max_step' => '',
|
285 |
+
'class' => '',
|
286 |
+
'condition' => '',
|
287 |
+
'operator' => 'and',
|
288 |
+
),
|
289 |
+
array(
|
290 |
+
'id' => 'demo_gallery_shortcode',
|
291 |
+
'label' => __( 'Gallery Shortcode', 'theme-text-domain' ),
|
292 |
+
'desc' => sprintf( __( 'The Gallery option type can also be saved as a shortcode by adding %s to the class attribute. Using the Gallery option type in this manner will result in a better user experience as you\'re able to save the link, column, and order settings.', 'theme-text-domain' ), '<code>ot-gallery-shortcode</code>' ),
|
293 |
+
'std' => '',
|
294 |
+
'type' => 'gallery',
|
295 |
+
'section' => 'option_types',
|
296 |
+
'rows' => '',
|
297 |
+
'post_type' => '',
|
298 |
+
'taxonomy' => '',
|
299 |
+
'min_max_step' => '',
|
300 |
+
'class' => 'ot-gallery-shortcode',
|
301 |
+
'condition' => '',
|
302 |
+
'operator' => 'and',
|
303 |
+
),
|
304 |
+
array(
|
305 |
+
'id' => 'demo_google_fonts',
|
306 |
+
'label' => __( 'Google Fonts', 'theme-text-domain' ),
|
307 |
+
'desc' => sprintf( __( 'The Google Fonts option type will dynamically enqueue any number of Google Web Fonts into the document %1$s. As well, once the option has been saved each font family will automatically be inserted into the %2$s array for the Typography option type. You can further modify the font stack by using the %3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s parameter is being passed from %7$s, so it will be the ID of a Typography option type. This will allow you to add additional web safe fonts to individual font families on an as-need basis.', 'theme-text-domain' ), '<code>HEAD</code>', '<code>font-family</code>', '<code>ot_google_font_stack</code>', '<code>$font_stack</code>', '<code>$family</code>', '<code>$field_id</code>', '<code>ot_recognized_font_families</code>' ),
|
308 |
+
'std' => array(
|
309 |
+
array(
|
310 |
+
'family' => 'opensans',
|
311 |
+
'variants' => array( '300', '300italic', 'regular', 'italic', '600', '600italic' ),
|
312 |
+
'subsets' => array( 'latin' ),
|
313 |
+
),
|
314 |
+
),
|
315 |
+
'type' => 'google-fonts',
|
316 |
+
'section' => 'option_types',
|
317 |
+
'rows' => '',
|
318 |
+
'post_type' => '',
|
319 |
+
'taxonomy' => '',
|
320 |
+
'min_max_step' => '',
|
321 |
+
'class' => '',
|
322 |
+
'condition' => '',
|
323 |
+
'operator' => 'and',
|
324 |
+
),
|
325 |
+
array(
|
326 |
+
'id' => 'demo_javascript',
|
327 |
+
'label' => __( 'JavaScript', 'theme-text-domain' ),
|
328 |
+
'desc' => '<p>' . sprintf( __( 'The JavaScript option type is a textarea that uses the %s code editor to highlight your JavaScript and display errors as you type.', 'theme-text-domain' ), '<code>ace.js</code>' ) . '</p>',
|
329 |
+
'std' => '',
|
330 |
+
'type' => 'javascript',
|
331 |
+
'section' => 'option_types',
|
332 |
+
'rows' => '20',
|
333 |
+
'post_type' => '',
|
334 |
+
'taxonomy' => '',
|
335 |
+
'min_max_step' => '',
|
336 |
+
'class' => '',
|
337 |
+
'condition' => '',
|
338 |
+
'operator' => 'and',
|
339 |
+
),
|
340 |
+
array(
|
341 |
+
'id' => 'demo_link_color',
|
342 |
+
'label' => __( 'Link Color', 'theme-text-domain' ),
|
343 |
+
'desc' => __( 'The Link Color option type is used to set all link color states.', 'theme-text-domain' ),
|
344 |
+
'std' => '',
|
345 |
+
'type' => 'link-color',
|
346 |
+
'section' => 'option_types',
|
347 |
+
'rows' => '',
|
348 |
+
'post_type' => '',
|
349 |
+
'taxonomy' => '',
|
350 |
+
'min_max_step' => '',
|
351 |
+
'class' => '',
|
352 |
+
'condition' => '',
|
353 |
+
'operator' => 'and',
|
354 |
+
),
|
355 |
+
array(
|
356 |
+
'id' => 'demo_list_item',
|
357 |
+
'label' => __( 'List Item', 'theme-text-domain' ),
|
358 |
+
'desc' => __( 'The List Item option type allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'theme-text-domain' ),
|
359 |
+
'std' => '',
|
360 |
+
'type' => 'list-item',
|
361 |
+
'section' => 'option_types',
|
362 |
+
'rows' => '',
|
363 |
+
'post_type' => '',
|
364 |
+
'taxonomy' => '',
|
365 |
+
'min_max_step' => '',
|
366 |
+
'class' => '',
|
367 |
+
'condition' => '',
|
368 |
+
'operator' => 'and',
|
369 |
+
'settings' => array(
|
370 |
+
array(
|
371 |
+
'id' => 'demo_list_item_content',
|
372 |
+
'label' => __( 'Content', 'theme-text-domain' ),
|
373 |
+
'desc' => '',
|
374 |
+
'std' => '',
|
375 |
+
'type' => 'textarea-simple',
|
376 |
+
'rows' => '10',
|
377 |
+
'post_type' => '',
|
378 |
+
'taxonomy' => '',
|
379 |
+
'min_max_step' => '',
|
380 |
+
'class' => '',
|
381 |
+
'condition' => '',
|
382 |
+
'operator' => 'and',
|
383 |
+
),
|
384 |
+
),
|
385 |
+
),
|
386 |
+
array(
|
387 |
+
'id' => 'demo_measurement',
|
388 |
+
'label' => __( 'Measurement', 'theme-text-domain' ),
|
389 |
+
'desc' => sprintf( __( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'theme-text-domain' ), '<code>px</code>', '<code>%</code>', '<code>em</code>', '<code>pt</code>', '<code>ot_measurement_unit_types</code>' ),
|
390 |
+
'std' => '',
|
391 |
+
'type' => 'measurement',
|
392 |
+
'section' => 'option_types',
|
393 |
+
'rows' => '',
|
394 |
+
'post_type' => '',
|
395 |
+
'taxonomy' => '',
|
396 |
+
'min_max_step' => '',
|
397 |
+
'class' => '',
|
398 |
+
'condition' => '',
|
399 |
+
'operator' => 'and',
|
400 |
+
),
|
401 |
+
array(
|
402 |
+
'id' => 'demo_numeric_slider',
|
403 |
+
'label' => __( 'Numeric Slider', 'theme-text-domain' ),
|
404 |
+
'desc' => __( 'The Numeric Slider option type displays a jQuery UI slider. It will return a single numerical value for use in a custom function or loop.', 'theme-text-domain' ),
|
405 |
+
'std' => '',
|
406 |
+
'type' => 'numeric-slider',
|
407 |
+
'section' => 'option_types',
|
408 |
+
'rows' => '',
|
409 |
+
'post_type' => '',
|
410 |
+
'taxonomy' => '',
|
411 |
+
'min_max_step' => '-500,5000,100',
|
412 |
+
'class' => '',
|
413 |
+
'condition' => '',
|
414 |
+
'operator' => 'and',
|
415 |
+
),
|
416 |
+
array(
|
417 |
+
'id' => 'demo_on_off',
|
418 |
+
'label' => __( 'On/Off', 'theme-text-domain' ),
|
419 |
+
'desc' => sprintf( __( 'The On/Off option type displays a simple switch that can be used to turn things on or off. The saved return value is either %1$s or %2$s.', 'theme-text-domain' ), '<code>on</code>', '<code>off</code>' ),
|
420 |
+
'std' => '',
|
421 |
+
'type' => 'on-off',
|
422 |
+
'section' => 'option_types',
|
423 |
+
'rows' => '',
|
424 |
+
'post_type' => '',
|
425 |
+
'taxonomy' => '',
|
426 |
+
'min_max_step' => '',
|
427 |
+
'class' => '',
|
428 |
+
'condition' => '',
|
429 |
+
'operator' => 'and',
|
430 |
+
),
|
431 |
+
array(
|
432 |
+
'id' => 'demo_page_checkbox',
|
433 |
+
'label' => __( 'Page Checkbox', 'theme-text-domain' ),
|
434 |
+
'desc' => __( 'The Page Checkbox option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'theme-text-domain' ),
|
435 |
+
'std' => '',
|
436 |
+
'type' => 'page-checkbox',
|
437 |
+
'section' => 'option_types',
|
438 |
+
'rows' => '',
|
439 |
+
'post_type' => '',
|
440 |
+
'taxonomy' => '',
|
441 |
+
'min_max_step' => '',
|
442 |
+
'class' => '',
|
443 |
+
'condition' => '',
|
444 |
+
'operator' => 'and',
|
445 |
+
),
|
446 |
+
array(
|
447 |
+
'id' => 'demo_page_select',
|
448 |
+
'label' => __( 'Page Select', 'theme-text-domain' ),
|
449 |
+
'desc' => __( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'theme-text-domain' ),
|
450 |
+
'std' => '',
|
451 |
+
'type' => 'page-select',
|
452 |
+
'section' => 'option_types',
|
453 |
+
'rows' => '',
|
454 |
+
'post_type' => '',
|
455 |
+
'taxonomy' => '',
|
456 |
+
'min_max_step' => '',
|
457 |
+
'class' => '',
|
458 |
+
'condition' => '',
|
459 |
+
'operator' => 'and',
|
460 |
+
),
|
461 |
+
array(
|
462 |
+
'id' => 'demo_post_checkbox',
|
463 |
+
'label' => __( 'Post Checkbox', 'theme-text-domain' ),
|
464 |
+
'desc' => __( 'The Post Checkbox option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'theme-text-domain' ),
|
465 |
+
'std' => '',
|
466 |
+
'type' => 'post-checkbox',
|
467 |
+
'section' => 'option_types',
|
468 |
+
'rows' => '',
|
469 |
+
'post_type' => '',
|
470 |
+
'taxonomy' => '',
|
471 |
+
'min_max_step' => '',
|
472 |
+
'class' => '',
|
473 |
+
'condition' => '',
|
474 |
+
'operator' => 'and',
|
475 |
+
),
|
476 |
+
array(
|
477 |
+
'id' => 'demo_post_select',
|
478 |
+
'label' => __( 'Post Select', 'theme-text-domain' ),
|
479 |
+
'desc' => __( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'theme-text-domain' ),
|
480 |
+
'std' => '',
|
481 |
+
'type' => 'post-select',
|
482 |
+
'section' => 'option_types',
|
483 |
+
'rows' => '',
|
484 |
+
'post_type' => '',
|
485 |
+
'taxonomy' => '',
|
486 |
+
'min_max_step' => '',
|
487 |
+
'class' => '',
|
488 |
+
'condition' => '',
|
489 |
+
'operator' => 'and',
|
490 |
+
),
|
491 |
+
array(
|
492 |
+
'id' => 'demo_radio',
|
493 |
+
'label' => __( 'Radio', 'theme-text-domain' ),
|
494 |
+
'desc' => __( 'The Radio option type displays a group of choices. It allows the user to choose one and will return that value as a string for use in a custom function or loop.', 'theme-text-domain' ),
|
495 |
+
'std' => '',
|
496 |
+
'type' => 'radio',
|
497 |
+
'section' => 'option_types',
|
498 |
+
'rows' => '',
|
499 |
+
'post_type' => '',
|
500 |
+
'taxonomy' => '',
|
501 |
+
'min_max_step' => '',
|
502 |
+
'class' => '',
|
503 |
+
'condition' => '',
|
504 |
+
'operator' => 'and',
|
505 |
+
'choices' => array(
|
506 |
+
array(
|
507 |
+
'value' => 'yes',
|
508 |
+
'label' => __( 'Yes', 'theme-text-domain' ),
|
509 |
+
'src' => '',
|
510 |
+
),
|
511 |
+
array(
|
512 |
+
'value' => 'no',
|
513 |
+
'label' => __( 'No', 'theme-text-domain' ),
|
514 |
+
'src' => '',
|
515 |
+
),
|
516 |
+
array(
|
517 |
+
'value' => 'maybe',
|
518 |
+
'label' => __( 'Maybe', 'theme-text-domain' ),
|
519 |
+
'src' => '',
|
520 |
+
),
|
521 |
+
),
|
522 |
+
),
|
523 |
+
array(
|
524 |
+
'id' => 'demo_radio_image',
|
525 |
+
'label' => __( 'Radio Image', 'theme-text-domain' ),
|
526 |
+
'desc' => sprintf( __( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using %s. As well, you can add your own custom images using the choices array.', 'theme-text-domain' ), '<code>ot_radio_images</code>' ),
|
527 |
+
'std' => 'right-sidebar',
|
528 |
+
'type' => 'radio-image',
|
529 |
+
'section' => 'option_types',
|
530 |
+
'rows' => '',
|
531 |
+
'post_type' => '',
|
532 |
+
'taxonomy' => '',
|
533 |
+
'min_max_step' => '',
|
534 |
+
'class' => '',
|
535 |
+
'condition' => '',
|
536 |
+
'operator' => 'and',
|
537 |
+
),
|
538 |
+
array(
|
539 |
+
'id' => 'demo_select',
|
540 |
+
'label' => __( 'Select', 'theme-text-domain' ),
|
541 |
+
'desc' => __( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'theme-text-domain' ),
|
542 |
+
'std' => '',
|
543 |
+
'type' => 'select',
|
544 |
+
'section' => 'option_types',
|
545 |
+
'rows' => '',
|
546 |
+
'post_type' => '',
|
547 |
+
'taxonomy' => '',
|
548 |
+
'min_max_step' => '',
|
549 |
+
'class' => '',
|
550 |
+
'condition' => '',
|
551 |
+
'operator' => 'and',
|
552 |
+
'choices' => array(
|
553 |
+
array(
|
554 |
+
'value' => '',
|
555 |
+
'label' => __( '-- Choose One --', 'theme-text-domain' ),
|
556 |
+
'src' => '',
|
557 |
+
),
|
558 |
+
array(
|
559 |
+
'value' => 'yes',
|
560 |
+
'label' => __( 'Yes', 'theme-text-domain' ),
|
561 |
+
'src' => '',
|
562 |
+
),
|
563 |
+
array(
|
564 |
+
'value' => 'no',
|
565 |
+
'label' => __( 'No', 'theme-text-domain' ),
|
566 |
+
'src' => '',
|
567 |
+
),
|
568 |
+
array(
|
569 |
+
'value' => 'maybe',
|
570 |
+
'label' => __( 'Maybe', 'theme-text-domain' ),
|
571 |
+
'src' => '',
|
572 |
+
),
|
573 |
+
),
|
574 |
+
),
|
575 |
+
array(
|
576 |
+
'id' => 'demo_sidebar_select',
|
577 |
+
'label' => __( 'Sidebar Select', 'theme-text-domain' ),
|
578 |
+
'desc' => '<p>' . sprintf( __( 'This option type makes it possible for users to select a WordPress registered sidebar to use on a specific area. By using the two provided filters, %1$s, and %2$s we can be selective about which sidebars are available on a specific content area.', 'theme-text-domain' ), '<code>ot_recognized_sidebars</code>', '<code>ot_recognized_sidebars_{$field_id}</code>' ) . '</p><p>' . sprintf( __( 'For example, if we create a WordPress theme that provides the ability to change the Blog Sidebar and we don\'t want to have the footer sidebars available on this area, we can unset those sidebars either manually or by using a regular expression if we have a common name like %s.', 'theme-text-domain' ), '<code>footer-sidebar-$i</code>' ) . '</p>',
|
579 |
+
'std' => '',
|
580 |
+
'type' => 'sidebar-select',
|
581 |
+
'section' => 'option_types',
|
582 |
+
'rows' => '',
|
583 |
+
'post_type' => '',
|
584 |
+
'taxonomy' => '',
|
585 |
+
'min_max_step' => '',
|
586 |
+
'class' => '',
|
587 |
+
'condition' => '',
|
588 |
+
'operator' => 'and',
|
589 |
+
),
|
590 |
+
array(
|
591 |
+
'id' => 'demo_social_links',
|
592 |
+
'label' => __( 'Social Links', 'theme-text-domain' ),
|
593 |
+
'desc' => '<p>' . sprintf( __( 'The Social Links option type utilizes a drag & drop interface to create a list of social links. There are a few filters that make extending this option type easy. You can set the %1$s filter to %2$s and turn off loading default values. Use the %3$s filter to change the default values that are loaded. To filter the settings array use the %4$s filter.', 'theme-text-domain' ), '<code>ot_type_social_links_load_defaults</code>', '<code>false</code>', '<code>ot_type_social_links_defaults</code>', '<code>ot_social_links_settings</code>' ) . '</p>',
|
594 |
+
'std' => '',
|
595 |
+
'type' => 'social-links',
|
596 |
+
'section' => 'option_types',
|
597 |
+
'rows' => '',
|
598 |
+
'post_type' => '',
|
599 |
+
'taxonomy' => '',
|
600 |
+
'min_max_step' => '',
|
601 |
+
'class' => '',
|
602 |
+
'condition' => '',
|
603 |
+
'operator' => 'and',
|
604 |
+
),
|
605 |
+
array(
|
606 |
+
'id' => 'demo_spacing',
|
607 |
+
'label' => __( 'Spacing', 'theme-text-domain' ),
|
608 |
+
'desc' => __( 'The Spacing option type is used to set spacing values such as padding or margin in the form of top, right, bottom, and left.', 'theme-text-domain' ),
|
609 |
+
'std' => '',
|
610 |
+
'type' => 'spacing',
|
611 |
+
'section' => 'option_types',
|
612 |
+
'rows' => '',
|
613 |
+
'post_type' => '',
|
614 |
+
'taxonomy' => '',
|
615 |
+
'min_max_step' => '',
|
616 |
+
'class' => '',
|
617 |
+
'condition' => '',
|
618 |
+
'operator' => 'and',
|
619 |
+
),
|
620 |
+
array(
|
621 |
+
'id' => 'demo_tag_checkbox',
|
622 |
+
'label' => __( 'Tag Checkbox', 'theme-text-domain' ),
|
623 |
+
'desc' => __( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ),
|
624 |
+
'std' => '',
|
625 |
+
'type' => 'tag-checkbox',
|
626 |
+
'section' => 'option_types',
|
627 |
+
'rows' => '',
|
628 |
+
'post_type' => '',
|
629 |
+
'taxonomy' => '',
|
630 |
+
'min_max_step' => '',
|
631 |
+
'class' => '',
|
632 |
+
'condition' => '',
|
633 |
+
'operator' => 'and',
|
634 |
+
),
|
635 |
+
array(
|
636 |
+
'id' => 'demo_tag_select',
|
637 |
+
'label' => __( 'Tag Select', 'theme-text-domain' ),
|
638 |
+
'desc' => __( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ),
|
639 |
+
'std' => '',
|
640 |
+
'type' => 'tag-select',
|
641 |
+
'section' => 'option_types',
|
642 |
+
'rows' => '',
|
643 |
+
'post_type' => '',
|
644 |
+
'taxonomy' => '',
|
645 |
+
'min_max_step' => '',
|
646 |
+
'class' => '',
|
647 |
+
'condition' => '',
|
648 |
+
'operator' => 'and',
|
649 |
+
),
|
650 |
+
array(
|
651 |
+
'id' => 'demo_taxonomy_checkbox',
|
652 |
+
'label' => __( 'Taxonomy Checkbox', 'theme-text-domain' ),
|
653 |
+
'desc' => __( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ),
|
654 |
+
'std' => '',
|
655 |
+
'type' => 'taxonomy-checkbox',
|
656 |
+
'section' => 'option_types',
|
657 |
+
'rows' => '',
|
658 |
+
'post_type' => '',
|
659 |
+
'taxonomy' => 'category,post_tag',
|
660 |
+
'min_max_step' => '',
|
661 |
+
'class' => '',
|
662 |
+
'condition' => '',
|
663 |
+
'operator' => 'and',
|
664 |
+
),
|
665 |
+
array(
|
666 |
+
'id' => 'demo_taxonomy_select',
|
667 |
+
'label' => __( 'Taxonomy Select', 'theme-text-domain' ),
|
668 |
+
'desc' => __( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ),
|
669 |
+
'std' => '',
|
670 |
+
'type' => 'taxonomy-select',
|
671 |
+
'section' => 'option_types',
|
672 |
+
'rows' => '',
|
673 |
+
'post_type' => '',
|
674 |
+
'taxonomy' => 'category,post_tag',
|
675 |
+
'min_max_step' => '',
|
676 |
+
'class' => '',
|
677 |
+
'condition' => '',
|
678 |
+
'operator' => 'and',
|
679 |
+
),
|
680 |
+
array(
|
681 |
+
'id' => 'demo_text',
|
682 |
+
'label' => __( 'Text', 'theme-text-domain' ),
|
683 |
+
'desc' => __( 'The Text option type is used to save string values. For example, any optional or required text that is of reasonably short character length.', 'theme-text-domain' ),
|
684 |
+
'std' => '',
|
685 |
+
'type' => 'text',
|
686 |
+
'section' => 'option_types',
|
687 |
+
'rows' => '',
|
688 |
+
'post_type' => '',
|
689 |
+
'taxonomy' => '',
|
690 |
+
'min_max_step' => '',
|
691 |
+
'class' => '',
|
692 |
+
'condition' => '',
|
693 |
+
'operator' => 'and',
|
694 |
+
),
|
695 |
+
array(
|
696 |
+
'id' => 'demo_textarea',
|
697 |
+
'label' => __( 'Textarea', 'theme-text-domain' ),
|
698 |
+
'desc' => sprintf( __( 'The Textarea option type is a large string value used for custom code or text in the theme and has a WYSIWYG editor that can be filtered to change the how it is displayed. For example, you can filter %1$s, %2$s, %3$s, and %4$s.', 'theme-text-domain' ), '<code>wpautop</code>', '<code>media_buttons</code>', '<code>tinymce</code>', '<code>quicktags</code>' ),
|
699 |
+
'std' => '',
|
700 |
+
'type' => 'textarea',
|
701 |
+
'section' => 'option_types',
|
702 |
+
'rows' => '15',
|
703 |
+
'post_type' => '',
|
704 |
+
'taxonomy' => '',
|
705 |
+
'min_max_step' => '',
|
706 |
+
'class' => '',
|
707 |
+
'condition' => '',
|
708 |
+
'operator' => 'and',
|
709 |
+
),
|
710 |
+
array(
|
711 |
+
'id' => 'demo_textarea_simple',
|
712 |
+
'label' => __( 'Textarea Simple', 'theme-text-domain' ),
|
713 |
+
'desc' => __( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The Textarea Simple does not have a WYSIWYG editor.', 'theme-text-domain' ),
|
714 |
+
'std' => '',
|
715 |
+
'type' => 'textarea-simple',
|
716 |
+
'section' => 'option_types',
|
717 |
+
'rows' => '10',
|
718 |
+
'post_type' => '',
|
719 |
+
'taxonomy' => '',
|
720 |
+
'min_max_step' => '',
|
721 |
+
'class' => '',
|
722 |
+
'condition' => '',
|
723 |
+
'operator' => 'and',
|
724 |
+
),
|
725 |
+
array(
|
726 |
+
'id' => 'demo_textblock',
|
727 |
+
'label' => __( 'Textblock', 'theme-text-domain' ),
|
728 |
+
'desc' => __( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML, but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'theme-text-domain' ),
|
729 |
+
'std' => '',
|
730 |
+
'type' => 'textblock',
|
731 |
+
'section' => 'option_types',
|
732 |
+
'rows' => '',
|
733 |
+
'post_type' => '',
|
734 |
+
'taxonomy' => '',
|
735 |
+
'min_max_step' => '',
|
736 |
+
'class' => '',
|
737 |
+
'condition' => '',
|
738 |
+
'operator' => 'and',
|
739 |
+
),
|
740 |
+
array(
|
741 |
+
'id' => 'demo_textblock_titled',
|
742 |
+
'label' => __( 'Textblock Titled', 'theme-text-domain' ),
|
743 |
+
'desc' => __( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML, and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'theme-text-domain' ),
|
744 |
+
'std' => '',
|
745 |
+
'type' => 'textblock-titled',
|
746 |
+
'section' => 'option_types',
|
747 |
+
'rows' => '',
|
748 |
+
'post_type' => '',
|
749 |
+
'taxonomy' => '',
|
750 |
+
'min_max_step' => '',
|
751 |
+
'class' => '',
|
752 |
+
'condition' => '',
|
753 |
+
'operator' => 'and',
|
754 |
+
),
|
755 |
+
array(
|
756 |
+
'id' => 'demo_typography',
|
757 |
+
'label' => __( 'Typography', 'theme-text-domain' ),
|
758 |
+
'desc' => sprintf( __( 'The Typography option type is for adding typography styles to your theme either dynamically via the CSS option type above or manually with %1$s. The Typography option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'theme-text-domain' ), '<code>ot_get_option()</code>', '<code>ot_recognized_typography_fields</code>', '<code>ot_recognized_font_families</code>, <code>ot_recognized_font_sizes</code>, <code>ot_recognized_font_styles</code>, <code>ot_recognized_font_variants</code>, <code>ot_recognized_font_weights</code>, <code>ot_recognized_letter_spacing</code>, <code>ot_recognized_line_heights</code>, <code>ot_recognized_text_decorations</code> ' . __( 'and', 'theme-text-domain' ) . ' <code>ot_recognized_text_transformations</code>' ),
|
759 |
+
'std' => '',
|
760 |
+
'type' => 'typography',
|
761 |
+
'section' => 'option_types',
|
762 |
+
'rows' => '',
|
763 |
+
'post_type' => '',
|
764 |
+
'taxonomy' => '',
|
765 |
+
'min_max_step' => '',
|
766 |
+
'class' => '',
|
767 |
+
'condition' => '',
|
768 |
+
'operator' => 'and',
|
769 |
+
),
|
770 |
+
array(
|
771 |
+
'id' => 'demo_upload',
|
772 |
+
'label' => __( 'Upload', 'theme-text-domain' ),
|
773 |
+
'desc' => sprintf( __( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "%1$s" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You will have to re-upload or %2$s any media to your new server and change the URIs if necessary.', 'theme-text-domain' ), apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'theme-text-domain' ) ), 'FTP' ),
|
774 |
+
'std' => '',
|
775 |
+
'type' => 'upload',
|
776 |
+
'section' => 'option_types',
|
777 |
+
'rows' => '',
|
778 |
+
'post_type' => '',
|
779 |
+
'taxonomy' => '',
|
780 |
+
'min_max_step' => '',
|
781 |
+
'class' => '',
|
782 |
+
'condition' => '',
|
783 |
+
'operator' => 'and',
|
784 |
+
),
|
785 |
+
array(
|
786 |
+
'id' => 'demo_upload_attachment_id',
|
787 |
+
'label' => __( 'Upload Attachment ID', 'theme-text-domain' ),
|
788 |
+
'desc' => sprintf( __( 'The Upload option type can also be saved as an attachment ID by adding %s to the class attribute.', 'theme-text-domain' ), '<code>ot-upload-attachment-id</code>' ),
|
789 |
+
'std' => '',
|
790 |
+
'type' => 'upload',
|
791 |
+
'section' => 'option_types',
|
792 |
+
'rows' => '',
|
793 |
+
'post_type' => '',
|
794 |
+
'taxonomy' => '',
|
795 |
+
'min_max_step' => '',
|
796 |
+
'class' => 'ot-upload-attachment-id',
|
797 |
+
'condition' => '',
|
798 |
+
'operator' => 'and',
|
799 |
+
),
|
800 |
+
),
|
801 |
+
);
|
802 |
+
|
803 |
+
// Allow settings to be filtered before saving.
|
804 |
+
$custom_settings = apply_filters( ot_settings_id() . '_args', $custom_settings );
|
805 |
+
|
806 |
+
// Settings are not the same update the DB.
|
807 |
+
if ( $saved_settings !== $custom_settings ) {
|
808 |
+
update_option( ot_settings_id(), $custom_settings );
|
809 |
+
}
|
810 |
+
|
811 |
+
// Lets OptionTree know the UI Builder is being overridden.
|
812 |
+
global $ot_has_custom_theme_options;
|
813 |
+
$ot_has_custom_theme_options = true;
|
814 |
+
}
|
|
composer.json
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
{
|
2 |
"name": "valendesigns/option-tree",
|
3 |
"description": "Theme Options UI Builder for WordPress.",
|
|
|
4 |
"homepage": "https://github.com/valendesigns/option-tree",
|
5 |
-
"license": "
|
6 |
"authors": [
|
7 |
{
|
8 |
"name": "Derek Herman",
|
@@ -11,9 +12,52 @@
|
|
11 |
"role": "Developer"
|
12 |
}
|
13 |
],
|
|
|
14 |
"require": {
|
|
|
15 |
},
|
16 |
-
"
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
-
}
|
1 |
{
|
2 |
"name": "valendesigns/option-tree",
|
3 |
"description": "Theme Options UI Builder for WordPress.",
|
4 |
+
"type": "wordpress-plugin",
|
5 |
"homepage": "https://github.com/valendesigns/option-tree",
|
6 |
+
"license": "GPL-2.0-or-later",
|
7 |
"authors": [
|
8 |
{
|
9 |
"name": "Derek Herman",
|
12 |
"role": "Developer"
|
13 |
}
|
14 |
],
|
15 |
+
"prefer-stable" : true,
|
16 |
"require": {
|
17 |
+
"php": ">=5.3"
|
18 |
},
|
19 |
+
"require-dev": {
|
20 |
+
"brainmaestro/composer-git-hooks": "^2.6.0",
|
21 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
|
22 |
+
"phpcompatibility/phpcompatibility-wp": "*",
|
23 |
+
"php-coveralls/php-coveralls": "^2.1",
|
24 |
+
"slowprog/composer-copy-file": "0.2.1",
|
25 |
+
"wp-coding-standards/wpcs": "*",
|
26 |
+
"xwp/wp-dev-lib": "^1.1.0"
|
27 |
+
},
|
28 |
+
"scripts": {
|
29 |
+
"phpcs": [
|
30 |
+
"./vendor/bin/phpcs ${1:.} --standard=.phpcs.ruleset.xml"
|
31 |
+
],
|
32 |
+
"phpcbf": [
|
33 |
+
"./vendor/bin/phpcbf ${1:.} --standard=.phpcs.ruleset.xml"
|
34 |
+
],
|
35 |
+
"phpunit": [
|
36 |
+
"./bin/phpunit.sh xdebug_off"
|
37 |
+
],
|
38 |
+
"phpunit-coverage": [
|
39 |
+
"./bin/phpunit.sh xdebug_on"
|
40 |
+
],
|
41 |
+
"post-install-cmd": [
|
42 |
+
"./bin/install-tests.sh",
|
43 |
+
"./vendor/bin/cghooks add --no-lock",
|
44 |
+
"SlowProg\\CopyFile\\ScriptHandler::copy"
|
45 |
+
],
|
46 |
+
"post-update-cmd": [
|
47 |
+
"./bin/install-tests.sh",
|
48 |
+
"./vendor/bin/cghooks update",
|
49 |
+
"SlowProg\\CopyFile\\ScriptHandler::copy"
|
50 |
+
],
|
51 |
+
"readme": [
|
52 |
+
"./vendor/xwp/wp-dev-lib/scripts/generate-markdown-readme"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
"extra": {
|
56 |
+
"copy-file": {
|
57 |
+
"tests/autoload.php": "tests/wp-tests/phpunit/wp-tests-config.php"
|
58 |
+
},
|
59 |
+
"hooks": {
|
60 |
+
"pre-commit": "./vendor/xwp/wp-dev-lib/scripts/pre-commit"
|
61 |
+
}
|
62 |
}
|
63 |
+
}
|
includes/class-ot-cleanup.php
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Cleanup.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Cleanup' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Cleanup class.
|
16 |
+
*
|
17 |
+
* This class loads all the OptionTree Cleanup methods and helpers.
|
18 |
+
*/
|
19 |
+
class OT_Cleanup {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class constructor.
|
23 |
+
*
|
24 |
+
* This method adds other methods of the class to specific hooks within WordPress.
|
25 |
+
*
|
26 |
+
* @uses add_action()
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
* @since 2.4.6
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
if ( ! is_admin() ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
// Load styles.
|
37 |
+
add_action( 'admin_head', array( $this, 'styles' ), 1 );
|
38 |
+
|
39 |
+
// Maybe Clean up OptionTree.
|
40 |
+
add_action( 'admin_menu', array( $this, 'maybe_cleanup' ), 100 );
|
41 |
+
|
42 |
+
// Increase timeout if allowed.
|
43 |
+
add_action( 'ot_pre_consolidate_posts', array( $this, 'increase_timeout' ) );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Adds the cleanup styles to the admin head
|
48 |
+
*
|
49 |
+
* @access public
|
50 |
+
* @since 2.5.0
|
51 |
+
*/
|
52 |
+
public function styles() {
|
53 |
+
echo '<style>#toplevel_page_ot-cleanup{display:none;}</style>';
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Check if OptionTree needs to be cleaned up from a previous install.
|
58 |
+
*
|
59 |
+
* @access public
|
60 |
+
* @since 2.4.6
|
61 |
+
*/
|
62 |
+
public function maybe_cleanup() {
|
63 |
+
global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table;
|
64 |
+
|
65 |
+
$table_name = $wpdb->prefix . 'option_tree';
|
66 |
+
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore
|
67 |
+
$ot_maybe_cleanup_posts = count( $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree' LIMIT 2" ) ) > 1; // phpcs:ignore
|
68 |
+
$ot_maybe_cleanup_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) == $table_name; // phpcs:ignore
|
69 |
+
|
70 |
+
if ( ! $ot_maybe_cleanup_posts && ! $ot_maybe_cleanup_table && 'ot-cleanup' === $page ) {
|
71 |
+
wp_safe_redirect( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) );
|
72 |
+
exit;
|
73 |
+
}
|
74 |
+
|
75 |
+
if ( $ot_maybe_cleanup_posts || $ot_maybe_cleanup_table ) {
|
76 |
+
|
77 |
+
if ( 'ot-cleanup' !== $page ) {
|
78 |
+
add_action( 'admin_notices', array( $this, 'cleanup_notice' ) );
|
79 |
+
}
|
80 |
+
|
81 |
+
$theme_check_bs = 'add_menu_' . 'page'; // phpcs:ignore
|
82 |
+
|
83 |
+
$theme_check_bs( apply_filters( 'ot_cleanup_page_title', __( 'OptionTree Cleanup', 'option-tree' ) ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ), 'edit_theme_options', 'ot-cleanup', array( $this, 'options_page' ) );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Adds an admin nag.
|
89 |
+
*
|
90 |
+
* @access public
|
91 |
+
* @since 2.4.6
|
92 |
+
*/
|
93 |
+
public function cleanup_notice() {
|
94 |
+
|
95 |
+
if ( 'appearance_page_ot-cleanup' !== get_current_screen()->id ) {
|
96 |
+
$link = sprintf( '<a href="%s">%s</a>', admin_url( 'themes.php?page=ot-cleanup' ), apply_filters( 'ot_cleanup_menu_title', esc_html__( 'OptionTree Cleanup', 'option-tree' ) ) );
|
97 |
+
|
98 |
+
/* translators: %s: internal admin page URL */
|
99 |
+
echo '<div class="update-nag">' . sprintf( esc_html__( 'OptionTree has outdated data that should be removed. Please go to %s for more information.', 'option-tree' ), $link ) . '</div>'; // phpcs:ignore
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Adds a Tools sub page to clean up the database with.
|
105 |
+
*
|
106 |
+
* @access public
|
107 |
+
* @since 2.4.6
|
108 |
+
*/
|
109 |
+
public function options_page() {
|
110 |
+
global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table;
|
111 |
+
|
112 |
+
// Option ID.
|
113 |
+
$option_id = 'ot_media_post_ID';
|
114 |
+
|
115 |
+
// Get the media post ID.
|
116 |
+
$post_ID = get_option( $option_id, false );
|
117 |
+
|
118 |
+
// Zero loop count.
|
119 |
+
$count = 0;
|
120 |
+
|
121 |
+
// Check for safe mode.
|
122 |
+
$safe_mode = ini_get( 'safe_mode' ); // phpcs:ignore
|
123 |
+
|
124 |
+
echo '<div class="wrap">';
|
125 |
+
|
126 |
+
echo '<h2>' . apply_filters( 'ot_cleanup_page_title', esc_html__( 'OptionTree Cleanup', 'option-tree' ) ) . '</h2>'; // phpcs:ignore
|
127 |
+
|
128 |
+
if ( $ot_maybe_cleanup_posts ) {
|
129 |
+
|
130 |
+
$posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree'" ); // phpcs:ignore
|
131 |
+
|
132 |
+
echo '<h3>' . esc_html__( 'Multiple Media Posts', 'option-tree' ) . '</h3>';
|
133 |
+
|
134 |
+
/* translators: %1$s: number of media posts, %2$s: media post type, %3$s: table name */
|
135 |
+
$string = esc_html__( 'There are currently %1$s OptionTree media posts in your database. At some point in the past, a version of OptionTree added multiple %2$s media post objects cluttering up your %3$s table. There is no associated risk or harm that these posts have caused other than to add size to your overall database. Thankfully, there is a way to remove all these orphaned media posts and get your database cleaned up.', 'option-tree' );
|
136 |
+
echo '<p>' . sprintf( $string, '<code>' . number_format( count( $posts ) ) . '</code>', '<tt>option-tree</tt>', '<tt>' . $wpdb->posts . '</tt>' ) . '</p>'; // phpcs:ignore
|
137 |
+
|
138 |
+
/* translators: %s: number of media posts being deleted */
|
139 |
+
echo '<p>' . sprintf( esc_html__( 'By clicking the button below, OptionTree will delete %s records and consolidate them into one single OptionTree media post for uploading attachments to. Additionally, the attachments will have their parent ID updated to the correct media post.', 'option-tree' ), '<code>' . number_format( count( $posts ) - 1 ) . '</code>' ) . '</p>';
|
140 |
+
|
141 |
+
echo '<p><strong>' . esc_html__( 'This could take a while to fully process depending on how many records you have in your database, so please be patient and wait for the script to finish.', 'option-tree' ) . '</strong></p>';
|
142 |
+
|
143 |
+
/* translators: %1$s: the word Note wrapped in a strong attribute, %2$s: number of posts being deleted */
|
144 |
+
$string = __( '%1$s: Your server is running in safe mode. Which means this page will automatically reload after deleting %2$s posts, you can filter this number using %3$s if your server is having trouble processing that many at one time.', 'option-tree' );
|
145 |
+
echo $safe_mode ? '<p>' . sprintf( $string, '<strong>' . esc_html__( 'Note', 'option-tree' ) . '</strong>:', apply_filters( 'ot_consolidate_posts_reload', 500 ), '<tt>ot_consolidate_posts_reload</tt>' ) . '</p>' : ''; // phpcs:ignore
|
146 |
+
|
147 |
+
echo '<p><a class="button button-primary" href="' . wp_nonce_url( admin_url( 'themes.php?page=ot-cleanup' ), 'consolidate-posts' ) . '">' . esc_html__( 'Consolidate Posts', 'option-tree' ) . '</a></p>'; // phpcs:ignore
|
148 |
+
|
149 |
+
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'consolidate-posts' ) ) { // phpcs:ignore
|
150 |
+
|
151 |
+
if ( false === $post_ID || empty( $post_ID ) ) {
|
152 |
+
$post_ID = isset( $posts[0]->ID ) ? $posts[0]->ID : null;
|
153 |
+
|
154 |
+
// Add to the DB.
|
155 |
+
if ( null !== $post_ID ) {
|
156 |
+
update_option( $option_id, $post_ID );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
// Do pre consolidation action to increase timeout.
|
161 |
+
do_action( 'ot_pre_consolidate_posts' );
|
162 |
+
|
163 |
+
// Loop over posts.
|
164 |
+
foreach ( $posts as $post ) {
|
165 |
+
|
166 |
+
// Don't destroy the correct post.
|
167 |
+
if ( $post_ID === $post->ID ) {
|
168 |
+
continue;
|
169 |
+
}
|
170 |
+
|
171 |
+
// Update count.
|
172 |
+
$count++;
|
173 |
+
|
174 |
+
// Reload script in safe mode.
|
175 |
+
if ( $safe_mode && $count > absint( apply_filters( 'ot_consolidate_posts_reload', 500 ) ) ) {
|
176 |
+
echo '<br />' . esc_html__( 'Reloading...', 'option-tree' );
|
177 |
+
echo '
|
178 |
+
<script>
|
179 |
+
setTimeout( ot_script_reload, 3000 )
|
180 |
+
function ot_script_reload() {
|
181 |
+
window.location = "' . esc_url_raw( self_admin_url( 'themes.php?page=ot-cleanup&_wpnonce=' . wp_create_nonce( 'consolidate-posts' ) ) ) . '"
|
182 |
+
}
|
183 |
+
</script>';
|
184 |
+
break;
|
185 |
+
}
|
186 |
+
|
187 |
+
// Get the attachments.
|
188 |
+
$attachments = get_children( 'post_type=attachment&post_parent=' . $post->ID );
|
189 |
+
|
190 |
+
// Update the attachments parent ID.
|
191 |
+
if ( ! empty( $attachments ) ) {
|
192 |
+
|
193 |
+
/* translators: %1$s: the post type, %2$s: the post ID */
|
194 |
+
$string = esc_html__( 'Updating Attachments parent ID for %1$s post %2$s.', 'option-tree' );
|
195 |
+
echo sprintf( $string . '<br />', '<tt>option-tree</tt>', '<tt>#' . $post->ID . '</tt>' ); // phpcs:ignore
|
196 |
+
|
197 |
+
foreach ( $attachments as $attachment_id => $attachment ) {
|
198 |
+
wp_update_post(
|
199 |
+
array(
|
200 |
+
'ID' => $attachment_id,
|
201 |
+
'post_parent' => $post_ID,
|
202 |
+
)
|
203 |
+
);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/* translators: %1$s: the post type, %2$s: the post ID */
|
208 |
+
$string = esc_html__( 'Deleting %1$s post %2$s.', 'option-tree' );
|
209 |
+
|
210 |
+
// Delete post.
|
211 |
+
echo sprintf( $string . '<br />', '<tt>option-tree</tt>', '<tt>#' . $post->ID . '</tt>' ); // phpcs:ignore
|
212 |
+
wp_delete_post( $post->ID, true );
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
echo '<br />' . esc_html__( 'Clean up script has completed, the page will now reload...', 'option-tree' );
|
217 |
+
|
218 |
+
echo '
|
219 |
+
<script>
|
220 |
+
setTimeout( ot_script_reload, 3000 )
|
221 |
+
function ot_script_reload() {
|
222 |
+
window.location = "' . esc_url_raw( self_admin_url( 'themes.php?page=ot-cleanup' ) ) . '"
|
223 |
+
}
|
224 |
+
</script>';
|
225 |
+
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( $ot_maybe_cleanup_table ) {
|
230 |
+
|
231 |
+
$table_name = $wpdb->prefix . 'option_tree';
|
232 |
+
|
233 |
+
echo $ot_maybe_cleanup_posts ? '<hr />' : '';
|
234 |
+
|
235 |
+
echo '<h3>' . esc_html__( 'Outdated Table', 'option-tree' ) . '</h3>';
|
236 |
+
|
237 |
+
/* translators: %s: table name */
|
238 |
+
$string = esc_html__( 'If you have upgraded from an old 1.x version of OptionTree at some point, you have an extra %s table in your database that can be removed. It\'s not hurting anything, but does not need to be there. If you want to remove it. Click the button below.', 'option-tree' );
|
239 |
+
|
240 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
241 |
+
|
242 |
+
echo '<p><a class="button button-primary" href="' . esc_url_raw( wp_nonce_url( admin_url( 'themes.php?page=ot-cleanup' ), 'drop-table' ) ) . '">' . esc_html__( 'Drop Table', 'option-tree' ) . '</a></p>';
|
243 |
+
|
244 |
+
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'drop-table' ) ) { // phpcs:ignore
|
245 |
+
|
246 |
+
/* translators: %s: table name */
|
247 |
+
$string = esc_html__( 'Deleting the outdated and unused %s table...', 'option-tree' );
|
248 |
+
|
249 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
250 |
+
|
251 |
+
$wpdb->query( "DROP TABLE IF EXISTS $table_name" ); // phpcs:ignore
|
252 |
+
|
253 |
+
if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) != $table_name ) { // phpcs:ignore
|
254 |
+
|
255 |
+
/* translators: %s: table name */
|
256 |
+
$string = esc_html__( 'The %s table has been successfully deleted. The page will now reload...', 'option-tree' );
|
257 |
+
|
258 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
259 |
+
|
260 |
+
echo '
|
261 |
+
<script>
|
262 |
+
setTimeout( ot_script_reload, 3000 )
|
263 |
+
function ot_script_reload() {
|
264 |
+
window.location = "' . esc_url_raw( self_admin_url( 'themes.php?page=ot-cleanup' ) ) . '"
|
265 |
+
}
|
266 |
+
</script>';
|
267 |
+
|
268 |
+
} else {
|
269 |
+
|
270 |
+
/* translators: %s: table name */
|
271 |
+
$string = esc_html__( 'Something went wrong. The %s table was not deleted.', 'option-tree' );
|
272 |
+
|
273 |
+
echo '<p>' . sprintf( $string, '<tt>' . $table_name . '</tt>' ) . '</p>'; // phpcs:ignore
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
echo '</div>';
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Increase PHP timeout.
|
283 |
+
*
|
284 |
+
* This is to prevent bulk operations from timing out
|
285 |
+
*
|
286 |
+
* @access public
|
287 |
+
* @since 2.4.6
|
288 |
+
*/
|
289 |
+
public function increase_timeout() {
|
290 |
+
if ( ! ini_get( 'safe_mode' ) ) { // phpcs:ignore
|
291 |
+
@set_time_limit( 0 ); // phpcs:ignore
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
new OT_Cleanup();
|
includes/class-ot-meta-box.php
ADDED
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Meta Box.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Meta_Box' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Meta Box class.
|
16 |
+
*
|
17 |
+
* This class loads all the methods and helpers specific to build a meta box.
|
18 |
+
*/
|
19 |
+
class OT_Meta_Box {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Stores the meta box config array.
|
23 |
+
*
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
private $meta_box;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Class constructor.
|
30 |
+
*
|
31 |
+
* This method adds other methods of the class to specific hooks within WordPress.
|
32 |
+
*
|
33 |
+
* @uses add_action()
|
34 |
+
*
|
35 |
+
* @access public
|
36 |
+
* @since 1.0
|
37 |
+
*
|
38 |
+
* @param array $meta_box Meta box config array.
|
39 |
+
*/
|
40 |
+
public function __construct( $meta_box ) {
|
41 |
+
if ( ! is_admin() ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
global $ot_meta_boxes;
|
46 |
+
|
47 |
+
if ( ! isset( $ot_meta_boxes ) ) {
|
48 |
+
$ot_meta_boxes = array();
|
49 |
+
}
|
50 |
+
|
51 |
+
$ot_meta_boxes[] = $meta_box;
|
52 |
+
|
53 |
+
$this->meta_box = $meta_box;
|
54 |
+
|
55 |
+
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
56 |
+
|
57 |
+
add_action( 'save_post', array( $this, 'save_meta_box' ), 1, 2 );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Adds meta box to any post type
|
62 |
+
*
|
63 |
+
* @uses add_meta_box()
|
64 |
+
*
|
65 |
+
* @access public
|
66 |
+
* @since 1.0
|
67 |
+
*/
|
68 |
+
public function add_meta_boxes() {
|
69 |
+
global $wp_version;
|
70 |
+
|
71 |
+
$is_wp_5 = version_compare( $wp_version, '5.0', '>=' );
|
72 |
+
|
73 |
+
foreach ( (array) $this->meta_box['pages'] as $page ) {
|
74 |
+
add_meta_box( $this->meta_box['id'], $this->meta_box['title'], array( $this, 'build_meta_box' ), $page, $this->meta_box['context'], $this->meta_box['priority'], $this->meta_box['fields'] );
|
75 |
+
|
76 |
+
if ( $is_wp_5 ) {
|
77 |
+
add_filter(
|
78 |
+
'postbox_classes_' . $page . '_' . $this->meta_box['id'],
|
79 |
+
function( $classes ) {
|
80 |
+
array_push( $classes, 'ot-meta-box' );
|
81 |
+
return $classes;
|
82 |
+
}
|
83 |
+
);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Meta box view.
|
90 |
+
*
|
91 |
+
* @access public
|
92 |
+
* @since 1.0
|
93 |
+
*
|
94 |
+
* @param object $post The WP_Post object.
|
95 |
+
* @param array $fields The meta box fields.
|
96 |
+
*/
|
97 |
+
public function build_meta_box( $post, $fields ) {
|
98 |
+
unset( $fields ); // @todo Check if the loop can use this param.
|
99 |
+
|
100 |
+
echo '<div class="ot-metabox-wrapper">';
|
101 |
+
|
102 |
+
// Use nonce for verification.
|
103 |
+
echo '<input type="hidden" name="' . esc_attr( $this->meta_box['id'] ) . '_nonce" value="' . esc_attr( wp_create_nonce( $this->meta_box['id'] ) ) . '" />';
|
104 |
+
|
105 |
+
// Meta box description.
|
106 |
+
echo isset( $this->meta_box['desc'] ) && ! empty( $this->meta_box['desc'] ) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode( $this->meta_box['desc'] ) . '</div>' : ''; // phpcs:ignore
|
107 |
+
|
108 |
+
// Loop through meta box fields.
|
109 |
+
foreach ( $this->meta_box['fields'] as $field ) {
|
110 |
+
|
111 |
+
// Get current post meta data.
|
112 |
+
$field_value = get_post_meta( $post->ID, $field['id'], true );
|
113 |
+
|
114 |
+
// Set standard value.
|
115 |
+
if ( isset( $field['std'] ) ) {
|
116 |
+
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
117 |
+
}
|
118 |
+
|
119 |
+
// Build the arguments array.
|
120 |
+
$_args = array(
|
121 |
+
'type' => $field['type'],
|
122 |
+
'field_id' => $field['id'],
|
123 |
+
'field_name' => $field['id'],
|
124 |
+
'field_value' => $field_value,
|
125 |
+
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
126 |
+
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
127 |
+
'field_rows' => isset( $field['rows'] ) && ! empty( $field['rows'] ) ? $field['rows'] : 10,
|
128 |
+
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
129 |
+
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
130 |
+
'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
131 |
+
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
132 |
+
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
133 |
+
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
134 |
+
'field_choices' => isset( $field['choices'] ) ? $field['choices'] : array(),
|
135 |
+
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
136 |
+
'post_id' => $post->ID,
|
137 |
+
'meta' => true,
|
138 |
+
);
|
139 |
+
|
140 |
+
$conditions = '';
|
141 |
+
|
142 |
+
// Setup the conditions.
|
143 |
+
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
144 |
+
$conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"';
|
145 |
+
$conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : '';
|
146 |
+
}
|
147 |
+
|
148 |
+
// Only allow simple textarea due to DOM issues with wp_editor().
|
149 |
+
if ( false === apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) && 'textarea' === $_args['type'] ) {
|
150 |
+
$_args['type'] = 'textarea-simple';
|
151 |
+
}
|
152 |
+
|
153 |
+
// Build the setting CSS class.
|
154 |
+
if ( ! empty( $_args['field_class'] ) ) {
|
155 |
+
|
156 |
+
$classes = explode( ' ', $_args['field_class'] );
|
157 |
+
|
158 |
+
foreach ( $classes as $key => $value ) {
|
159 |
+
|
160 |
+
$classes[ $key ] = $value . '-wrap';
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
$class = 'format-settings ' . implode( ' ', $classes );
|
165 |
+
} else {
|
166 |
+
|
167 |
+
$class = 'format-settings';
|
168 |
+
}
|
169 |
+
|
170 |
+
// Option label.
|
171 |
+
echo '<div id="setting_' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $class ) . '"' . $conditions . '>'; // phpcs:ignore
|
172 |
+
|
173 |
+
echo '<div class="format-setting-wrap">';
|
174 |
+
|
175 |
+
// Don't show title with textblocks.
|
176 |
+
if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) {
|
177 |
+
echo '<div class="format-setting-label">';
|
178 |
+
echo '<label for="' . esc_attr( $field['id'] ) . '" class="label">' . esc_html( $field['label'] ) . '</label>';
|
179 |
+
echo '</div>';
|
180 |
+
}
|
181 |
+
|
182 |
+
// Get the option HTML.
|
183 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
184 |
+
|
185 |
+
echo '</div>';
|
186 |
+
|
187 |
+
echo '</div>';
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
echo '<div class="clear"></div>';
|
192 |
+
|
193 |
+
echo '</div>';
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Saves the meta box values
|
198 |
+
*
|
199 |
+
* @access public
|
200 |
+
* @since 1.0
|
201 |
+
*
|
202 |
+
* @param int $post_id The post ID.
|
203 |
+
* @param object $post_object The WP_Post object.
|
204 |
+
* @return int|void
|
205 |
+
*/
|
206 |
+
public function save_meta_box( $post_id, $post_object ) {
|
207 |
+
global $pagenow;
|
208 |
+
|
209 |
+
// Verify nonce.
|
210 |
+
if ( isset( $_POST[ $this->meta_box['id'] . '_nonce' ] ) && ! wp_verify_nonce( $_POST[ $this->meta_box['id'] . '_nonce' ], $this->meta_box['id'] ) ) { // phpcs:ignore
|
211 |
+
return $post_id;
|
212 |
+
}
|
213 |
+
|
214 |
+
// Store the post global for use later.
|
215 |
+
$post_global = $_POST;
|
216 |
+
|
217 |
+
// Don't save if $_POST is empty.
|
218 |
+
if ( empty( $post_global ) || ( isset( $post_global['vc_inline'] ) && true === $post_global['vc_inline'] ) ) {
|
219 |
+
return $post_id;
|
220 |
+
}
|
221 |
+
|
222 |
+
// Don't save during quick edit.
|
223 |
+
if ( 'admin-ajax.php' === $pagenow ) {
|
224 |
+
return $post_id;
|
225 |
+
}
|
226 |
+
|
227 |
+
// Don't save during autosave.
|
228 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
229 |
+
return $post_id;
|
230 |
+
}
|
231 |
+
|
232 |
+
// Don't save if viewing a revision.
|
233 |
+
if ( 'revision' === $post_object->post_type || 'revision.php' === $pagenow ) {
|
234 |
+
return $post_id;
|
235 |
+
}
|
236 |
+
|
237 |
+
// Check permissions.
|
238 |
+
if ( isset( $post_global['post_type'] ) && 'page' === $post_global['post_type'] ) {
|
239 |
+
if ( ! current_user_can( 'edit_page', $post_id ) ) {
|
240 |
+
return $post_id;
|
241 |
+
}
|
242 |
+
} else {
|
243 |
+
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
244 |
+
return $post_id;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
foreach ( $this->meta_box['fields'] as $field ) {
|
249 |
+
|
250 |
+
$old = get_post_meta( $post_id, $field['id'], true );
|
251 |
+
$new = '';
|
252 |
+
|
253 |
+
// There is data to validate.
|
254 |
+
if ( isset( $post_global[ $field['id'] ] ) ) {
|
255 |
+
|
256 |
+
// Slider and list item.
|
257 |
+
if ( in_array( $field['type'], array( 'list-item', 'slider' ), true ) ) {
|
258 |
+
|
259 |
+
// Required title setting.
|
260 |
+
$required_setting = array(
|
261 |
+
array(
|
262 |
+
'id' => 'title',
|
263 |
+
'label' => __( 'Title', 'option-tree' ),
|
264 |
+
'desc' => '',
|
265 |
+
'std' => '',
|
266 |
+
'type' => 'text',
|
267 |
+
'rows' => '',
|
268 |
+
'class' => 'option-tree-setting-title',
|
269 |
+
'post_type' => '',
|
270 |
+
'choices' => array(),
|
271 |
+
),
|
272 |
+
);
|
273 |
+
|
274 |
+
// Convert the settings to an array.
|
275 |
+
$settings = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : array();
|
276 |
+
|
277 |
+
// Settings are empty for some odd reason get the defaults.
|
278 |
+
if ( empty( $settings ) ) {
|
279 |
+
$settings = ( 'slider' === $field['type'] ) ? ot_slider_settings( $field['id'] ) : ot_list_item_settings( $field['id'] );
|
280 |
+
}
|
281 |
+
|
282 |
+
// Merge the two settings array.
|
283 |
+
$settings = array_merge( $required_setting, $settings );
|
284 |
+
|
285 |
+
foreach ( $post_global[ $field['id'] ] as $k => $setting_array ) {
|
286 |
+
|
287 |
+
foreach ( $settings as $sub_setting ) {
|
288 |
+
|
289 |
+
// Verify sub setting has a type & value.
|
290 |
+
if ( isset( $sub_setting['type'] ) && isset( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
291 |
+
|
292 |
+
$post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'] );
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
// Set up new data with validated data.
|
298 |
+
$new = $post_global[ $field['id'] ];
|
299 |
+
|
300 |
+
} elseif ( 'social-links' === $field['type'] ) {
|
301 |
+
|
302 |
+
// Convert the settings to an array.
|
303 |
+
$settings = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : array();
|
304 |
+
|
305 |
+
// Settings are empty get the defaults.
|
306 |
+
if ( empty( $settings ) ) {
|
307 |
+
$settings = ot_social_links_settings( $field['id'] );
|
308 |
+
}
|
309 |
+
|
310 |
+
foreach ( $post_global[ $field['id'] ] as $k => $setting_array ) {
|
311 |
+
|
312 |
+
foreach ( $settings as $sub_setting ) {
|
313 |
+
|
314 |
+
// Verify sub setting has a type & value.
|
315 |
+
if ( isset( $sub_setting['type'] ) && isset( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
316 |
+
$post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'] );
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
// Set up new data with validated data.
|
322 |
+
$new = $post_global[ $field['id'] ];
|
323 |
+
} else {
|
324 |
+
|
325 |
+
// Run through validation.
|
326 |
+
$new = ot_validate_setting( $post_global[ $field['id'] ], $field['type'], $field['id'] );
|
327 |
+
}
|
328 |
+
|
329 |
+
// Insert CSS.
|
330 |
+
if ( 'css' === $field['type'] ) {
|
331 |
+
|
332 |
+
if ( '' !== $new ) {
|
333 |
+
|
334 |
+
// insert CSS into dynamic.css.
|
335 |
+
ot_insert_css_with_markers( $field['id'], $new, true );
|
336 |
+
} else {
|
337 |
+
|
338 |
+
// Remove old CSS from dynamic.css.
|
339 |
+
ot_remove_old_css( $field['id'] );
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
if ( isset( $new ) && $new !== $old ) {
|
345 |
+
update_post_meta( $post_id, $field['id'], $new );
|
346 |
+
} elseif ( '' === $new && $old ) {
|
347 |
+
delete_post_meta( $post_id, $field['id'], $old );
|
348 |
+
}
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
}
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
if ( ! function_exists( 'ot_register_meta_box' ) ) {
|
357 |
+
|
358 |
+
/**
|
359 |
+
* This method instantiates the meta box class & builds the UI.
|
360 |
+
*
|
361 |
+
* @uses OT_Meta_Box()
|
362 |
+
*
|
363 |
+
* @param array $args Meta box arguments.
|
364 |
+
*
|
365 |
+
* @access public
|
366 |
+
* @since 2.0
|
367 |
+
*/
|
368 |
+
function ot_register_meta_box( $args ) {
|
369 |
+
if ( ! $args ) {
|
370 |
+
return;
|
371 |
+
}
|
372 |
+
|
373 |
+
new OT_Meta_Box( $args );
|
374 |
+
}
|
375 |
+
}
|
includes/class-ot-post-formats.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Post Formats.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Post_Formats' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Post Formats class.
|
16 |
+
*
|
17 |
+
* This class loads all the methods and helpers specific to build a the post format metaboxes.
|
18 |
+
*/
|
19 |
+
class OT_Post_Formats {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class Constructor
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @since 2.3.0
|
26 |
+
*/
|
27 |
+
public function __construct() {
|
28 |
+
$this->setup_actions();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Setup the default filters and actions.
|
33 |
+
*
|
34 |
+
* @uses add_action() To add various actions.
|
35 |
+
* @uses add_filter() To add various filters.
|
36 |
+
*
|
37 |
+
* @access private
|
38 |
+
* @since 2.3.0
|
39 |
+
*/
|
40 |
+
private function setup_actions() {
|
41 |
+
|
42 |
+
// Initialize the meta boxes.
|
43 |
+
add_action( 'admin_init', array( $this, 'meta_boxes' ), 2 );
|
44 |
+
|
45 |
+
// Setup pings for the link & quote URLs.
|
46 |
+
add_filter( 'pre_ping', array( $this, 'pre_ping_post_links' ), 10, 3 );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Builds the default Meta Boxes.
|
51 |
+
*
|
52 |
+
* @access private
|
53 |
+
* @since 2.3.0
|
54 |
+
*/
|
55 |
+
public function meta_boxes() {
|
56 |
+
|
57 |
+
// Exit if called outside of WP admin.
|
58 |
+
if ( ! is_admin() ) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Filter the post formats meta boxes.
|
64 |
+
*
|
65 |
+
* @since 2.6.0
|
66 |
+
*
|
67 |
+
* @param array $meta_boxes The meta boxes being registered.
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
+
$meta_boxes = apply_filters(
|
71 |
+
'ot_recognized_post_format_meta_boxes',
|
72 |
+
array(
|
73 |
+
ot_meta_box_post_format_gallery(),
|
74 |
+
ot_meta_box_post_format_link(),
|
75 |
+
ot_meta_box_post_format_quote(),
|
76 |
+
ot_meta_box_post_format_video(),
|
77 |
+
ot_meta_box_post_format_audio(),
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Register our meta boxes using the
|
83 |
+
* ot_register_meta_box() function.
|
84 |
+
*/
|
85 |
+
foreach ( $meta_boxes as $meta_box ) {
|
86 |
+
ot_register_meta_box( $meta_box );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Setup pings for the link & quote URLs
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @since 2.3.0
|
95 |
+
*
|
96 |
+
* @param array $post_links The URLs to ping.
|
97 |
+
* @param array $pung Pinged URLs.
|
98 |
+
* @param int $post_id Post ID.
|
99 |
+
*/
|
100 |
+
public function pre_ping_post_links( $post_links, $pung, $post_id = null ) {
|
101 |
+
|
102 |
+
$_link = get_post_meta( $post_id, '_format_link_url', true );
|
103 |
+
if ( ! empty( $_link ) && ! in_array( $_link, $pung, true ) && ! in_array( $_link, $post_links, true ) ) {
|
104 |
+
$post_links[] = $_link;
|
105 |
+
}
|
106 |
+
|
107 |
+
$_quote = get_post_meta( $post_id, '_format_quote_source_url', true );
|
108 |
+
if ( ! empty( $_quote ) && ! in_array( $_quote, $pung, true ) && ! in_array( $_quote, $post_links, true ) ) {
|
109 |
+
$post_links[] = $_quote;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Instantiate The Class.
|
117 |
+
*
|
118 |
+
* @since 1.0
|
119 |
+
*/
|
120 |
+
if ( function_exists( 'ot_register_meta_box' ) ) {
|
121 |
+
new OT_Post_Formats();
|
122 |
+
}
|
includes/class-ot-settings.php
ADDED
@@ -0,0 +1,1012 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OptionTree Settings.
|
4 |
+
*
|
5 |
+
* @package OptionTree
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'OT_Settings' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* OptionTree Settings class.
|
16 |
+
*
|
17 |
+
* This class loads all the methods and helpers specific to a Settings page.
|
18 |
+
*/
|
19 |
+
class OT_Settings {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* An array of options.
|
23 |
+
*
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
private $options;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Page hook for targeting admin page.
|
30 |
+
*
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
private $page_hook;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
*
|
38 |
+
* @param array $args An array of options.
|
39 |
+
*
|
40 |
+
* @access public
|
41 |
+
* @since 2.0
|
42 |
+
*/
|
43 |
+
public function __construct( $args ) {
|
44 |
+
|
45 |
+
$this->options = $args;
|
46 |
+
|
47 |
+
// Return early if not viewing an admin page or no options.
|
48 |
+
if ( ! is_admin() || ! is_array( $this->options ) ) {
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
// Load everything.
|
53 |
+
$this->hooks();
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Execute the WordPress Hooks
|
58 |
+
*
|
59 |
+
* @access public
|
60 |
+
* @since 2.0
|
61 |
+
*/
|
62 |
+
public function hooks() {
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Filter the `admin_menu` action hook priority.
|
66 |
+
*
|
67 |
+
* @since 2.5.0
|
68 |
+
*
|
69 |
+
* @param int $priority The priority. Default '10'.
|
70 |
+
*/
|
71 |
+
$priority = apply_filters( 'ot_admin_menu_priority', 10 );
|
72 |
+
|
73 |
+
// Add pages & menu items.
|
74 |
+
add_action( 'admin_menu', array( $this, 'add_page' ), $priority );
|
75 |
+
|
76 |
+
// Register sections.
|
77 |
+
add_action( 'admin_init', array( $this, 'add_sections' ) );
|
78 |
+
|
79 |
+
// Register settings.
|
80 |
+
add_action( 'admin_init', array( $this, 'add_settings' ) );
|
81 |
+
|
82 |
+
// Reset options.
|
83 |
+
add_action( 'admin_init', array( $this, 'reset_options' ), 10 );
|
84 |
+
|
85 |
+
// Initialize settings.
|
86 |
+
add_action( 'admin_init', array( $this, 'initialize_settings' ), 11 );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Loads each admin page
|
91 |
+
*
|
92 |
+
* @return bool
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @since 2.0
|
96 |
+
*/
|
97 |
+
public function add_page() {
|
98 |
+
|
99 |
+
// Loop through options.
|
100 |
+
foreach ( (array) $this->options as $option ) {
|
101 |
+
|
102 |
+
// Loop through pages.
|
103 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Theme Check... stop nagging me about this kind of stuff.
|
107 |
+
* The damn admin pages are required for OT to function, duh!
|
108 |
+
*/
|
109 |
+
$theme_check_bs = 'add_menu_' . 'page'; // phpcs:ignore
|
110 |
+
$theme_check_bs2 = 'add_submenu_' . 'page'; // phpcs:ignore
|
111 |
+
|
112 |
+
// Load page in WP top level menu.
|
113 |
+
if ( ! isset( $page['parent_slug'] ) || empty( $page['parent_slug'] ) ) {
|
114 |
+
$page_hook = $theme_check_bs(
|
115 |
+
$page['page_title'],
|
116 |
+
$page['menu_title'],
|
117 |
+
$page['capability'],
|
118 |
+
$page['menu_slug'],
|
119 |
+
array( $this, 'display_page' ),
|
120 |
+
$page['icon_url'],
|
121 |
+
$page['position']
|
122 |
+
);
|
123 |
+
|
124 |
+
// Load page in WP sub menu.
|
125 |
+
} else {
|
126 |
+
$page_hook = $theme_check_bs2(
|
127 |
+
$page['parent_slug'],
|
128 |
+
$page['page_title'],
|
129 |
+
$page['menu_title'],
|
130 |
+
$page['capability'],
|
131 |
+
$page['menu_slug'],
|
132 |
+
array( $this, 'display_page' )
|
133 |
+
);
|
134 |
+
}
|
135 |
+
|
136 |
+
// Only load if not a hidden page.
|
137 |
+
if ( ! isset( $page['hidden_page'] ) ) {
|
138 |
+
|
139 |
+
// Associate $page_hook with page id.
|
140 |
+
$this->page_hook[ $page['id'] ] = $page_hook;
|
141 |
+
|
142 |
+
// Add scripts.
|
143 |
+
add_action( 'admin_print_scripts-' . $page_hook, array( $this, 'scripts' ) );
|
144 |
+
|
145 |
+
// Add styles.
|
146 |
+
add_action( 'admin_print_styles-' . $page_hook, array( $this, 'styles' ) );
|
147 |
+
|
148 |
+
// Add contextual help.
|
149 |
+
add_action( 'load-' . $page_hook, array( $this, 'help' ) );
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Loads the scripts
|
159 |
+
*
|
160 |
+
* @access public
|
161 |
+
* @since 2.0
|
162 |
+
*/
|
163 |
+
public function scripts() {
|
164 |
+
ot_admin_scripts();
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Loads the styles
|
169 |
+
*
|
170 |
+
* @access public
|
171 |
+
* @since 2.0
|
172 |
+
*/
|
173 |
+
public function styles() {
|
174 |
+
ot_admin_styles();
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Loads the contextual help for each page
|
179 |
+
*
|
180 |
+
* @return bool
|
181 |
+
*
|
182 |
+
* @access public
|
183 |
+
* @since 2.0
|
184 |
+
*/
|
185 |
+
public function help() {
|
186 |
+
$screen = get_current_screen();
|
187 |
+
|
188 |
+
// Loop through options.
|
189 |
+
foreach ( (array) $this->options as $option ) {
|
190 |
+
|
191 |
+
// Loop through pages.
|
192 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
193 |
+
|
194 |
+
// Verify page.
|
195 |
+
if ( ! isset( $page['hidden_page'] ) && $screen->id === $this->page_hook[ $page['id'] ] ) {
|
196 |
+
|
197 |
+
// Set up the help tabs.
|
198 |
+
if ( ! empty( $page['contextual_help']['content'] ) ) {
|
199 |
+
foreach ( $page['contextual_help']['content'] as $contextual_help ) {
|
200 |
+
$screen->add_help_tab(
|
201 |
+
array(
|
202 |
+
'id' => esc_attr( $contextual_help['id'] ),
|
203 |
+
'title' => esc_attr( $contextual_help['title'] ),
|
204 |
+
'content' => htmlspecialchars_decode( $contextual_help['content'] ),
|
205 |
+
)
|
206 |
+
);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
// Set up the help sidebar.
|
211 |
+
if ( ! empty( $page['contextual_help']['sidebar'] ) ) {
|
212 |
+
$screen->set_help_sidebar( htmlspecialchars_decode( $page['contextual_help']['sidebar'] ) );
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return false;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Loads the content for each page
|
223 |
+
*
|
224 |
+
* @access public
|
225 |
+
* @since 2.0
|
226 |
+
*/
|
227 |
+
public function display_page() {
|
228 |
+
$screen = get_current_screen();
|
229 |
+
|
230 |
+
// Loop through settings.
|
231 |
+
foreach ( (array) $this->options as $option ) {
|
232 |
+
|
233 |
+
// Loop through pages.
|
234 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
235 |
+
|
236 |
+
// Verify page.
|
237 |
+
if ( ! isset( $page['hidden_page'] ) && $screen->id === $this->page_hook[ $page['id'] ] ) {
|
238 |
+
|
239 |
+
$show_buttons = isset( $page['show_buttons'] ) && false === $page['show_buttons'] ? false : true;
|
240 |
+
|
241 |
+
// Update active layout content.
|
242 |
+
if ( isset( $_REQUEST['settings-updated'] ) && true === filter_var( wp_unslash( $_REQUEST['settings-updated'] ), FILTER_VALIDATE_BOOLEAN ) ) { // phpcs:ignore
|
243 |
+
|
244 |
+
$layouts = get_option( ot_layouts_id() );
|
245 |
+
|
246 |
+
// Has active layout.
|
247 |
+
if ( isset( $layouts['active_layout'] ) ) {
|
248 |
+
$option_tree = get_option( $option['id'], array() );
|
249 |
+
$layouts[ $layouts['active_layout'] ] = ot_encode( $option_tree );
|
250 |
+
update_option( ot_layouts_id(), $layouts );
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
echo '<div class="wrap settings-wrap" id="page-' . esc_attr( $page['id'] ) . '">';
|
255 |
+
|
256 |
+
echo '<h2>' . wp_kses_post( $page['page_title'] ) . '</h2>';
|
257 |
+
|
258 |
+
echo ot_alert_message( $page ); // phpcs:ignore
|
259 |
+
|
260 |
+
settings_errors( 'option-tree' );
|
261 |
+
|
262 |
+
// Header.
|
263 |
+
echo '<div id="option-tree-header-wrap">';
|
264 |
+
|
265 |
+
echo '<ul id="option-tree-header">';
|
266 |
+
|
267 |
+
$link = '<a href="https://wordpress.org/plugins/option-tree/" target="_blank">' . esc_html__( 'OptionTree', 'option-tree' ) . '</a>';
|
268 |
+
echo '<li id="option-tree-logo">' . wp_kses_post( apply_filters( 'ot_header_logo_link', $link, $page['id'] ) ) . '</li>';
|
269 |
+
|
270 |
+
echo '<li id="option-tree-version"><span>' . esc_html( apply_filters( 'ot_header_version_text', 'OptionTree ' . OT_VERSION, $page['id'] ) ) . '</span></li>';
|
271 |
+
|
272 |
+
// Add additional theme specific links here.
|
273 |
+
do_action( 'ot_header_list', $page['id'] );
|
274 |
+
|
275 |
+
echo '</ul>';
|
276 |
+
|
277 |
+
// Layouts form.
|
278 |
+
if ( 'ot_theme_options' === $page['id'] && true === OT_SHOW_NEW_LAYOUT ) {
|
279 |
+
ot_theme_options_layouts_form();
|
280 |
+
}
|
281 |
+
|
282 |
+
echo '</div>';
|
283 |
+
|
284 |
+
// Remove forms on the custom settings pages.
|
285 |
+
if ( $show_buttons ) {
|
286 |
+
|
287 |
+
echo '<form action="options.php" method="post" id="option-tree-settings-api">';
|
288 |
+
|
289 |
+
settings_fields( $option['id'] );
|
290 |
+
} else {
|
291 |
+
|
292 |
+
echo '<div id="option-tree-settings-api">';
|
293 |
+
}
|
294 |
+
|
295 |
+
// Sub Header.
|
296 |
+
echo '<div id="option-tree-sub-header">';
|
297 |
+
|
298 |
+
if ( $show_buttons ) {
|
299 |
+
echo '<button class="option-tree-ui-button button button-primary right">' . esc_html( $page['button_text'] ) . '</button>';
|
300 |
+
}
|
301 |
+
|
302 |
+
echo '</div>';
|
303 |
+
|
304 |
+
// Navigation.
|
305 |
+
echo '<div class="ui-tabs">';
|
306 |
+
|
307 |
+
// Check for sections.
|
308 |
+
if ( isset( $page['sections'] ) && 0 < count( $page['sections'] ) ) {
|
309 |
+
|
310 |
+
echo '<ul class="ui-tabs-nav">';
|
311 |
+
|
312 |
+
// Loop through page sections.
|
313 |
+
foreach ( (array) $page['sections'] as $section ) {
|
314 |
+
echo '<li id="tab_' . esc_attr( $section['id'] ) . '"><a href="#section_' . esc_attr( $section['id'] ) . '">' . wp_kses_post( $section['title'] ) . '</a></li>';
|
315 |
+
}
|
316 |
+
|
317 |
+
echo '</ul>';
|
318 |
+
}
|
319 |
+
|
320 |
+
// Sections.
|
321 |
+
echo '<div id="poststuff" class="metabox-holder">';
|
322 |
+
|
323 |
+
echo '<div id="post-body">';
|
324 |
+
|
325 |
+
echo '<div id="post-body-content">';
|
326 |
+
|
327 |
+
$this->do_settings_sections( isset( $_GET['page'] ) ? $_GET['page'] : '' ); // phpcs:ignore
|
328 |
+
|
329 |
+
echo '</div>';
|
330 |
+
|
331 |
+
echo '</div>';
|
332 |
+
|
333 |
+
echo '</div>';
|
334 |
+
|
335 |
+
echo '<div class="clear"></div>';
|
336 |
+
|
337 |
+
echo '</div>';
|
338 |
+
|
339 |
+
// Buttons.
|
340 |
+
if ( $show_buttons ) {
|
341 |
+
|
342 |
+
echo '<div class="option-tree-ui-buttons">';
|
343 |
+
|
344 |
+
echo '<button class="option-tree-ui-button button button-primary right">' . esc_html( $page['button_text'] ) . '</button>';
|
345 |
+
|
346 |
+
echo '</div>';
|
347 |
+
}
|
348 |
+
|
349 |
+
echo $show_buttons ? '</form>' : '</div>';
|
350 |
+
|
351 |
+
// Reset button.
|
352 |
+
if ( $show_buttons ) {
|
353 |
+
|
354 |
+
echo '<form method="post" action="' . esc_url_raw( str_replace( '&settings-updated=true', '', $_SERVER['REQUEST_URI'] ) ) . '">'; // phpcs:ignore
|
355 |
+
|
356 |
+
// Form nonce.
|
357 |
+
wp_nonce_field( 'option_tree_reset_form', 'option_tree_reset_nonce' );
|
358 |
+
|
359 |
+
echo '<input type="hidden" name="action" value="reset" />';
|
360 |
+
|
361 |
+
echo '<button type="submit" class="option-tree-ui-button button button-secondary left reset-settings" title="' . esc_html__( 'Reset Options', 'option-tree' ) . '">' . esc_html__( 'Reset Options', 'option-tree' ) . '</button>';
|
362 |
+
|
363 |
+
echo '</form>';
|
364 |
+
}
|
365 |
+
|
366 |
+
echo '</div>';
|
367 |
+
}
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
return false;
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Adds sections to the page
|
376 |
+
*
|
377 |
+
* @return bool
|
378 |
+
*
|
379 |
+
* @access public
|
380 |
+
* @since 2.0
|
381 |
+
*/
|
382 |
+
public function add_sections() {
|
383 |
+
|
384 |
+
// Loop through options.
|
385 |
+
foreach ( (array) $this->options as $option ) {
|
386 |
+
|
387 |
+
// Loop through pages.
|
388 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
389 |
+
|
390 |
+
// Loop through page sections.
|
391 |
+
foreach ( (array) $this->get_sections( $page ) as $section ) {
|
392 |
+
|
393 |
+
// Add each section.
|
394 |
+
add_settings_section(
|
395 |
+
$section['id'],
|
396 |
+
$section['title'],
|
397 |
+
array( $this, 'display_section' ),
|
398 |
+
$page['menu_slug']
|
399 |
+
);
|
400 |
+
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
|
405 |
+
return false;
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Callback for add_settings_section()
|
410 |
+
*
|
411 |
+
* @access public
|
412 |
+
* @since 2.0
|
413 |
+
*/
|
414 |
+
public function display_section() {
|
415 |
+
/* currently pointless */
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Add settings the the page
|
420 |
+
*
|
421 |
+
* @return bool
|
422 |
+
*
|
423 |
+
* @access public
|
424 |
+
* @since 2.0
|
425 |
+
*/
|
426 |
+
public function add_settings() {
|
427 |
+
|
428 |
+
// Loop through options.
|
429 |
+
foreach ( (array) $this->options as $option ) {
|
430 |
+
|
431 |
+
register_setting( $option['id'], $option['id'], array( $this, 'sanitize_callback' ) );
|
432 |
+
|
433 |
+
// Loop through pages.
|
434 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
435 |
+
|
436 |
+
// Loop through page settings.
|
437 |
+
foreach ( (array) $this->get_the_settings( $page ) as $setting ) {
|
438 |
+
|
439 |
+
// Skip if missing setting ID, label, or section.
|
440 |
+
if ( ! isset( $setting['id'] ) || ! isset( $setting['label'] ) || ! isset( $setting['section'] ) ) {
|
441 |
+
continue;
|
442 |
+
}
|
443 |
+
|
444 |
+
// Add get_option param to the array.
|
445 |
+
$setting['get_option'] = $option['id'];
|
446 |
+
|
447 |
+
// Add each setting.
|
448 |
+
add_settings_field(
|
449 |
+
$setting['id'],
|
450 |
+
$setting['label'],
|
451 |
+
array( $this, 'display_setting' ),
|
452 |
+
$page['menu_slug'],
|
453 |
+
$setting['section'],
|
454 |
+
$setting
|
455 |
+
);
|
456 |
+
}
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
+
return false;
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Callback for add_settings_field() to build each setting by type
|
465 |
+
*
|
466 |
+
* @param array $args Setting object array.
|
467 |
+
*
|
468 |
+
* @access public
|
469 |
+
* @since 2.0
|
470 |
+
*/
|
471 |
+
public function display_setting( $args = array() ) {
|
472 |
+
extract( $args ); // phpcs:ignore
|
473 |
+
|
474 |
+
// Get current saved data.
|
475 |
+
$options = get_option( $get_option, false );
|
476 |
+
|
477 |
+
// Set field value.
|
478 |
+
$field_value = isset( $options[ $id ] ) ? $options[ $id ] : '';
|
479 |
+
|
480 |
+
// Set standard value.
|
481 |
+
if ( isset( $std ) ) {
|
482 |
+
$field_value = ot_filter_std_value( $field_value, $std );
|
483 |
+
}
|
484 |
+
|
485 |
+
// Allow the descriptions to be filtered before being displayed.
|
486 |
+
$desc = apply_filters( 'ot_filter_description', ( isset( $desc ) ? $desc : '' ), $id );
|
487 |
+
|
488 |
+
// Build the arguments array.
|
489 |
+
$_args = array(
|
490 |
+
'type' => $type,
|
491 |
+
'field_id' => $id,
|
492 |
+
'field_name' => $get_option . '[' . $id . ']',
|
493 |
+
'field_value' => $field_value,
|
494 |
+
'field_desc' => $desc,
|
495 |
+
'field_std' => isset( $std ) ? $std : '',
|
496 |
+
'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15,
|
497 |
+
'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post',
|
498 |
+
'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category',
|
499 |
+
'field_min_max_step' => isset( $min_max_step ) && ! empty( $min_max_step ) ? $min_max_step : '0,100,1',
|
500 |
+
'field_condition' => isset( $condition ) && ! empty( $condition ) ? $condition : '',
|
501 |
+
'field_operator' => isset( $operator ) && ! empty( $operator ) ? $operator : 'and',
|
502 |
+
'field_class' => isset( $class ) ? $class : '',
|
503 |
+
'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(),
|
504 |
+
'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(),
|
505 |
+
'post_id' => ot_get_media_post_ID(),
|
506 |
+
'get_option' => $get_option,
|
507 |
+
);
|
508 |
+
|
509 |
+
// Limit DB queries for Google Fonts.
|
510 |
+
if ( 'google-fonts' === $type ) {
|
511 |
+
ot_fetch_google_fonts();
|
512 |
+
ot_set_google_fonts( $id, $field_value );
|
513 |
+
}
|
514 |
+
|
515 |
+
// Get the option HTML.
|
516 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Sets the option standards if nothing yet exists.
|
521 |
+
*
|
522 |
+
* @access public
|
523 |
+
* @since 2.0
|
524 |
+
*/
|
525 |
+
public function initialize_settings() {
|
526 |
+
|
527 |
+
// Loop through options.
|
528 |
+
foreach ( (array) $this->options as $option ) {
|
529 |
+
|
530 |
+
// Skip if option is already set.
|
531 |
+
if ( isset( $option['id'] ) && get_option( $option['id'], false ) ) {
|
532 |
+
return false;
|
533 |
+
}
|
534 |
+
|
535 |
+
$defaults = array();
|
536 |
+
|
537 |
+
// Loop through pages.
|
538 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
539 |
+
|
540 |
+
// Loop through page settings.
|
541 |
+
foreach ( (array) $this->get_the_settings( $page ) as $setting ) {
|
542 |
+
|
543 |
+
if ( isset( $setting['std'] ) ) {
|
544 |
+
|
545 |
+
$defaults[ $setting['id'] ] = ot_validate_setting( $setting['std'], $setting['type'], $setting['id'] );
|
546 |
+
}
|
547 |
+
}
|
548 |
+
}
|
549 |
+
|
550 |
+
update_option( $option['id'], $defaults );
|
551 |
+
}
|
552 |
+
|
553 |
+
return false;
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* Sanitize callback for register_setting()
|
558 |
+
*
|
559 |
+
* @param mixed $input The setting input.
|
560 |
+
* @return string
|
561 |
+
*
|
562 |
+
* @access public
|
563 |
+
* @since 2.0
|
564 |
+
*/
|
565 |
+
public function sanitize_callback( $input ) {
|
566 |
+
|
567 |
+
// Store the post global for use later.
|
568 |
+
$post_global = $_POST; // phpcs:ignore
|
569 |
+
|
570 |
+
// Loop through options.
|
571 |
+
foreach ( (array) $this->options as $option ) {
|
572 |
+
|
573 |
+
// Loop through pages.
|
574 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
575 |
+
|
576 |
+
// Loop through page settings.
|
577 |
+
foreach ( (array) $this->get_the_settings( $page ) as $setting ) {
|
578 |
+
|
579 |
+
// Verify setting has a type & value.
|
580 |
+
if ( isset( $setting['type'] ) && isset( $input[ $setting['id'] ] ) ) {
|
581 |
+
|
582 |
+
// Get the defaults.
|
583 |
+
$current_settings = get_option( ot_settings_id() );
|
584 |
+
$current_options = get_option( $option['id'] );
|
585 |
+
|
586 |
+
// Validate setting.
|
587 |
+
if ( is_array( $input[ $setting['id'] ] ) && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
588 |
+
|
589 |
+
// Required title setting.
|
590 |
+
$required_setting = array(
|
591 |
+
array(
|
592 |
+
'id' => 'title',
|
593 |
+
'label' => __( 'Title', 'option-tree' ),
|
594 |
+
'desc' => '',
|
595 |
+
'std' => '',
|
596 |
+
'type' => 'text',
|
597 |
+
'rows' => '',
|
598 |
+
'class' => 'option-tree-setting-title',
|
599 |
+
'post_type' => '',
|
600 |
+
'choices' => array(),
|
601 |
+
),
|
602 |
+
);
|
603 |
+
|
604 |
+
// Convert the settings to an array.
|
605 |
+
$settings = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : array();
|
606 |
+
|
607 |
+
// Settings are empty for some odd reason get the defaults.
|
608 |
+
if ( empty( $settings ) ) {
|
609 |
+
$settings = 'slider' === $setting['type'] ? ot_slider_settings( $setting['id'] ) : ot_list_item_settings( $setting['id'] );
|
610 |
+
}
|
611 |
+
|
612 |
+
// Merge the two settings arrays.
|
613 |
+
$settings = array_merge( $required_setting, $settings );
|
614 |
+
|
615 |
+
// Create an empty WPML id array.
|
616 |
+
$wpml_ids = array();
|
617 |
+
|
618 |
+
foreach ( $input[ $setting['id'] ] as $k => $setting_array ) {
|
619 |
+
|
620 |
+
$has_value = false;
|
621 |
+
foreach ( $settings as $sub_setting ) {
|
622 |
+
|
623 |
+
// Setup the WPML ID.
|
624 |
+
$wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
|
625 |
+
|
626 |
+
// Add id to array.
|
627 |
+
$wpml_ids[] = $wpml_id;
|
628 |
+
|
629 |
+
/* verify sub setting has a type & value */
|
630 |
+
if ( isset( $sub_setting['type'] ) && isset( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
631 |
+
|
632 |
+
// Validate setting.
|
633 |
+
$input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id );
|
634 |
+
$has_value = true;
|
635 |
+
}
|
636 |
+
}
|
637 |
+
|
638 |
+
if ( ! $has_value ) {
|
639 |
+
unset( $input[ $setting['id'] ][ $k ] );
|
640 |
+
}
|
641 |
+
}
|
642 |
+
} elseif ( is_array( $input[ $setting['id'] ] ) && 'social-links' === $setting['type'] ) {
|
643 |
+
|
644 |
+
// Convert the settings to an array.
|
645 |
+
$settings = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : array();
|
646 |
+
|
647 |
+
// Settings are empty get the defaults.
|
648 |
+
if ( empty( $settings ) ) {
|
649 |
+
$settings = ot_social_links_settings( $setting['id'] );
|
650 |
+
}
|
651 |
+
|
652 |
+
// Create an empty WPML id array.
|
653 |
+
$wpml_ids = array();
|
654 |
+
|
655 |
+
foreach ( $input[ $setting['id'] ] as $k => $setting_array ) {
|
656 |
+
|
657 |
+
$has_value = false;
|
658 |
+
foreach ( $settings as $sub_setting ) {
|
659 |
+
|
660 |
+
// Setup the WPML ID.
|
661 |
+
$wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
|
662 |
+
|
663 |
+
// Add id to array.
|
664 |
+
$wpml_ids[] = $wpml_id;
|
665 |
+
|
666 |
+
// Verify sub setting has a type & value.
|
667 |
+
if ( isset( $sub_setting['type'] ) && isset( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] ) ) {
|
668 |
+
|
669 |
+
if ( 'href' === $sub_setting['id'] ) {
|
670 |
+
$sub_setting['type'] = 'url';
|
671 |
+
}
|
672 |
+
|
673 |
+
// Validate setting.
|
674 |
+
$input_safe = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id );
|
675 |
+
|
676 |
+
if ( ! empty( $input_safe ) ) {
|
677 |
+
$input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = $input_safe;
|
678 |
+
$has_value = true;
|
679 |
+
}
|
680 |
+
}
|
681 |
+
}
|
682 |
+
|
683 |
+
if ( ! $has_value ) {
|
684 |
+
unset( $input[ $setting['id'] ][ $k ] );
|
685 |
+
}
|
686 |
+
}
|
687 |
+
} else {
|
688 |
+
$input[ $setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ], $setting['type'], $setting['id'], $setting['id'] );
|
689 |
+
}
|
690 |
+
}
|
691 |
+
|
692 |
+
// Unregister WPML strings that were deleted from lists and sliders.
|
693 |
+
if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
694 |
+
|
695 |
+
if ( ! isset( $wpml_ids ) ) {
|
696 |
+
$wpml_ids = array();
|
697 |
+
}
|
698 |
+
|
699 |
+
foreach ( $current_settings['settings'] as $check_setting ) {
|
700 |
+
|
701 |
+
if ( $setting['id'] === $check_setting['id'] && ! empty( $current_options[ $setting['id'] ] ) ) {
|
702 |
+
|
703 |
+
foreach ( $current_options[ $setting['id'] ] as $key => $value ) {
|
704 |
+
|
705 |
+
foreach ( $value as $ckey => $cvalue ) {
|
706 |
+
|
707 |
+
$id = $setting['id'] . '_' . $ckey . '_' . $key;
|
708 |
+
|
709 |
+
if ( ! in_array( $id, $wpml_ids, true ) ) {
|
710 |
+
ot_wpml_unregister_string( $id );
|
711 |
+
}
|
712 |
+
}
|
713 |
+
}
|
714 |
+
}
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
+
/* unregister WPML strings that were deleted from social links */
|
719 |
+
if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && 'social-links' === $setting['type'] ) {
|
720 |
+
|
721 |
+
if ( ! isset( $wpml_ids ) ) {
|
722 |
+
$wpml_ids = array();
|
723 |
+
}
|
724 |
+
|
725 |
+
foreach ( $current_settings['settings'] as $check_setting ) {
|
726 |
+
|
727 |
+
if ( $setting['id'] === $check_setting['id'] && ! empty( $current_options[ $setting['id'] ] ) ) {
|
728 |
+
|
729 |
+
foreach ( $current_options[ $setting['id'] ] as $key => $value ) {
|
730 |
+
|
731 |
+
foreach ( $value as $ckey => $cvalue ) {
|
732 |
+
|
733 |
+
$id = $setting['id'] . '_' . $ckey . '_' . $key;
|
734 |
+
|
735 |
+
if ( ! in_array( $id, $wpml_ids, true ) ) {
|
736 |
+
ot_wpml_unregister_string( $id );
|
737 |
+
}
|
738 |
+
}
|
739 |
+
}
|
740 |
+
}
|
741 |
+
}
|
742 |
+
}
|
743 |
+
}
|
744 |
+
}
|
745 |
+
}
|
746 |
+
|
747 |
+
return $input;
|
748 |
+
}
|
749 |
+
|
750 |
+
/**
|
751 |
+
* Helper function to get the pages array for an option
|
752 |
+
*
|
753 |
+
* @param array $option Option array.
|
754 |
+
* @return mixed
|
755 |
+
*
|
756 |
+
* @access public
|
757 |
+
* @since 2.0
|
758 |
+
*/
|
759 |
+
public function get_pages( $option = array() ) {
|
760 |
+
|
761 |
+
if ( empty( $option ) ) {
|
762 |
+
return false;
|
763 |
+
}
|
764 |
+
|
765 |
+
// Check for pages.
|
766 |
+
if ( isset( $option['pages'] ) && ! empty( $option['pages'] ) ) {
|
767 |
+
|
768 |
+
// Return pages array.
|
769 |
+
return $option['pages'];
|
770 |
+
|
771 |
+
}
|
772 |
+
|
773 |
+
return false;
|
774 |
+
}
|
775 |
+
|
776 |
+
/**
|
777 |
+
* Helper function to get the sections array for a page
|
778 |
+
*
|
779 |
+
* @param array $page Page array.
|
780 |
+
* @return mixed
|
781 |
+
*
|
782 |
+
* @access public
|
783 |
+
* @since 2.0
|
784 |
+
*/
|
785 |
+
public function get_sections( $page = array() ) {
|
786 |
+
|
787 |
+
if ( empty( $page ) ) {
|
788 |
+
return false;
|
789 |
+
}
|
790 |
+
|
791 |
+
// Check for sections.
|
792 |
+
if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) {
|
793 |
+
|
794 |
+
// Return sections array.
|
795 |
+
return $page['sections'];
|
796 |
+
|
797 |
+
}
|
798 |
+
|
799 |
+
return false;
|
800 |
+
}
|
801 |
+
|
802 |
+
/**
|
803 |
+
* Helper function to get the settings array for a page
|
804 |
+
*
|
805 |
+
* @param array $page Page array.
|
806 |
+
* @return mixed
|
807 |
+
*
|
808 |
+
* @access public
|
809 |
+
* @since 2.0
|
810 |
+
*/
|
811 |
+
public function get_the_settings( $page = array() ) {
|
812 |
+
|
813 |
+
if ( empty( $page ) ) {
|
814 |
+
return false;
|
815 |
+
}
|
816 |
+
|
817 |
+
/* check for settings */
|
818 |
+
if ( isset( $page['settings'] ) && ! empty( $page['settings'] ) ) {
|
819 |
+
|
820 |
+
/* return settings array */
|
821 |
+
return $page['settings'];
|
822 |
+
|
823 |
+
}
|
824 |
+
|
825 |
+
return false;
|
826 |
+
}
|
827 |
+
|
828 |
+
/**
|
829 |
+
* Prints out all settings sections added to a particular settings page
|
830 |
+
*
|
831 |
+
* @global $wp_settings_sections Storage array of all settings sections added to admin pages.
|
832 |
+
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
|
833 |
+
*
|
834 |
+
* @param string $page The slug name of the page whos settings sections you want to output.
|
835 |
+
* @return string
|
836 |
+
*
|
837 |
+
* @access public
|
838 |
+
* @since 2.0
|
839 |
+
*/
|
840 |
+
public function do_settings_sections( $page ) {
|
841 |
+
global $wp_settings_sections, $wp_settings_fields;
|
842 |
+
|
843 |
+
if ( ! isset( $wp_settings_sections ) || ! isset( $wp_settings_sections[ $page ] ) ) {
|
844 |
+
return false;
|
845 |
+
}
|
846 |
+
|
847 |
+
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
|
848 |
+
|
849 |
+
if ( ! isset( $section['id'] ) ) {
|
850 |
+
continue;
|
851 |
+
}
|
852 |
+
|
853 |
+
$section_id = $section['id'];
|
854 |
+
|
855 |
+
echo '<div id="section_' . esc_attr( $section_id ) . '" class="postbox ui-tabs-panel">';
|
856 |
+
|
857 |
+
call_user_func( $section['callback'], $section );
|
858 |
+
|
859 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section_id ] ) ) {
|
860 |
+
continue;
|
861 |
+
}
|
862 |
+
|
863 |
+
echo '<div class="inside">';
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Hook to insert arbitrary markup before the `do_settings_fields` method.
|
867 |
+
*
|
868 |
+
* @since 2.6.0
|
869 |
+
*
|
870 |
+
* @param string $page The page slug.
|
871 |
+
* @param string $section_id The section ID.
|
872 |
+
*/
|
873 |
+
do_action( 'ot_do_settings_fields_before', $page, $section_id );
|
874 |
+
|
875 |
+
$this->do_settings_fields( $page, $section_id );
|
876 |
+
|
877 |
+
/**
|
878 |
+
* Hook to insert arbitrary markup after the `do_settings_fields` method.
|
879 |
+
*
|
880 |
+
* @since 2.6.0
|
881 |
+
*
|
882 |
+
* @param string $page The page slug.
|
883 |
+
* @param string $section_id The section ID.
|
884 |
+
*/
|
885 |
+
do_action( 'ot_do_settings_fields_after', $page, $section_id );
|
886 |
+
|
887 |
+
echo '</div>';
|
888 |
+
|
889 |
+
echo '</div>';
|
890 |
+
}
|
891 |
+
|
892 |
+
}
|
893 |
+
|
894 |
+
/**
|
895 |
+
* Print out the settings fields for a particular settings section
|
896 |
+
*
|
897 |
+
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
|
898 |
+
*
|
899 |
+
* @param string $page Slug title of the admin page who's settings fields you want to show.
|
900 |
+
* @param string $section Slug title of the settings section who's fields you want to show.
|
901 |
+
* @return string
|
902 |
+
*
|
903 |
+
* @access public
|
904 |
+
* @since 2.0
|
905 |
+
*/
|
906 |
+
public function do_settings_fields( $page, $section ) {
|
907 |
+
global $wp_settings_fields;
|
908 |
+
|
909 |
+
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
|
910 |
+
return;
|
911 |
+
}
|
912 |
+
|
913 |
+
foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
|
914 |
+
|
915 |
+
$conditions = '';
|
916 |
+
|
917 |
+
if ( isset( $field['args']['condition'] ) && ! empty( $field['args']['condition'] ) ) {
|
918 |
+
|
919 |
+
$conditions = ' data-condition="' . esc_attr( $field['args']['condition'] ) . '"';
|
920 |
+
$conditions .= isset( $field['args']['operator'] ) && in_array( $field['args']['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['args']['operator'] ) . '"' : '';
|
921 |
+
}
|
922 |
+
|
923 |
+
// Build the setting CSS class.
|
924 |
+
if ( isset( $field['args']['class'] ) && ! empty( $field['args']['class'] ) ) {
|
925 |
+
|
926 |
+
$classes = explode( ' ', $field['args']['class'] );
|
927 |
+
|
928 |
+
foreach ( $classes as $key => $value ) {
|
929 |
+
$classes[ $key ] = $value . '-wrap';
|
930 |
+
}
|
931 |
+
|
932 |
+
$class = 'format-settings ' . implode( ' ', $classes );
|
933 |
+
} else {
|
934 |
+
|
935 |
+
$class = 'format-settings';
|
936 |
+
}
|
937 |
+
|
938 |
+
echo '<div id="setting_' . esc_attr( $field['id'] ) . '" class="' . esc_attr( $class ) . '"' . $conditions . '>'; // phpcs:ignore
|
939 |
+
|
940 |
+
echo '<div class="format-setting-wrap">';
|
941 |
+
|
942 |
+
if ( 'textblock' !== $field['args']['type'] && ! empty( $field['title'] ) ) {
|
943 |
+
|
944 |
+
echo '<div class="format-setting-label">';
|
945 |
+
|
946 |
+
echo '<h3 class="label">' . wp_kses_post( $field['title'] ) . '</h3>';
|
947 |
+
|
948 |
+
echo '</div>';
|
949 |
+
}
|
950 |
+
|
951 |
+
call_user_func( $field['callback'], $field['args'] );
|
952 |
+
|
953 |
+
echo '</div>';
|
954 |
+
|
955 |
+
echo '</div>';
|
956 |
+
}
|
957 |
+
}
|
958 |
+
|
959 |
+
/**
|
960 |
+
* Resets page options before the screen is displayed
|
961 |
+
*
|
962 |
+
* @access public
|
963 |
+
* @since 2.0
|
964 |
+
*
|
965 |
+
* @return bool
|
966 |
+
*/
|
967 |
+
public function reset_options() {
|
968 |
+
|
969 |
+
// Check for reset action.
|
970 |
+
if ( isset( $_POST['option_tree_reset_nonce'] ) && wp_verify_nonce( $_POST['option_tree_reset_nonce'], 'option_tree_reset_form' ) ) { // phpcs:ignore
|
971 |
+
|
972 |
+
// Loop through options.
|
973 |
+
foreach ( (array) $this->options as $option ) {
|
974 |
+
|
975 |
+
// Loop through pages.
|
976 |
+
foreach ( (array) $this->get_pages( $option ) as $page ) {
|
977 |
+
|
978 |
+
// Verify page.
|
979 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] === $page['menu_slug'] ) {
|
980 |
+
|
981 |
+
// Reset options.
|
982 |
+
delete_option( $option['id'] );
|
983 |
+
}
|
984 |
+
}
|
985 |
+
}
|
986 |
+
}
|
987 |
+
return false;
|
988 |
+
}
|
989 |
+
}
|
990 |
+
|
991 |
+
}
|
992 |
+
|
993 |
+
if ( ! function_exists( 'ot_register_settings' ) ) {
|
994 |
+
|
995 |
+
/**
|
996 |
+
* This method instantiates the settings class & builds the UI.
|
997 |
+
*
|
998 |
+
* @uses OT_Settings()
|
999 |
+
*
|
1000 |
+
* @param array $args Array of arguments to create settings.
|
1001 |
+
*
|
1002 |
+
* @access public
|
1003 |
+
* @since 2.0
|
1004 |
+
*/
|
1005 |
+
function ot_register_settings( $args ) {
|
1006 |
+
if ( ! $args ) {
|
1007 |
+
return;
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
new OT_Settings( $args );
|
1011 |
+
}
|
1012 |
+
}
|
includes/ot-cleanup-api.php
DELETED
@@ -1,295 +0,0 @@
|
|
1 |
-
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
2 |
-
/**
|
3 |
-
* OptionTree Cleanup API
|
4 |
-
*
|
5 |
-
* This class loads all the OptionTree Cleanup methods and helpers.
|
6 |
-
*
|
7 |
-
* @package OptionTree
|
8 |
-
* @author Derek Herman <derek@valendesigns.com>
|
9 |
-
* @copyright Copyright (c) 2014, Derek Herman
|
10 |
-
*/
|
11 |
-
if ( ! class_exists( 'OT_Cleanup' ) ) {
|
12 |
-
|
13 |
-
class OT_Cleanup {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* PHP5 constructor method.
|
17 |
-
*
|
18 |
-
* This method adds other methods of the class to specific hooks within WordPress.
|
19 |
-
*
|
20 |
-
* @uses add_action()
|
21 |
-
*
|
22 |
-
* @return void
|
23 |
-
*
|
24 |
-
* @access public
|
25 |
-
* @since 2.4.6
|
26 |
-
*/
|
27 |
-
function __construct() {
|
28 |
-
if ( ! is_admin() )
|
29 |
-
return;
|
30 |
-
|
31 |
-
// Load styles
|
32 |
-
add_action( 'admin_head', array( $this, 'styles' ), 1 );
|
33 |
-
|
34 |
-
// Maybe Clean up OptionTree
|
35 |
-
add_action( 'admin_menu', array( $this, 'maybe_cleanup' ), 100 );
|
36 |
-
|
37 |
-
// Increase timeout if allowed
|
38 |
-
add_action( 'ot_pre_consolidate_posts', array( $this, 'increase_timeout' ) );
|
39 |
-
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Adds the cleanup styles to the admin head
|
44 |
-
*
|
45 |
-
* @return string
|
46 |
-
*
|
47 |
-
* @access public
|
48 |
-
* @since 2.5.0
|
49 |
-
*/
|
50 |
-
function styles() {
|
51 |
-
|
52 |
-
echo '<style>#toplevel_page_ot-cleanup{display:none;}</style>';
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Check if OptionTree needs to be cleaned up from a previous install.
|
58 |
-
*
|
59 |
-
* @return void
|
60 |
-
*
|
61 |
-
* @access public
|
62 |
-
* @since 2.4.6
|
63 |
-
*/
|
64 |
-
public function maybe_cleanup() {
|
65 |
-
global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table;
|
66 |
-
|
67 |
-
$table_name = $wpdb->prefix . 'option_tree';
|
68 |
-
$page = isset( $_GET['page'] ) ? $_GET['page'] : '';
|
69 |
-
$ot_maybe_cleanup_posts = count( $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree' LIMIT 2" ) ) > 1;
|
70 |
-
$ot_maybe_cleanup_table = $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) == $table_name;
|
71 |
-
|
72 |
-
if ( ! $ot_maybe_cleanup_posts && ! $ot_maybe_cleanup_table && $page == 'ot-cleanup' ) {
|
73 |
-
wp_redirect( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) );
|
74 |
-
exit;
|
75 |
-
}
|
76 |
-
|
77 |
-
if ( $ot_maybe_cleanup_posts || $ot_maybe_cleanup_table ) {
|
78 |
-
|
79 |
-
if ( $page != 'ot-cleanup' )
|
80 |
-
add_action( 'admin_notices', array( $this, 'cleanup_notice' ) );
|
81 |
-
|
82 |
-
$theme_check_bs = 'add_menu_' . 'page';
|
83 |
-
|
84 |
-
$theme_check_bs( apply_filters( 'ot_cleanup_page_title', __( 'OptionTree Cleanup', 'option-tree' ) ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ), 'edit_theme_options', 'ot-cleanup', array( $this, 'options_page' ) );
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Adds an admin nag.
|
92 |
-
*
|
93 |
-
* @return string
|
94 |
-
*
|
95 |
-
* @access public
|
96 |
-
* @since 2.4.6
|
97 |
-
*/
|
98 |
-
public function cleanup_notice() {
|
99 |
-
|
100 |
-
if ( get_current_screen()->id != 'appearance_page_ot-cleanup' )
|
101 |
-
echo '<div class="update-nag">' . sprintf( __( 'OptionTree has outdated data that should be removed. Please go to %s for more information.', 'option-tree' ), sprintf( '<a href="%s">%s</a>', admin_url( 'themes.php?page=ot-cleanup' ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ) ) ) . '</div>';
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Adds a Tools sub page to clean up the database with.
|
107 |
-
*
|
108 |
-
* @return string
|
109 |
-
*
|
110 |
-
* @access public
|
111 |
-
* @since 2.4.6
|
112 |
-
*/
|
113 |
-
public function options_page() {
|
114 |
-
global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table;
|
115 |
-
|
116 |
-
// Option ID
|
117 |
-
$option_id = 'ot_media_post_ID';
|
118 |
-
|
119 |
-
// Get the media post ID
|
120 |
-
$post_ID = get_option( $option_id, false );
|
121 |
-
|
122 |
-
// Zero loop count
|
123 |
-
$count = 0;
|
124 |
-
|
125 |
-
// Check for safe mode
|
126 |
-
$safe_mode = ini_get( 'safe_mode' );
|
127 |
-
|
128 |
-
echo '<div class="wrap">';
|
129 |
-
|
130 |
-
echo '<h2>' . apply_filters( 'ot_cleanup_page_title', __( 'OptionTree Cleanup', 'option-tree' ) ) . '</h2>';
|
131 |
-
|
132 |
-
if ( $ot_maybe_cleanup_posts ) {
|
133 |
-
|
134 |
-
$posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree'" );
|
135 |
-
|
136 |
-
echo '<h3>' . __( 'Multiple Media Posts', 'option-tree' ) . '</h3>';
|
137 |
-
|
138 |
-
echo '<p>' . sprintf( __( 'There are currently %s OptionTree media posts in your database. At some point in the past, a version of OptionTree added multiple %s media post objects cluttering up your %s table. There is no associated risk or harm that these posts have caused other than to add size to your overall database. Thankfully, there is a way to remove all these orphaned media posts and get your database cleaned up.', 'option-tree' ), '<code>' . number_format( count( $posts ) ) . '</code>', '<tt>option-tree</tt>', '<tt>' . $wpdb->posts . '</tt>' ) . '</p>';
|
139 |
-
|
140 |
-
echo '<p>' . sprintf( __( 'By clicking the button below, OptionTree will delete %s records and consolidate them into one single OptionTree media post for uploading attachments to. Additionally, the attachments will have their parent ID updated to the correct media post.', 'option-tree' ), '<code>' . number_format( count( $posts ) - 1 ) . '</code>' ) . '</p>';
|
141 |
-
|
142 |
-
echo '<p><strong>' . __( 'This could take a while to fully process depending on how many records you have in your database, so please be patient and wait for the script to finish.', 'option-tree' ) . '</strong></p>';
|
143 |
-
|
144 |
-
echo $safe_mode ? '<p>' . sprintf( __( '%s Your server is running in safe mode. Which means this page will automatically reload after deleting %s posts, you can filter this number using %s if your server is having trouble processing that many at one time.', 'option-tree' ), '<strong>Note</strong>:', apply_filters( 'ot_consolidate_posts_reload', 500 ), '<tt>ot_consolidate_posts_reload</tt>' ) . '</p>' : '';
|
145 |
-
|
146 |
-
echo '<p><a class="button button-primary" href="' . wp_nonce_url( admin_url( 'themes.php?page=ot-cleanup' ), 'consolidate-posts' ) . '">' . __( 'Consolidate Posts', 'option-tree' ) . '</a></p>';
|
147 |
-
|
148 |
-
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'consolidate-posts' ) ) {
|
149 |
-
|
150 |
-
if ( $post_ID === false || empty( $post_ID ) ) {
|
151 |
-
$post_ID = isset( $posts[0]->ID ) ? $posts[0]->ID : null;
|
152 |
-
|
153 |
-
// Add to the DB
|
154 |
-
if ( $post_ID !== null )
|
155 |
-
update_option( $option_id, $post_ID );
|
156 |
-
|
157 |
-
}
|
158 |
-
|
159 |
-
// Do pre consolidation action to increase timeout.
|
160 |
-
do_action( 'ot_pre_consolidate_posts' );
|
161 |
-
|
162 |
-
// Loop over posts
|
163 |
-
foreach( $posts as $post ) {
|
164 |
-
|
165 |
-
// Don't destroy the correct post.
|
166 |
-
if ( $post_ID == $post->ID )
|
167 |
-
continue;
|
168 |
-
|
169 |
-
// Update count
|
170 |
-
$count++;
|
171 |
-
|
172 |
-
// Reload script in safe mode
|
173 |
-
if ( $safe_mode && $count > apply_filters( 'ot_consolidate_posts_reload', 500 ) ) {
|
174 |
-
echo '<br />' . __( 'Reloading...', 'option-tree' );
|
175 |
-
echo '
|
176 |
-
<script>
|
177 |
-
setTimeout( ot_script_reload, 3000 )
|
178 |
-
function ot_script_reload() {
|
179 |
-
window.location = "' . self_admin_url( 'themes.php?page=ot-cleanup&_wpnonce=' . wp_create_nonce( 'consolidate-posts' ) ) . '"
|
180 |
-
}
|
181 |
-
</script>';
|
182 |
-
break;
|
183 |
-
}
|
184 |
-
|
185 |
-
// Get the attachements
|
186 |
-
$attachments = get_children( 'post_type=attachment&post_parent=' . $post->ID );
|
187 |
-
|
188 |
-
// Update the attachments parent ID
|
189 |
-
if ( ! empty( $attachments ) ) {
|
190 |
-
|
191 |
-
echo 'Updating Attachments parent ID for <tt>option-tree</tt> post <tt>#' . $post->ID . '</tt>.<br />';
|
192 |
-
|
193 |
-
foreach( $attachments as $attachment_id => $attachment ) {
|
194 |
-
wp_update_post(
|
195 |
-
array(
|
196 |
-
'ID' => $attachment_id,
|
197 |
-
'post_parent' => $post_ID
|
198 |
-
)
|
199 |
-
);
|
200 |
-
}
|
201 |
-
|
202 |
-
}
|
203 |
-
|
204 |
-
// Delete post
|
205 |
-
echo 'Deleting <tt>option-tree</tt> post <tt>#' . $post->ID . '</tt><br />';
|
206 |
-
wp_delete_post( $post->ID, true );
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
-
echo '<br />' . __( 'Clean up script has completed, the page will now reload...', 'option-tree' );
|
211 |
-
|
212 |
-
echo '
|
213 |
-
<script>
|
214 |
-
setTimeout( ot_script_reload, 3000 )
|
215 |
-
function ot_script_reload() {
|
216 |
-
window.location = "' . self_admin_url( 'themes.php?page=ot-cleanup' ) . '"
|
217 |
-
}
|
218 |
-
</script>';
|
219 |
-
|
220 |
-
}
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
if ( $ot_maybe_cleanup_table ) {
|
225 |
-
|
226 |
-
$table_name = $wpdb->prefix . 'option_tree';
|
227 |
-
|
228 |
-
echo $ot_maybe_cleanup_posts ? '<hr />' : '';
|
229 |
-
|
230 |
-
echo '<h3>' . __( 'Outdated Table', 'option-tree' ) . '</h3>';
|
231 |
-
|
232 |
-
echo '<p>' . sprintf( __( 'If you have upgraded from an old 1.x version of OptionTree at some point, you have an extra %s table in your database that can be removed. It\'s not hurting anything, but does not need to be there. If you want to remove it. Click the button below.', 'option-tree' ), '<tt>' . $table_name . '</tt>' ) . '</p>';
|
233 |
-
|
234 |
-
echo '<p><a class="button button-primary" href="' . wp_nonce_url( admin_url( 'themes.php?page=ot-cleanup' ), 'drop-table' ) . '">' . __( 'Drop Table', 'option-tree' ) . '</a></p>';
|
235 |
-
|
236 |
-
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'drop-table' ) ) {
|
237 |
-
|
238 |
-
echo '<p>' . sprintf( __( 'Deleting the outdated and unused %s table...', 'option-tree' ), '<tt>' . $table_name . '</tt>' ) . '</p>';
|
239 |
-
|
240 |
-
$wpdb->query( "DROP TABLE IF EXISTS $table_name" );
|
241 |
-
|
242 |
-
if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) != $table_name ) {
|
243 |
-
|
244 |
-
echo '<p>' . sprintf( __( 'The %s table has been successfully deleted. The page will now reload...', 'option-tree' ), '<tt>' . $table_name . '</tt>' ) . '</p>';
|
245 |
-
|
246 |
-
echo '
|
247 |
-
<script>
|
248 |
-
setTimeout( ot_script_reload, 3000 )
|
249 |
-
function ot_script_reload() {
|
250 |
-
window.location = "' . self_admin_url( 'themes.php?page=ot-cleanup' ) . '"
|
251 |
-
}
|
252 |
-
</script>';
|
253 |
-
|
254 |
-
} else {
|
255 |
-
|
256 |
-
echo '<p>' . sprintf( __( 'Something went wrong. The %s table was not deleted.', 'option-tree' ), '<tt>' . $table_name . '</tt>' ) . '</p>';
|
257 |
-
|
258 |
-
}
|
259 |
-
|
260 |
-
}
|
261 |
-
|
262 |
-
}
|
263 |
-
|
264 |
-
echo '</div>';
|
265 |
-
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Increase PHP timeout.
|
270 |
-
*
|
271 |
-
* This is to prevent bulk operations from timing out
|
272 |
-
*
|
273 |
-
* @return void
|
274 |
-
*
|
275 |
-
* @access public
|
276 |
-
* @since 2.4.6
|
277 |
-
*/
|
278 |
-
public function increase_timeout() {
|
279 |
-
|
280 |
-
if ( ! ini_get( 'safe_mode' ) ) {
|
281 |
-
|
282 |
-
@set_time_limit( 0 );
|
283 |
-
|
284 |
-
}
|
285 |
-
|
286 |
-
}
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
}
|
291 |
-
|
292 |
-
new OT_Cleanup();
|
293 |
-
|
294 |
-
/* End of file ot-cleanup-api.php */
|
295 |
-
/* Location: ./includes/ot-cleanup-api.php */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/ot-functions-admin.php
CHANGED
@@ -1,1795 +1,1642 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
* Functions used only while viewing the admin UI.
|
4 |
*
|
5 |
-
* Limit loading these function only when needed
|
6 |
* and not in the front end.
|
7 |
*
|
8 |
-
* @package
|
9 |
-
* @author Derek Herman <derek@valendesigns.com>
|
10 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
11 |
-
* @since 2.0
|
12 |
*/
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
* @uses ot_register_settings()
|
18 |
-
*
|
19 |
-
* @return void
|
20 |
-
*
|
21 |
-
* @access public
|
22 |
-
* @since 2.1
|
23 |
-
*/
|
24 |
-
if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
/* get the settings array */
|
29 |
-
$get_settings = get_option( ot_settings_id() );
|
30 |
-
|
31 |
-
/* sections array */
|
32 |
-
$sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
|
33 |
-
|
34 |
-
/* settings array */
|
35 |
-
$settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
|
36 |
-
|
37 |
-
/* contexual_help array */
|
38 |
-
$contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
|
39 |
-
|
40 |
-
/* build the Theme Options */
|
41 |
-
if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) {
|
42 |
-
|
43 |
-
ot_register_settings( array(
|
44 |
-
array(
|
45 |
-
'id' => ot_options_id(),
|
46 |
-
'pages' => array(
|
47 |
-
array(
|
48 |
-
'id' => 'ot_theme_options',
|
49 |
-
'parent_slug' => apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ),
|
50 |
-
'page_title' => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ),
|
51 |
-
'menu_title' => apply_filters( 'ot_theme_options_menu_title', __( 'Theme Options', 'option-tree' ) ),
|
52 |
-
'capability' => $caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ),
|
53 |
-
'menu_slug' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ),
|
54 |
-
'icon_url' => apply_filters( 'ot_theme_options_icon_url', null ),
|
55 |
-
'position' => apply_filters( 'ot_theme_options_position', null ),
|
56 |
-
'updated_message' => apply_filters( 'ot_theme_options_updated_message', __( 'Theme Options updated.', 'option-tree' ) ),
|
57 |
-
'reset_message' => apply_filters( 'ot_theme_options_reset_message', __( 'Theme Options reset.', 'option-tree' ) ),
|
58 |
-
'button_text' => apply_filters( 'ot_theme_options_button_text', __( 'Save Changes', 'option-tree' ) ),
|
59 |
-
'contextual_help' => apply_filters( 'ot_theme_options_contextual_help', $contextual_help ),
|
60 |
-
'sections' => apply_filters( 'ot_theme_options_sections', $sections ),
|
61 |
-
'settings' => apply_filters( 'ot_theme_options_settings', $settings )
|
62 |
-
)
|
63 |
-
)
|
64 |
-
)
|
65 |
-
)
|
66 |
-
);
|
67 |
-
|
68 |
-
// Filters the options.php to add the minimum user capabilities.
|
69 |
-
add_filter( 'option_page_capability_' . ot_options_id(), create_function( '$caps', "return '$caps';" ), 999 );
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
|
77 |
-
/**
|
78 |
-
* Registers the Settings page
|
79 |
-
*
|
80 |
-
* @uses ot_register_settings()
|
81 |
-
*
|
82 |
-
* @return void
|
83 |
-
*
|
84 |
-
* @access public
|
85 |
-
* @since 2.1
|
86 |
-
*/
|
87 |
if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
)
|
388 |
-
)
|
389 |
-
);
|
390 |
-
|
391 |
-
}
|
392 |
-
|
393 |
}
|
394 |
|
395 |
-
/**
|
396 |
-
* Runs directly after the Theme Options are save.
|
397 |
-
*
|
398 |
-
* @return void
|
399 |
-
*
|
400 |
-
* @access public
|
401 |
-
* @since 2.0
|
402 |
-
*/
|
403 |
if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
|
404 |
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
}
|
422 |
|
|
|
|
|
|
|
|
|
423 |
}
|
424 |
|
425 |
-
/**
|
426 |
-
* Validate the options by type before saving.
|
427 |
-
*
|
428 |
-
* This function will run on only some of the option types
|
429 |
-
* as all of them don't need to be validated, just the
|
430 |
-
* ones users are going to input data into; because they
|
431 |
-
* can't be trusted.
|
432 |
-
*
|
433 |
-
* @param mixed Setting value
|
434 |
-
* @param string Setting type
|
435 |
-
* @param string Setting field ID
|
436 |
-
* @param string WPML field ID
|
437 |
-
* @return mixed
|
438 |
-
*
|
439 |
-
* @access public
|
440 |
-
* @since 2.0
|
441 |
-
*/
|
442 |
if ( ! function_exists( 'ot_validate_setting' ) ) {
|
443 |
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
736 |
}
|
737 |
|
738 |
-
/**
|
739 |
-
* Setup the default admin styles
|
740 |
-
*
|
741 |
-
* @return void
|
742 |
-
*
|
743 |
-
* @access public
|
744 |
-
* @since 2.0
|
745 |
-
*/
|
746 |
if ( ! function_exists( 'ot_admin_styles' ) ) {
|
747 |
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
791 |
}
|
792 |
|
793 |
-
/**
|
794 |
-
* Setup the default admin scripts
|
795 |
-
*
|
796 |
-
* @uses add_thickbox() Include Thickbox for file uploads
|
797 |
-
* @uses wp_enqueue_script() Add OptionTree scripts
|
798 |
-
* @uses wp_localize_script() Used to include arbitrary Javascript data
|
799 |
-
*
|
800 |
-
* @return void
|
801 |
-
*
|
802 |
-
* @access public
|
803 |
-
* @since 2.0
|
804 |
-
*/
|
805 |
if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
806 |
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
873 |
}
|
874 |
|
875 |
-
/**
|
876 |
-
* Returns the ID of a custom post type by post_title.
|
877 |
-
*
|
878 |
-
* @uses get_results()
|
879 |
-
*
|
880 |
-
* @return int
|
881 |
-
*
|
882 |
-
* @access public
|
883 |
-
* @since 2.0
|
884 |
-
*/
|
885 |
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
|
886 |
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
912 |
}
|
913 |
|
914 |
-
/**
|
915 |
-
* Register custom post type & create the media post used to attach images.
|
916 |
-
*
|
917 |
-
* @uses get_results()
|
918 |
-
*
|
919 |
-
* @return void
|
920 |
-
*
|
921 |
-
* @access public
|
922 |
-
* @since 2.0
|
923 |
-
*/
|
924 |
if ( ! function_exists( 'ot_create_media_post' ) ) {
|
925 |
-
|
926 |
-
function ot_create_media_post() {
|
927 |
-
|
928 |
-
$regsiter_post_type = 'register_' . 'post_type';
|
929 |
-
$regsiter_post_type( 'option-tree', array(
|
930 |
-
'labels' => array( 'name' => __( 'Option Tree', 'option-tree' ) ),
|
931 |
-
'public' => false,
|
932 |
-
'show_ui' => false,
|
933 |
-
'capability_type' => 'post',
|
934 |
-
'exclude_from_search' => true,
|
935 |
-
'hierarchical' => false,
|
936 |
-
'rewrite' => false,
|
937 |
-
'supports' => array( 'title', 'editor' ),
|
938 |
-
'can_export' => false,
|
939 |
-
'show_in_nav_menus' => false
|
940 |
-
) );
|
941 |
-
|
942 |
-
/* look for custom page */
|
943 |
-
$post_id = ot_get_media_post_ID();
|
944 |
-
|
945 |
-
/* no post exists */
|
946 |
-
if ( $post_id == 0 ) {
|
947 |
-
|
948 |
-
/* create post object */
|
949 |
-
$_p = array();
|
950 |
-
$_p['post_title'] = 'Media';
|
951 |
-
$_p['post_name'] = 'media';
|
952 |
-
$_p['post_status'] = 'private';
|
953 |
-
$_p['post_type'] = 'option-tree';
|
954 |
-
$_p['comment_status'] = 'closed';
|
955 |
-
$_p['ping_status'] = 'closed';
|
956 |
-
|
957 |
-
/* insert the post into the database */
|
958 |
-
wp_insert_post( $_p );
|
959 |
-
|
960 |
-
}
|
961 |
-
|
962 |
-
}
|
963 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
964 |
}
|
965 |
|
966 |
-
/**
|
967 |
-
* Setup default settings array.
|
968 |
-
*
|
969 |
-
* @return void
|
970 |
-
*
|
971 |
-
* @access public
|
972 |
-
* @since 2.0
|
973 |
-
*/
|
974 |
if ( ! function_exists( 'ot_default_settings' ) ) {
|
975 |
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1122 |
}
|
1123 |
|
1124 |
-
/**
|
1125 |
-
* Helper function to update the CSS option type after save.
|
1126 |
-
*
|
1127 |
-
* @return void
|
1128 |
-
*
|
1129 |
-
* @access public
|
1130 |
-
* @since 2.0
|
1131 |
-
*/
|
1132 |
if ( ! function_exists( 'ot_save_css' ) ) {
|
1133 |
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
}
|
1169 |
-
|
1170 |
-
|
1171 |
-
* Helper function to load filters for XML mime type.
|
1172 |
-
*
|
1173 |
-
* @return void
|
1174 |
-
*
|
1175 |
-
* @access public
|
1176 |
-
* @since 2.0
|
1177 |
-
*/
|
1178 |
-
if ( ! function_exists( 'ot_add_xml_to_upload_filetypes' ) ) {
|
1179 |
-
|
1180 |
-
function ot_add_xml_to_upload_filetypes() {
|
1181 |
-
|
1182 |
-
add_filter( 'upload_mimes', 'ot_upload_mimes' );
|
1183 |
-
add_filter( 'wp_mime_type_icon', 'ot_xml_mime_type_icon', 10, 2 );
|
1184 |
-
|
1185 |
-
}
|
1186 |
-
|
1187 |
-
}
|
1188 |
-
|
1189 |
-
/**
|
1190 |
-
* Filter 'upload_mimes' and add xml.
|
1191 |
-
*
|
1192 |
-
* @param array $mimes An array of valid upload mime types
|
1193 |
-
* @return array
|
1194 |
-
*
|
1195 |
-
* @access public
|
1196 |
-
* @since 2.0
|
1197 |
-
*/
|
1198 |
-
if ( ! function_exists( 'ot_upload_mimes' ) ) {
|
1199 |
-
|
1200 |
-
function ot_upload_mimes( $mimes ) {
|
1201 |
-
|
1202 |
-
$mimes['xml'] = 'application/xml';
|
1203 |
-
|
1204 |
-
return $mimes;
|
1205 |
-
|
1206 |
-
}
|
1207 |
-
|
1208 |
-
}
|
1209 |
-
|
1210 |
-
/**
|
1211 |
-
* Filters 'wp_mime_type_icon' and have xml display as a document.
|
1212 |
-
*
|
1213 |
-
* @param string $icon The mime icon
|
1214 |
-
* @param string $mime The mime type
|
1215 |
-
* @return string
|
1216 |
-
*
|
1217 |
-
* @access public
|
1218 |
-
* @since 2.0
|
1219 |
-
*/
|
1220 |
-
if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) {
|
1221 |
-
|
1222 |
-
function ot_xml_mime_type_icon( $icon, $mime ) {
|
1223 |
-
|
1224 |
-
if ( $mime == 'application/xml' || $mime == 'text/xml' )
|
1225 |
-
return wp_mime_type_icon( 'document' );
|
1226 |
-
|
1227 |
-
return $icon;
|
1228 |
-
|
1229 |
-
}
|
1230 |
-
|
1231 |
}
|
1232 |
|
1233 |
-
/**
|
1234 |
-
* Import before the screen is displayed.
|
1235 |
-
*
|
1236 |
-
* @return void
|
1237 |
-
*
|
1238 |
-
* @access public
|
1239 |
-
* @since 2.0
|
1240 |
-
*/
|
1241 |
if ( ! function_exists( 'ot_import' ) ) {
|
1242 |
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
if ( is_array( $textarea ) ) {
|
1296 |
-
update_option( ot_settings_id(), $textarea );
|
1297 |
-
$message = 'success';
|
1298 |
-
}
|
1299 |
-
|
1300 |
-
/* redirect */
|
1301 |
-
wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
1302 |
-
exit;
|
1303 |
-
|
1304 |
-
}
|
1305 |
-
|
1306 |
-
/* check and verify import theme options data nonce */
|
1307 |
-
if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) {
|
1308 |
-
|
1309 |
-
/* default message */
|
1310 |
-
$message = 'failed';
|
1311 |
-
|
1312 |
-
/* textarea value */
|
1313 |
-
$options = isset( $_POST['import_data'] ) ? unserialize( ot_decode( $_POST['import_data'] ) ) : '';
|
1314 |
-
|
1315 |
-
/* get settings array */
|
1316 |
-
$settings = get_option( ot_settings_id() );
|
1317 |
-
|
1318 |
-
/* has options */
|
1319 |
-
if ( is_array( $options ) ) {
|
1320 |
-
|
1321 |
-
/* validate options */
|
1322 |
-
if ( is_array( $settings ) ) {
|
1323 |
-
|
1324 |
-
foreach( $settings['settings'] as $setting ) {
|
1325 |
-
|
1326 |
-
if ( isset( $options[$setting['id']] ) ) {
|
1327 |
-
|
1328 |
-
$content = ot_stripslashes( $options[$setting['id']] );
|
1329 |
-
|
1330 |
-
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
1331 |
-
|
1332 |
-
}
|
1333 |
-
|
1334 |
-
}
|
1335 |
-
|
1336 |
-
}
|
1337 |
-
|
1338 |
-
/* execute the action hook and pass the theme options to it */
|
1339 |
-
do_action( 'ot_before_theme_options_save', $options );
|
1340 |
-
|
1341 |
-
/* update the option tree array */
|
1342 |
-
update_option( ot_options_id(), $options );
|
1343 |
-
|
1344 |
-
$message = 'success';
|
1345 |
-
|
1346 |
-
}
|
1347 |
-
|
1348 |
-
/* redirect accordingly */
|
1349 |
-
wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-data', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
1350 |
-
exit;
|
1351 |
-
|
1352 |
-
}
|
1353 |
-
|
1354 |
-
/* check and verify import layouts nonce */
|
1355 |
-
if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) {
|
1356 |
-
|
1357 |
-
/* default message */
|
1358 |
-
$message = 'failed';
|
1359 |
-
|
1360 |
-
/* textarea value */
|
1361 |
-
$layouts = isset( $_POST['import_layouts'] ) ? unserialize( ot_decode( $_POST['import_layouts'] ) ) : '';
|
1362 |
-
|
1363 |
-
/* get settings array */
|
1364 |
-
$settings = get_option( ot_settings_id() );
|
1365 |
-
|
1366 |
-
/* has layouts */
|
1367 |
-
if ( is_array( $layouts ) ) {
|
1368 |
-
|
1369 |
-
/* validate options */
|
1370 |
-
if ( is_array( $settings ) ) {
|
1371 |
-
|
1372 |
-
foreach( $layouts as $key => $value ) {
|
1373 |
-
|
1374 |
-
if ( $key == 'active_layout' )
|
1375 |
-
continue;
|
1376 |
-
|
1377 |
-
$options = unserialize( ot_decode( $value ) );
|
1378 |
-
|
1379 |
-
foreach( $settings['settings'] as $setting ) {
|
1380 |
-
|
1381 |
-
if ( isset( $options[$setting['id']] ) ) {
|
1382 |
-
|
1383 |
-
$content = ot_stripslashes( $options[$setting['id']] );
|
1384 |
-
|
1385 |
-
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
1386 |
-
|
1387 |
-
}
|
1388 |
-
|
1389 |
-
}
|
1390 |
-
|
1391 |
-
$layouts[$key] = ot_encode( serialize( $options ) );
|
1392 |
-
|
1393 |
-
}
|
1394 |
-
|
1395 |
-
}
|
1396 |
-
|
1397 |
-
/* update the option tree array */
|
1398 |
-
if ( isset( $layouts['active_layout'] ) ) {
|
1399 |
-
|
1400 |
-
$new_options = unserialize( ot_decode( $layouts[$layouts['active_layout']] ) );
|
1401 |
-
|
1402 |
-
/* execute the action hook and pass the theme options to it */
|
1403 |
-
do_action( 'ot_before_theme_options_save', $new_options );
|
1404 |
-
|
1405 |
-
update_option( ot_options_id(), $new_options );
|
1406 |
-
|
1407 |
-
}
|
1408 |
-
|
1409 |
-
/* update the option tree layouts array */
|
1410 |
-
update_option( ot_layouts_id(), $layouts );
|
1411 |
-
|
1412 |
-
$message = 'success';
|
1413 |
-
|
1414 |
-
}
|
1415 |
-
|
1416 |
-
/* redirect accordingly */
|
1417 |
-
wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
1418 |
-
exit;
|
1419 |
-
|
1420 |
-
}
|
1421 |
-
|
1422 |
-
return false;
|
1423 |
-
|
1424 |
-
}
|
1425 |
-
|
1426 |
-
}
|
1427 |
-
|
1428 |
-
/**
|
1429 |
-
* Export before the screen is displayed.
|
1430 |
-
*
|
1431 |
-
* @return void
|
1432 |
-
*
|
1433 |
-
* @access public
|
1434 |
-
* @since 2.0.8
|
1435 |
-
*/
|
1436 |
-
if ( ! function_exists( 'ot_export' ) ) {
|
1437 |
-
|
1438 |
-
function ot_export() {
|
1439 |
-
|
1440 |
-
/* check and verify export settings file nonce */
|
1441 |
-
if ( isset( $_POST['export_settings_file_nonce'] ) && wp_verify_nonce( $_POST['export_settings_file_nonce'], 'export_settings_file_form' ) ) {
|
1442 |
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1449 |
}
|
1450 |
|
1451 |
-
|
1452 |
-
* Reusable XMl import helper function.
|
1453 |
-
*
|
1454 |
-
* @param string $file The path to the file.
|
1455 |
-
* @return mixed False or an array of settings.
|
1456 |
-
*
|
1457 |
-
* @access public
|
1458 |
-
* @since 2.0.8
|
1459 |
-
*/
|
1460 |
-
if ( ! function_exists( 'ot_import_xml' ) ) {
|
1461 |
-
|
1462 |
-
function ot_import_xml( $file ) {
|
1463 |
-
|
1464 |
-
$get_data = wp_remote_get( $file );
|
1465 |
-
|
1466 |
-
if ( is_wp_error( $get_data ) )
|
1467 |
-
return false;
|
1468 |
-
|
1469 |
-
$rawdata = isset( $get_data['body'] ) ? $get_data['body'] : false;
|
1470 |
-
|
1471 |
-
if ( $rawdata ) {
|
1472 |
-
|
1473 |
-
$section_count = 0;
|
1474 |
-
$settings_count = 0;
|
1475 |
-
|
1476 |
-
$section = '';
|
1477 |
-
|
1478 |
-
$settings = array();
|
1479 |
-
$xml = new SimpleXMLElement( $rawdata );
|
1480 |
-
|
1481 |
-
foreach ( $xml->row as $value ) {
|
1482 |
-
|
1483 |
-
/* heading is a section now */
|
1484 |
-
if ( $value->item_type == 'heading' ) {
|
1485 |
-
|
1486 |
-
/* add section to the sections array */
|
1487 |
-
$settings['sections'][$section_count]['id'] = (string) $value->item_id;
|
1488 |
-
$settings['sections'][$section_count]['title'] = (string) $value->item_title;
|
1489 |
-
|
1490 |
-
/* save the last section id to use in creating settings */
|
1491 |
-
$section = (string) $value->item_id;
|
1492 |
-
|
1493 |
-
/* increment the section count */
|
1494 |
-
$section_count++;
|
1495 |
-
|
1496 |
-
} else {
|
1497 |
-
|
1498 |
-
/* add setting to the settings array */
|
1499 |
-
$settings['settings'][$settings_count]['id'] = (string) $value->item_id;
|
1500 |
-
$settings['settings'][$settings_count]['label'] = (string) $value->item_title;
|
1501 |
-
$settings['settings'][$settings_count]['desc'] = (string) $value->item_desc;
|
1502 |
-
$settings['settings'][$settings_count]['section'] = $section;
|
1503 |
-
$settings['settings'][$settings_count]['type'] = ot_map_old_option_types( (string) $value->item_type );
|
1504 |
-
$settings['settings'][$settings_count]['std'] = '';
|
1505 |
-
$settings['settings'][$settings_count]['class'] = '';
|
1506 |
-
|
1507 |
-
/* textarea rows */
|
1508 |
-
$rows = '';
|
1509 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) {
|
1510 |
-
if ( (int) $value->item_options > 0 ) {
|
1511 |
-
$rows = (int) $value->item_options;
|
1512 |
-
} else {
|
1513 |
-
$rows = 15;
|
1514 |
-
}
|
1515 |
-
}
|
1516 |
-
$settings['settings'][$settings_count]['rows'] = $rows;
|
1517 |
-
|
1518 |
-
/* post type */
|
1519 |
-
$post_type = '';
|
1520 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ) ) ) {
|
1521 |
-
if ( '' != (string) $value->item_options ) {
|
1522 |
-
$post_type = (string) $value->item_options;
|
1523 |
-
} else {
|
1524 |
-
$post_type = 'post';
|
1525 |
-
}
|
1526 |
-
}
|
1527 |
-
$settings['settings'][$settings_count]['post_type'] = $post_type;
|
1528 |
-
|
1529 |
-
/* choices */
|
1530 |
-
$choices = array();
|
1531 |
-
if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) {
|
1532 |
-
if ( '' != (string) $value->item_options ) {
|
1533 |
-
$choices = ot_convert_string_to_array( (string) $value->item_options );
|
1534 |
-
}
|
1535 |
-
}
|
1536 |
-
$settings['settings'][$settings_count]['choices'] = $choices;
|
1537 |
-
|
1538 |
-
$settings_count++;
|
1539 |
-
}
|
1540 |
-
|
1541 |
-
}
|
1542 |
-
|
1543 |
-
/* make sure each setting has a section just incase */
|
1544 |
-
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
1545 |
-
foreach( $settings['settings'] as $k => $setting ) {
|
1546 |
-
if ( '' == $setting['section'] ) {
|
1547 |
-
$settings['settings'][$k]['section'] = $settings['sections'][0]['id'];
|
1548 |
-
}
|
1549 |
-
}
|
1550 |
-
}
|
1551 |
-
|
1552 |
-
return $settings;
|
1553 |
-
|
1554 |
-
}
|
1555 |
-
|
1556 |
-
return false;
|
1557 |
-
}
|
1558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1559 |
}
|
1560 |
|
1561 |
-
/**
|
1562 |
-
* Export the Theme Mode theme-options.php
|
1563 |
-
*
|
1564 |
-
* @return attachment
|
1565 |
-
*
|
1566 |
-
* @access public
|
1567 |
-
* @since 2.0.8
|
1568 |
-
*/
|
1569 |
if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
1570 |
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
$
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1693 |
' . implode( ",\n", $std_array ) . '
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
$setting_std = 'array(
|
1739 |
' . implode( ",\n", $setting_std_array ) . '
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
}
|
1791 |
-
|
1792 |
-
$content.= "<?php
|
1793 |
/**
|
1794 |
* Initialize the custom theme options.
|
1795 |
*/
|
@@ -1800,4325 +1647,4413 @@ add_action( 'init', 'custom_theme_options' );
|
|
1800 |
*/
|
1801 |
function custom_theme_options() {
|
1802 |
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
);
|
1818 |
-
|
1819 |
-
/* allow settings to be filtered before saving */
|
1820 |
-
\$custom_settings = apply_filters( ot_settings_id() . '_args', \$custom_settings );
|
1821 |
-
|
1822 |
-
/* settings are not the same update the DB */
|
1823 |
-
if ( \$saved_settings !== \$custom_settings ) {
|
1824 |
-
update_option( ot_settings_id(), \$custom_settings );
|
1825 |
-
}
|
1826 |
-
|
1827 |
-
/* Lets OptionTree know the UI Builder is being overridden */
|
1828 |
-
global \$ot_has_custom_theme_options;
|
1829 |
-
\$ot_has_custom_theme_options = true;
|
1830 |
-
|
1831 |
-
}";
|
1832 |
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
|
|
1836 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1837 |
}
|
1838 |
|
1839 |
-
/**
|
1840 |
-
* Save settings array before the screen is displayed.
|
1841 |
-
*
|
1842 |
-
* @return void
|
1843 |
-
*
|
1844 |
-
* @access public
|
1845 |
-
* @since 2.0
|
1846 |
-
*/
|
1847 |
if ( ! function_exists( 'ot_save_settings' ) ) {
|
1848 |
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
}
|
1896 |
-
|
1897 |
-
}
|
1898 |
-
|
1899 |
-
$settings['sections'] = ot_stripslashes( $settings['sections'] );
|
1900 |
-
|
1901 |
-
}
|
1902 |
-
|
1903 |
-
/* validate settings by looping over array as many times as it takes */
|
1904 |
-
if ( isset( $settings['settings'] ) ) {
|
1905 |
-
|
1906 |
-
$settings['settings'] = ot_validate_settings_array( $settings['settings'] );
|
1907 |
-
|
1908 |
-
}
|
1909 |
-
|
1910 |
-
/* validate contextual_help */
|
1911 |
-
if ( isset( $settings['contextual_help']['content'] ) ) {
|
1912 |
-
|
1913 |
-
/* fix numeric keys since drag & drop will change them */
|
1914 |
-
$settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] );
|
1915 |
-
|
1916 |
-
/* loop through content */
|
1917 |
-
foreach( $settings['contextual_help']['content'] as $k => $content ) {
|
1918 |
-
|
1919 |
-
/* remove from array if missing values */
|
1920 |
-
if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' == $content['title'] && '' == $content['id'] ) ) {
|
1921 |
-
|
1922 |
-
unset( $settings['contextual_help']['content'][$k] );
|
1923 |
-
|
1924 |
-
} else {
|
1925 |
-
|
1926 |
-
/* validate label */
|
1927 |
-
if ( '' != $content['title'] ) {
|
1928 |
-
|
1929 |
-
$settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['title'] );
|
1930 |
-
|
1931 |
-
}
|
1932 |
-
|
1933 |
-
/* missing title set to unfiltered ID */
|
1934 |
-
if ( ! isset( $content['title'] ) || '' == $content['title'] ) {
|
1935 |
-
|
1936 |
-
$settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['id'] );
|
1937 |
-
|
1938 |
-
/* missing ID set to title */
|
1939 |
-
} else if ( ! isset( $content['id'] ) || '' == $content['id'] ) {
|
1940 |
-
|
1941 |
-
$content['id'] = wp_kses_post( $content['title'] );
|
1942 |
-
|
1943 |
-
}
|
1944 |
-
|
1945 |
-
/* sanitize ID once everything has been checked first */
|
1946 |
-
$settings['contextual_help']['content'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $content['id'] ) );
|
1947 |
-
|
1948 |
-
}
|
1949 |
-
|
1950 |
-
/* validate textarea description */
|
1951 |
-
if ( isset( $content['content'] ) ) {
|
1952 |
-
|
1953 |
-
$settings['contextual_help']['content'][$k]['content'] = wp_kses_post( $content['content'] );
|
1954 |
-
|
1955 |
-
}
|
1956 |
-
|
1957 |
-
}
|
1958 |
-
|
1959 |
-
}
|
1960 |
-
|
1961 |
-
/* validate contextual_help sidebar */
|
1962 |
-
if ( isset( $settings['contextual_help']['sidebar'] ) ) {
|
1963 |
-
|
1964 |
-
$settings['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] );
|
1965 |
-
|
1966 |
-
}
|
1967 |
-
|
1968 |
-
$settings['contextual_help'] = ot_stripslashes( $settings['contextual_help'] );
|
1969 |
-
|
1970 |
-
/* default message */
|
1971 |
-
$message = 'failed';
|
1972 |
-
|
1973 |
-
/* is array: save & show success message */
|
1974 |
-
if ( is_array( $settings ) ) {
|
1975 |
-
|
1976 |
-
/* WPML unregister ID's that have been removed */
|
1977 |
-
if ( function_exists( 'icl_unregister_string' ) ) {
|
1978 |
-
|
1979 |
-
$current = get_option( ot_settings_id() );
|
1980 |
-
$options = get_option( ot_options_id() );
|
1981 |
-
|
1982 |
-
if ( isset( $current['settings'] ) ) {
|
1983 |
-
|
1984 |
-
/* Empty ID array */
|
1985 |
-
$new_ids = array();
|
1986 |
-
|
1987 |
-
/* Build the WPML IDs array */
|
1988 |
-
foreach( $settings['settings'] as $setting ) {
|
1989 |
-
|
1990 |
-
if ( $setting['id'] ) {
|
1991 |
-
|
1992 |
-
$new_ids[] = $setting['id'];
|
1993 |
-
|
1994 |
-
}
|
1995 |
-
|
1996 |
-
}
|
1997 |
-
|
1998 |
-
/* Remove missing IDs from WPML */
|
1999 |
-
foreach( $current['settings'] as $current_setting ) {
|
2000 |
-
|
2001 |
-
if ( ! in_array( $current_setting['id'], $new_ids ) ) {
|
2002 |
-
|
2003 |
-
if ( ! empty( $options[$current_setting['id']] ) && in_array( $current_setting['type'], array( 'list-item', 'slider' ) ) ) {
|
2004 |
-
|
2005 |
-
foreach( $options[$current_setting['id']] as $key => $value ) {
|
2006 |
-
|
2007 |
-
foreach( $value as $ckey => $cvalue ) {
|
2008 |
-
|
2009 |
-
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
2010 |
-
|
2011 |
-
}
|
2012 |
-
|
2013 |
-
}
|
2014 |
-
|
2015 |
-
} else if ( ! empty( $options[$current_setting['id']] ) && $current_setting['type'] == 'social-icons' ) {
|
2016 |
-
|
2017 |
-
foreach( $options[$current_setting['id']] as $key => $value ) {
|
2018 |
-
|
2019 |
-
foreach( $value as $ckey => $cvalue ) {
|
2020 |
-
|
2021 |
-
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
2022 |
-
|
2023 |
-
}
|
2024 |
-
|
2025 |
-
}
|
2026 |
-
|
2027 |
-
} else {
|
2028 |
-
|
2029 |
-
ot_wpml_unregister_string( $current_setting['id'] );
|
2030 |
-
|
2031 |
-
}
|
2032 |
-
|
2033 |
-
}
|
2034 |
-
|
2035 |
-
}
|
2036 |
-
|
2037 |
-
}
|
2038 |
-
|
2039 |
-
}
|
2040 |
-
|
2041 |
-
update_option( ot_settings_id(), $settings );
|
2042 |
-
$message = 'success';
|
2043 |
-
|
2044 |
-
}
|
2045 |
-
|
2046 |
-
/* redirect */
|
2047 |
-
wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'save-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) );
|
2048 |
-
exit;
|
2049 |
-
|
2050 |
-
}
|
2051 |
-
|
2052 |
-
return false;
|
2053 |
-
|
2054 |
-
}
|
2055 |
-
|
2056 |
}
|
2057 |
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2071 |
|
2072 |
-
|
2073 |
-
|
2074 |
-
/* validate settings */
|
2075 |
-
if ( count( $settings ) > 0 ) {
|
2076 |
-
|
2077 |
-
/* fix numeric keys since drag & drop will change them */
|
2078 |
-
$settings = array_values( $settings );
|
2079 |
-
|
2080 |
-
/* loop through settings */
|
2081 |
-
foreach( $settings as $k => $setting ) {
|
2082 |
-
|
2083 |
-
|
2084 |
-
/* remove from array if missing values */
|
2085 |
-
if ( ( ! isset( $setting['label'] ) && ! isset( $setting['id'] ) ) || ( '' == $setting['label'] && '' == $setting['id'] ) ) {
|
2086 |
-
|
2087 |
-
unset( $settings[$k] );
|
2088 |
-
|
2089 |
-
} else {
|
2090 |
-
|
2091 |
-
/* validate label */
|
2092 |
-
if ( '' != $setting['label'] ) {
|
2093 |
-
|
2094 |
-
$settings[$k]['label'] = wp_kses_post( $setting['label'] );
|
2095 |
-
|
2096 |
-
}
|
2097 |
-
|
2098 |
-
/* missing label set to unfiltered ID */
|
2099 |
-
if ( ! isset( $setting['label'] ) || '' == $setting['label'] ) {
|
2100 |
-
|
2101 |
-
$settings[$k]['label'] = $setting['id'];
|
2102 |
-
|
2103 |
-
/* missing ID set to label */
|
2104 |
-
} else if ( ! isset( $setting['id'] ) || '' == $setting['id'] ) {
|
2105 |
-
|
2106 |
-
$setting['id'] = wp_kses_post( $setting['label'] );
|
2107 |
-
|
2108 |
-
}
|
2109 |
-
|
2110 |
-
/* sanitize ID once everything has been checked first */
|
2111 |
-
$settings[$k]['id'] = ot_sanitize_option_id( wp_kses_post( $setting['id'] ) );
|
2112 |
-
|
2113 |
-
}
|
2114 |
-
|
2115 |
-
/* validate description */
|
2116 |
-
if ( '' != $setting['desc'] ) {
|
2117 |
-
|
2118 |
-
$settings[$k]['desc'] = wp_kses_post( $setting['desc'] );
|
2119 |
-
|
2120 |
-
}
|
2121 |
-
|
2122 |
-
/* validate choices */
|
2123 |
-
if ( isset( $setting['choices'] ) ) {
|
2124 |
-
|
2125 |
-
/* loop through choices */
|
2126 |
-
foreach( $setting['choices'] as $ck => $choice ) {
|
2127 |
-
|
2128 |
-
/* remove from array if missing values */
|
2129 |
-
if ( ( ! isset( $choice['label'] ) && ! isset( $choice['value'] ) ) || ( '' == $choice['label'] && '' == $choice['value'] ) ) {
|
2130 |
-
|
2131 |
-
unset( $setting['choices'][$ck] );
|
2132 |
-
|
2133 |
-
} else {
|
2134 |
-
|
2135 |
-
/* missing label set to unfiltered ID */
|
2136 |
-
if ( ! isset( $choice['label'] ) || '' == $choice['label'] ) {
|
2137 |
-
|
2138 |
-
$setting['choices'][$ck]['label'] = wp_kses_post( $choice['value'] );
|
2139 |
-
|
2140 |
-
/* missing value set to label */
|
2141 |
-
} else if ( ! isset( $choice['value'] ) || '' == $choice['value'] ) {
|
2142 |
-
|
2143 |
-
$setting['choices'][$ck]['value'] = ot_sanitize_option_id( wp_kses_post( $choice['label'] ) );
|
2144 |
-
|
2145 |
-
}
|
2146 |
-
|
2147 |
-
}
|
2148 |
-
|
2149 |
-
}
|
2150 |
-
|
2151 |
-
/* update keys and push new array values */
|
2152 |
-
$settings[$k]['choices'] = array_values( $setting['choices'] );
|
2153 |
-
|
2154 |
-
}
|
2155 |
-
|
2156 |
-
/* validate sub settings */
|
2157 |
-
if ( isset( $setting['settings'] ) ) {
|
2158 |
-
|
2159 |
-
$settings[$k]['settings'] = ot_validate_settings_array( $setting['settings'] );
|
2160 |
-
|
2161 |
-
}
|
2162 |
-
|
2163 |
-
}
|
2164 |
-
|
2165 |
-
}
|
2166 |
-
|
2167 |
-
/* return array but strip those damn slashes out first!!! */
|
2168 |
-
return ot_stripslashes( $settings );
|
2169 |
-
|
2170 |
-
}
|
2171 |
|
2172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2173 |
|
2174 |
-
|
2175 |
-
|
2176 |
-
*
|
2177 |
-
* @return void
|
2178 |
-
*
|
2179 |
-
* @access public
|
2180 |
-
* @since 2.0
|
2181 |
-
*/
|
2182 |
-
if ( ! function_exists( 'ot_modify_layouts' ) ) {
|
2183 |
|
2184 |
-
|
2185 |
-
|
2186 |
-
/* check and verify modify layouts nonce */
|
2187 |
-
if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) {
|
2188 |
-
|
2189 |
-
/* previous layouts value */
|
2190 |
-
$option_tree_layouts = get_option( ot_layouts_id() );
|
2191 |
-
|
2192 |
-
/* new layouts value */
|
2193 |
-
$layouts = isset( $_POST[ot_layouts_id()] ) ? $_POST[ot_layouts_id()] : '';
|
2194 |
-
|
2195 |
-
/* rebuild layout array */
|
2196 |
-
$rebuild = array();
|
2197 |
-
|
2198 |
-
/* validate layouts */
|
2199 |
-
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
2200 |
-
|
2201 |
-
/* setup active layout */
|
2202 |
-
if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
|
2203 |
-
$rebuild['active_layout'] = $layouts['active_layout'];
|
2204 |
-
}
|
2205 |
-
|
2206 |
-
/* add new and overwrite active layout */
|
2207 |
-
if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
|
2208 |
-
$rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] );
|
2209 |
-
$rebuild[$rebuild['active_layout']] = ot_encode( serialize( get_option( ot_options_id() ) ) );
|
2210 |
-
}
|
2211 |
-
|
2212 |
-
$first_layout = '';
|
2213 |
-
|
2214 |
-
/* loop through layouts */
|
2215 |
-
foreach( $layouts as $key => $layout ) {
|
2216 |
-
|
2217 |
-
/* skip over active layout key */
|
2218 |
-
if ( $key == 'active_layout' )
|
2219 |
-
continue;
|
2220 |
-
|
2221 |
-
/* check if the key exists then set value */
|
2222 |
-
if ( isset( $option_tree_layouts[$key] ) && ! empty( $option_tree_layouts[$key] ) ) {
|
2223 |
-
$rebuild[$key] = $option_tree_layouts[$key];
|
2224 |
-
if ( '' == $first_layout ) {
|
2225 |
-
$first_layout = $key;
|
2226 |
-
}
|
2227 |
-
}
|
2228 |
-
|
2229 |
-
}
|
2230 |
-
|
2231 |
-
if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[$rebuild['active_layout']] ) && ! empty( $first_layout ) ) {
|
2232 |
-
$rebuild['active_layout'] = $first_layout;
|
2233 |
-
}
|
2234 |
-
|
2235 |
-
}
|
2236 |
-
|
2237 |
-
/* default message */
|
2238 |
-
$message = 'failed';
|
2239 |
-
|
2240 |
-
/* is array: save & show success message */
|
2241 |
-
if ( count( $rebuild ) > 1 ) {
|
2242 |
-
|
2243 |
-
/* rebuild the theme options */
|
2244 |
-
$rebuild_option_tree = unserialize( ot_decode( $rebuild[$rebuild['active_layout']] ) );
|
2245 |
-
if ( is_array( $rebuild_option_tree ) ) {
|
2246 |
-
|
2247 |
-
/* execute the action hook and pass the theme options to it */
|
2248 |
-
do_action( 'ot_before_theme_options_save', $rebuild_option_tree );
|
2249 |
-
|
2250 |
-
update_option( ot_options_id(), $rebuild_option_tree );
|
2251 |
-
|
2252 |
-
}
|
2253 |
-
|
2254 |
-
/* rebuild the layouts */
|
2255 |
-
update_option( ot_layouts_id(), $rebuild );
|
2256 |
-
|
2257 |
-
/* change message */
|
2258 |
-
$message = 'success';
|
2259 |
-
|
2260 |
-
} else if ( count( $rebuild ) <= 1 ) {
|
2261 |
-
|
2262 |
-
/* delete layouts option */
|
2263 |
-
delete_option( ot_layouts_id() );
|
2264 |
-
|
2265 |
-
/* change message */
|
2266 |
-
$message = 'deleted';
|
2267 |
-
|
2268 |
-
}
|
2269 |
-
|
2270 |
-
/* redirect */
|
2271 |
-
if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) {
|
2272 |
-
$query_args = esc_url_raw( add_query_arg( array( 'settings-updated' => 'layout' ), remove_query_arg( array( 'action', 'message' ), $_POST['_wp_http_referer'] ) ) );
|
2273 |
-
} else {
|
2274 |
-
$query_args = esc_url_raw( add_query_arg( array( 'action' => 'save-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) );
|
2275 |
-
}
|
2276 |
-
wp_redirect( $query_args );
|
2277 |
-
exit;
|
2278 |
-
|
2279 |
-
}
|
2280 |
-
|
2281 |
-
return false;
|
2282 |
-
|
2283 |
-
}
|
2284 |
-
|
2285 |
-
}
|
2286 |
|
2287 |
-
|
2288 |
-
|
2289 |
-
*
|
2290 |
-
* @param array Page array
|
2291 |
-
* @return mixed
|
2292 |
-
*
|
2293 |
-
* @access public
|
2294 |
-
* @since 2.0
|
2295 |
-
*/
|
2296 |
-
if ( ! function_exists( 'ot_alert_message' ) ) {
|
2297 |
|
2298 |
-
|
2299 |
-
|
2300 |
-
if ( empty( $page ) )
|
2301 |
-
return false;
|
2302 |
-
|
2303 |
-
$before = apply_filters( 'ot_before_page_messages', '', $page );
|
2304 |
-
|
2305 |
-
if ( $before ) {
|
2306 |
-
return $before;
|
2307 |
-
}
|
2308 |
-
|
2309 |
-
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
|
2310 |
-
$message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : '';
|
2311 |
-
$updated = isset( $_REQUEST['settings-updated'] ) ? $_REQUEST['settings-updated'] : '';
|
2312 |
-
|
2313 |
-
if ( $action == 'save-settings' ) {
|
2314 |
-
|
2315 |
-
if ( $message == 'success' ) {
|
2316 |
-
|
2317 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings updated.', 'option-tree' ) . '</p></div>';
|
2318 |
-
|
2319 |
-
} else if ( $message == 'failed' ) {
|
2320 |
-
|
2321 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be saved.', 'option-tree' ) . '</p></div>';
|
2322 |
-
|
2323 |
-
}
|
2324 |
-
|
2325 |
-
} else if ( $action == 'import-xml' || $action == 'import-settings' ) {
|
2326 |
-
|
2327 |
-
if ( $message == 'success' ) {
|
2328 |
-
|
2329 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Settings Imported.', 'option-tree' ) . '</p></div>';
|
2330 |
-
|
2331 |
-
} else if ( $message == 'failed' ) {
|
2332 |
-
|
2333 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Settings could not be imported.', 'option-tree' ) . '</p></div>';
|
2334 |
-
|
2335 |
-
}
|
2336 |
-
} else if ( $action == 'import-data' ) {
|
2337 |
-
|
2338 |
-
if ( $message == 'success' ) {
|
2339 |
-
|
2340 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Data Imported.', 'option-tree' ) . '</p></div>';
|
2341 |
-
|
2342 |
-
} else if ( $message == 'failed' ) {
|
2343 |
-
|
2344 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Data could not be imported.', 'option-tree' ) . '</p></div>';
|
2345 |
-
|
2346 |
-
}
|
2347 |
-
|
2348 |
-
} else if ( $action == 'import-layouts' ) {
|
2349 |
-
|
2350 |
-
if ( $message == 'success' ) {
|
2351 |
-
|
2352 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Imported.', 'option-tree' ) . '</p></div>';
|
2353 |
-
|
2354 |
-
} else if ( $message == 'failed' ) {
|
2355 |
-
|
2356 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be imported.', 'option-tree' ) . '</p></div>';
|
2357 |
-
|
2358 |
-
}
|
2359 |
-
|
2360 |
-
} else if ( $action == 'save-layouts' ) {
|
2361 |
-
|
2362 |
-
if ( $message == 'success' ) {
|
2363 |
-
|
2364 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts Updated.', 'option-tree' ) . '</p></div>';
|
2365 |
-
|
2366 |
-
} else if ( $message == 'failed' ) {
|
2367 |
-
|
2368 |
-
return '<div id="message" class="error fade below-h2"><p>' . __( 'Layouts could not be updated.', 'option-tree' ) . '</p></div>';
|
2369 |
-
|
2370 |
-
} else if ( $message == 'deleted' ) {
|
2371 |
-
|
2372 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layouts have been deleted.', 'option-tree' ) . '</p></div>';
|
2373 |
-
|
2374 |
-
}
|
2375 |
-
|
2376 |
-
} else if ( $updated == 'layout' ) {
|
2377 |
-
|
2378 |
-
return '<div id="message" class="updated fade below-h2"><p>' . __( 'Layout activated.', 'option-tree' ) . '</p></div>';
|
2379 |
-
|
2380 |
-
} else if ( $action == 'reset' ) {
|
2381 |
-
|
2382 |
-
return '<div id="message" class="updated fade below-h2"><p>' . $page['reset_message'] . '</p></div>';
|
2383 |
-
|
2384 |
-
}
|
2385 |
-
|
2386 |
-
do_action( 'ot_custom_page_messages', $page );
|
2387 |
-
|
2388 |
-
if ( $updated == 'true' ) {
|
2389 |
-
|
2390 |
-
return '<div id="message" class="updated fade below-h2"><p>' . $page['updated_message'] . '</p></div>';
|
2391 |
-
|
2392 |
-
}
|
2393 |
-
|
2394 |
-
return false;
|
2395 |
-
|
2396 |
-
}
|
2397 |
-
|
2398 |
-
}
|
2399 |
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
* This is not a task for a beginner as you'll need to add the function
|
2405 |
-
* that displays the option to the user and validate the saved data.
|
2406 |
-
*
|
2407 |
-
* @return array
|
2408 |
-
*
|
2409 |
-
* @access public
|
2410 |
-
* @since 2.0
|
2411 |
-
*/
|
2412 |
-
if ( ! function_exists( 'ot_option_types_array' ) ) {
|
2413 |
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
'border' => __('Border', 'option-tree'),
|
2419 |
-
'box-shadow' => __('Box Shadow', 'option-tree'),
|
2420 |
-
'category-checkbox' => __('Category Checkbox', 'option-tree'),
|
2421 |
-
'category-select' => __('Category Select', 'option-tree'),
|
2422 |
-
'checkbox' => __('Checkbox', 'option-tree'),
|
2423 |
-
'colorpicker' => __('Colorpicker', 'option-tree'),
|
2424 |
-
'colorpicker-opacity' => __('Colorpicker Opacity', 'option-tree'),
|
2425 |
-
'css' => __('CSS', 'option-tree'),
|
2426 |
-
'custom-post-type-checkbox' => __('Custom Post Type Checkbox', 'option-tree'),
|
2427 |
-
'custom-post-type-select' => __('Custom Post Type Select', 'option-tree'),
|
2428 |
-
'date-picker' => __('Date Picker', 'option-tree'),
|
2429 |
-
'date-time-picker' => __('Date Time Picker', 'option-tree'),
|
2430 |
-
'dimension' => __('Dimension', 'option-tree'),
|
2431 |
-
'gallery' => __('Gallery', 'option-tree'),
|
2432 |
-
'google-fonts' => __('Google Fonts', 'option-tree'),
|
2433 |
-
'javascript' => __('JavaScript', 'option-tree'),
|
2434 |
-
'link-color' => __('Link Color', 'option-tree'),
|
2435 |
-
'list-item' => __('List Item', 'option-tree'),
|
2436 |
-
'measurement' => __('Measurement', 'option-tree'),
|
2437 |
-
'numeric-slider' => __('Numeric Slider', 'option-tree'),
|
2438 |
-
'on-off' => __('On/Off', 'option-tree'),
|
2439 |
-
'page-checkbox' => __('Page Checkbox', 'option-tree'),
|
2440 |
-
'page-select' => __('Page Select', 'option-tree'),
|
2441 |
-
'post-checkbox' => __('Post Checkbox', 'option-tree'),
|
2442 |
-
'post-select' => __('Post Select', 'option-tree'),
|
2443 |
-
'radio' => __('Radio', 'option-tree'),
|
2444 |
-
'radio-image' => __('Radio Image', 'option-tree'),
|
2445 |
-
'select' => __('Select', 'option-tree'),
|
2446 |
-
'sidebar-select' => __('Sidebar Select', 'option-tree'),
|
2447 |
-
'slider' => __('Slider', 'option-tree'),
|
2448 |
-
'social-links' => __('Social Links', 'option-tree'),
|
2449 |
-
'spacing' => __('Spacing', 'option-tree'),
|
2450 |
-
'tab' => __('Tab', 'option-tree'),
|
2451 |
-
'tag-checkbox' => __('Tag Checkbox', 'option-tree'),
|
2452 |
-
'tag-select' => __('Tag Select', 'option-tree'),
|
2453 |
-
'taxonomy-checkbox' => __('Taxonomy Checkbox', 'option-tree'),
|
2454 |
-
'taxonomy-select' => __('Taxonomy Select', 'option-tree'),
|
2455 |
-
'text' => __('Text', 'option-tree'),
|
2456 |
-
'textarea' => __('Textarea', 'option-tree'),
|
2457 |
-
'textarea-simple' => __('Textarea Simple', 'option-tree'),
|
2458 |
-
'textblock' => __('Textblock', 'option-tree'),
|
2459 |
-
'textblock-titled' => __('Textblock Titled', 'option-tree'),
|
2460 |
-
'typography' => __('Typography', 'option-tree'),
|
2461 |
-
'upload' => __('Upload', 'option-tree')
|
2462 |
-
) );
|
2463 |
-
|
2464 |
-
}
|
2465 |
-
}
|
2466 |
|
2467 |
-
|
2468 |
-
|
2469 |
-
*
|
2470 |
-
* @param string $type The old option type
|
2471 |
-
* @return string The new option type
|
2472 |
-
*
|
2473 |
-
* @access public
|
2474 |
-
* @since 2.0
|
2475 |
-
*/
|
2476 |
-
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
2477 |
|
2478 |
-
|
2479 |
-
|
2480 |
-
if ( ! $type )
|
2481 |
-
return 'text';
|
2482 |
-
|
2483 |
-
$types = array(
|
2484 |
-
'background' => 'background',
|
2485 |
-
'category' => 'category-select',
|
2486 |
-
'categories' => 'category-checkbox',
|
2487 |
-
'checkbox' => 'checkbox',
|
2488 |
-
'colorpicker' => 'colorpicker',
|
2489 |
-
'css' => 'css',
|
2490 |
-
'custom_post' => 'custom-post-type-select',
|
2491 |
-
'custom_posts' => 'custom-post-type-checkbox',
|
2492 |
-
'input' => 'text',
|
2493 |
-
'image' => 'upload',
|
2494 |
-
'measurement' => 'measurement',
|
2495 |
-
'page' => 'page-select',
|
2496 |
-
'pages' => 'page-checkbox',
|
2497 |
-
'post' => 'post-select',
|
2498 |
-
'posts' => 'post-checkbox',
|
2499 |
-
'radio' => 'radio',
|
2500 |
-
'select' => 'select',
|
2501 |
-
'slider' => 'slider',
|
2502 |
-
'tag' => 'tag-select',
|
2503 |
-
'tags' => 'tag-checkbox',
|
2504 |
-
'textarea' => 'textarea',
|
2505 |
-
'textblock' => 'textblock',
|
2506 |
-
'typography' => 'typography',
|
2507 |
-
'upload' => 'upload'
|
2508 |
-
);
|
2509 |
-
|
2510 |
-
if ( isset( $types[$type] ) )
|
2511 |
-
return $types[$type];
|
2512 |
-
|
2513 |
-
return false;
|
2514 |
-
|
2515 |
-
}
|
2516 |
-
}
|
2517 |
|
2518 |
-
|
2519 |
-
|
2520 |
-
*
|
2521 |
-
* @param array $families An array of all recognized font families.
|
2522 |
-
* @param string $field_id ID of the feild being filtered.
|
2523 |
-
* @return array
|
2524 |
-
*
|
2525 |
-
* @access public
|
2526 |
-
* @since 2.5.0
|
2527 |
-
*/
|
2528 |
-
function ot_google_font_stack( $families, $field_id ) {
|
2529 |
-
|
2530 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
2531 |
-
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
2532 |
-
|
2533 |
-
if ( ! empty( $ot_set_google_fonts ) ) {
|
2534 |
-
foreach( $ot_set_google_fonts as $id => $sets ) {
|
2535 |
-
foreach( $sets as $value ) {
|
2536 |
-
$family = isset( $value['family'] ) ? $value['family'] : '';
|
2537 |
-
if ( $family && isset( $ot_google_fonts[$family] ) ) {
|
2538 |
-
$spaces = explode(' ', $ot_google_fonts[$family]['family'] );
|
2539 |
-
$font_stack = count( $spaces ) > 1 ? '"' . $ot_google_fonts[$family]['family'] . '"': $ot_google_fonts[$family]['family'];
|
2540 |
-
$families[$family] = apply_filters( 'ot_google_font_stack', $font_stack, $family, $field_id );
|
2541 |
-
}
|
2542 |
-
}
|
2543 |
-
}
|
2544 |
-
}
|
2545 |
-
|
2546 |
-
return $families;
|
2547 |
-
}
|
2548 |
-
add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
|
2549 |
|
2550 |
-
|
2551 |
-
|
2552 |
-
*
|
2553 |
-
* Returns an array of all recognized font families.
|
2554 |
-
* Keys are intended to be stored in the database
|
2555 |
-
* while values are ready for display in html.
|
2556 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2557 |
-
*
|
2558 |
-
* @uses apply_filters()
|
2559 |
-
*
|
2560 |
-
* @return array
|
2561 |
-
*
|
2562 |
-
* @access public
|
2563 |
-
* @since 1.1.8
|
2564 |
-
* @updated 2.0
|
2565 |
-
*/
|
2566 |
-
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
2567 |
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
'georgia' => 'Georgia',
|
2573 |
-
'helvetica' => 'Helvetica',
|
2574 |
-
'palatino' => 'Palatino',
|
2575 |
-
'tahoma' => 'Tahoma',
|
2576 |
-
'times' => '"Times New Roman", sans-serif',
|
2577 |
-
'trebuchet' => 'Trebuchet',
|
2578 |
-
'verdana' => 'Verdana'
|
2579 |
-
);
|
2580 |
-
|
2581 |
-
return apply_filters( 'ot_recognized_font_families', $families, $field_id );
|
2582 |
-
|
2583 |
-
}
|
2584 |
|
2585 |
-
|
|
|
|
|
|
|
2586 |
|
2587 |
-
|
2588 |
-
|
2589 |
-
*
|
2590 |
-
* Returns an array of all recognized font sizes.
|
2591 |
-
*
|
2592 |
-
* @uses apply_filters()
|
2593 |
-
*
|
2594 |
-
* @param string $field_id ID that's passed to the filters.
|
2595 |
-
* @return array
|
2596 |
-
*
|
2597 |
-
* @access public
|
2598 |
-
* @since 2.0.12
|
2599 |
-
*/
|
2600 |
-
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
|
2601 |
|
2602 |
-
|
2603 |
-
|
2604 |
-
$range = ot_range(
|
2605 |
-
apply_filters( 'ot_font_size_low_range', 0, $field_id ),
|
2606 |
-
apply_filters( 'ot_font_size_high_range', 150, $field_id ),
|
2607 |
-
apply_filters( 'ot_font_size_range_interval', 1, $field_id )
|
2608 |
-
);
|
2609 |
-
|
2610 |
-
$unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
|
2611 |
-
|
2612 |
-
foreach( $range as $k => $v ) {
|
2613 |
-
$range[$k] = $v . $unit;
|
2614 |
-
}
|
2615 |
-
|
2616 |
-
return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
|
2617 |
-
}
|
2618 |
|
2619 |
-
|
|
|
2620 |
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2626 |
-
*
|
2627 |
-
* @uses apply_filters()
|
2628 |
-
*
|
2629 |
-
* @return array
|
2630 |
-
*
|
2631 |
-
* @access public
|
2632 |
-
* @since 1.1.8
|
2633 |
-
* @updated 2.0
|
2634 |
-
*/
|
2635 |
-
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
|
2636 |
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
'italic' => 'Italic',
|
2642 |
-
'oblique' => 'Oblique',
|
2643 |
-
'inherit' => 'Inherit'
|
2644 |
-
), $field_id );
|
2645 |
-
|
2646 |
-
}
|
2647 |
|
2648 |
-
|
|
|
2649 |
|
2650 |
-
|
2651 |
-
* Recognized font variants
|
2652 |
-
*
|
2653 |
-
* Returns an array of all recognized font variants.
|
2654 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2655 |
-
*
|
2656 |
-
* @uses apply_filters()
|
2657 |
-
*
|
2658 |
-
* @return array
|
2659 |
-
*
|
2660 |
-
* @access public
|
2661 |
-
* @since 1.1.8
|
2662 |
-
* @updated 2.0
|
2663 |
-
*/
|
2664 |
-
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
|
2665 |
|
2666 |
-
|
2667 |
-
|
2668 |
-
return apply_filters( 'ot_recognized_font_variants', array(
|
2669 |
-
'normal' => 'Normal',
|
2670 |
-
'small-caps' => 'Small Caps',
|
2671 |
-
'inherit' => 'Inherit'
|
2672 |
-
), $field_id );
|
2673 |
-
|
2674 |
-
}
|
2675 |
-
|
2676 |
-
}
|
2677 |
|
2678 |
-
|
2679 |
-
|
2680 |
-
*
|
2681 |
-
* Returns an array of all recognized font weights.
|
2682 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2683 |
-
*
|
2684 |
-
* @uses apply_filters()
|
2685 |
-
*
|
2686 |
-
* @return array
|
2687 |
-
*
|
2688 |
-
* @access public
|
2689 |
-
* @since 1.1.8
|
2690 |
-
* @updated 2.0
|
2691 |
-
*/
|
2692 |
-
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
2693 |
|
2694 |
-
|
2695 |
-
|
2696 |
-
return apply_filters( 'ot_recognized_font_weights', array(
|
2697 |
-
'normal' => 'Normal',
|
2698 |
-
'bold' => 'Bold',
|
2699 |
-
'bolder' => 'Bolder',
|
2700 |
-
'lighter' => 'Lighter',
|
2701 |
-
'100' => '100',
|
2702 |
-
'200' => '200',
|
2703 |
-
'300' => '300',
|
2704 |
-
'400' => '400',
|
2705 |
-
'500' => '500',
|
2706 |
-
'600' => '600',
|
2707 |
-
'700' => '700',
|
2708 |
-
'800' => '800',
|
2709 |
-
'900' => '900',
|
2710 |
-
'inherit' => 'Inherit'
|
2711 |
-
), $field_id );
|
2712 |
-
|
2713 |
-
}
|
2714 |
-
|
2715 |
-
}
|
2716 |
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
*
|
2724 |
-
* @param string $field_id ID that's passed to the filters.
|
2725 |
-
* @return array
|
2726 |
-
*
|
2727 |
-
* @access public
|
2728 |
-
* @since 2.0.12
|
2729 |
-
*/
|
2730 |
-
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
|
2731 |
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ),
|
2737 |
-
apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
|
2738 |
-
);
|
2739 |
-
|
2740 |
-
$unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
|
2741 |
-
|
2742 |
-
foreach( $range as $k => $v ) {
|
2743 |
-
$range[$k] = $v . $unit;
|
2744 |
-
}
|
2745 |
-
|
2746 |
-
return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
|
2747 |
-
}
|
2748 |
|
|
|
|
|
2749 |
}
|
2750 |
|
2751 |
-
|
2752 |
-
* Recognized line heights
|
2753 |
-
*
|
2754 |
-
* Returns an array of all recognized line heights.
|
2755 |
-
*
|
2756 |
-
* @uses apply_filters()
|
2757 |
-
*
|
2758 |
-
* @param string $field_id ID that's passed to the filters.
|
2759 |
-
* @return array
|
2760 |
-
*
|
2761 |
-
* @access public
|
2762 |
-
* @since 2.0.12
|
2763 |
-
*/
|
2764 |
-
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
|
2765 |
-
|
2766 |
-
function ot_recognized_line_heights( $field_id ) {
|
2767 |
-
|
2768 |
-
$range = ot_range(
|
2769 |
-
apply_filters( 'ot_line_height_low_range', 0, $field_id ),
|
2770 |
-
apply_filters( 'ot_line_height_high_range', 150, $field_id ),
|
2771 |
-
apply_filters( 'ot_line_height_range_interval', 1, $field_id )
|
2772 |
-
);
|
2773 |
-
|
2774 |
-
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
|
2775 |
-
|
2776 |
-
foreach( $range as $k => $v ) {
|
2777 |
-
$range[$k] = $v . $unit;
|
2778 |
-
}
|
2779 |
-
|
2780 |
-
return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
|
2781 |
-
}
|
2782 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2783 |
}
|
2784 |
|
2785 |
-
|
2786 |
-
* Recognized text decorations
|
2787 |
-
*
|
2788 |
-
* Returns an array of all recognized text decorations.
|
2789 |
-
* Keys are intended to be stored in the database
|
2790 |
-
* while values are ready for display in html.
|
2791 |
-
*
|
2792 |
-
* @uses apply_filters()
|
2793 |
-
*
|
2794 |
-
* @return array
|
2795 |
-
*
|
2796 |
-
* @access public
|
2797 |
-
* @since 2.0.10
|
2798 |
-
*/
|
2799 |
-
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
2800 |
-
|
2801 |
-
function ot_recognized_text_decorations( $field_id = '' ) {
|
2802 |
-
|
2803 |
-
return apply_filters( 'ot_recognized_text_decorations', array(
|
2804 |
-
'blink' => 'Blink',
|
2805 |
-
'inherit' => 'Inherit',
|
2806 |
-
'line-through' => 'Line Through',
|
2807 |
-
'none' => 'None',
|
2808 |
-
'overline' => 'Overline',
|
2809 |
-
'underline' => 'Underline'
|
2810 |
-
), $field_id );
|
2811 |
-
|
2812 |
-
}
|
2813 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2814 |
}
|
2815 |
|
2816 |
-
|
2817 |
-
* Recognized text transformations
|
2818 |
-
*
|
2819 |
-
* Returns an array of all recognized text transformations.
|
2820 |
-
* Keys are intended to be stored in the database
|
2821 |
-
* while values are ready for display in html.
|
2822 |
-
*
|
2823 |
-
* @uses apply_filters()
|
2824 |
-
*
|
2825 |
-
* @return array
|
2826 |
-
*
|
2827 |
-
* @access public
|
2828 |
-
* @since 2.0.10
|
2829 |
-
*/
|
2830 |
-
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
2831 |
-
|
2832 |
-
function ot_recognized_text_transformations( $field_id = '' ) {
|
2833 |
-
|
2834 |
-
return apply_filters( 'ot_recognized_text_transformations', array(
|
2835 |
-
'capitalize' => 'Capitalize',
|
2836 |
-
'inherit' => 'Inherit',
|
2837 |
-
'lowercase' => 'Lowercase',
|
2838 |
-
'none' => 'None',
|
2839 |
-
'uppercase' => 'Uppercase'
|
2840 |
-
), $field_id );
|
2841 |
-
|
2842 |
-
}
|
2843 |
-
|
2844 |
-
}
|
2845 |
-
|
2846 |
-
/**
|
2847 |
-
* Recognized background repeat
|
2848 |
-
*
|
2849 |
-
* Returns an array of all recognized background repeat values.
|
2850 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2851 |
-
*
|
2852 |
-
* @uses apply_filters()
|
2853 |
-
*
|
2854 |
-
* @return array
|
2855 |
-
*
|
2856 |
-
* @access public
|
2857 |
-
* @since 1.1.8
|
2858 |
-
* @updated 2.0
|
2859 |
-
*/
|
2860 |
-
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
2861 |
-
|
2862 |
-
function ot_recognized_background_repeat( $field_id = '' ) {
|
2863 |
-
|
2864 |
-
return apply_filters( 'ot_recognized_background_repeat', array(
|
2865 |
-
'no-repeat' => 'No Repeat',
|
2866 |
-
'repeat' => 'Repeat All',
|
2867 |
-
'repeat-x' => 'Repeat Horizontally',
|
2868 |
-
'repeat-y' => 'Repeat Vertically',
|
2869 |
-
'inherit' => 'Inherit'
|
2870 |
-
), $field_id );
|
2871 |
-
|
2872 |
-
}
|
2873 |
-
|
2874 |
-
}
|
2875 |
-
|
2876 |
-
/**
|
2877 |
-
* Recognized background attachment
|
2878 |
-
*
|
2879 |
-
* Returns an array of all recognized background attachment values.
|
2880 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2881 |
-
*
|
2882 |
-
* @uses apply_filters()
|
2883 |
-
*
|
2884 |
-
* @return array
|
2885 |
-
*
|
2886 |
-
* @access public
|
2887 |
-
* @since 1.1.8
|
2888 |
-
* @updated 2.0
|
2889 |
-
*/
|
2890 |
-
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
|
2891 |
-
|
2892 |
-
function ot_recognized_background_attachment( $field_id = '' ) {
|
2893 |
-
|
2894 |
-
return apply_filters( 'ot_recognized_background_attachment', array(
|
2895 |
-
"fixed" => "Fixed",
|
2896 |
-
"scroll" => "Scroll",
|
2897 |
-
"inherit" => "Inherit"
|
2898 |
-
), $field_id );
|
2899 |
-
|
2900 |
-
}
|
2901 |
-
|
2902 |
-
}
|
2903 |
-
|
2904 |
-
/**
|
2905 |
-
* Recognized background position
|
2906 |
-
*
|
2907 |
-
* Returns an array of all recognized background position values.
|
2908 |
-
* Renamed in version 2.0 to avoid name collisions.
|
2909 |
-
*
|
2910 |
-
* @uses apply_filters()
|
2911 |
-
*
|
2912 |
-
* @return array
|
2913 |
-
*
|
2914 |
-
* @access public
|
2915 |
-
* @since 1.1.8
|
2916 |
-
* @updated 2.0
|
2917 |
-
*/
|
2918 |
-
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
|
2919 |
-
|
2920 |
-
function ot_recognized_background_position( $field_id = '' ) {
|
2921 |
-
|
2922 |
-
return apply_filters( 'ot_recognized_background_position', array(
|
2923 |
-
"left top" => "Left Top",
|
2924 |
-
"left center" => "Left Center",
|
2925 |
-
"left bottom" => "Left Bottom",
|
2926 |
-
"center top" => "Center Top",
|
2927 |
-
"center center" => "Center Center",
|
2928 |
-
"center bottom" => "Center Bottom",
|
2929 |
-
"right top" => "Right Top",
|
2930 |
-
"right center" => "Right Center",
|
2931 |
-
"right bottom" => "Right Bottom"
|
2932 |
-
), $field_id );
|
2933 |
-
|
2934 |
-
}
|
2935 |
-
|
2936 |
-
}
|
2937 |
-
|
2938 |
-
/**
|
2939 |
-
* Border Styles
|
2940 |
-
*
|
2941 |
-
* Returns an array of all available style types.
|
2942 |
-
*
|
2943 |
-
* @uses apply_filters()
|
2944 |
-
*
|
2945 |
-
* @return array
|
2946 |
-
*
|
2947 |
-
* @access public
|
2948 |
-
* @since 2.5.0
|
2949 |
-
*/
|
2950 |
-
if ( ! function_exists( 'ot_recognized_border_style_types' ) ) {
|
2951 |
-
|
2952 |
-
function ot_recognized_border_style_types( $field_id = '' ) {
|
2953 |
-
|
2954 |
-
return apply_filters( 'ot_recognized_border_style_types', array(
|
2955 |
-
'hidden' => 'Hidden',
|
2956 |
-
'dashed' => 'Dashed',
|
2957 |
-
'solid' => 'Solid',
|
2958 |
-
'double' => 'Double',
|
2959 |
-
'groove' => 'Groove',
|
2960 |
-
'ridge' => 'Ridge',
|
2961 |
-
'inset' => 'Inset',
|
2962 |
-
'outset' => 'Outset',
|
2963 |
-
), $field_id );
|
2964 |
-
|
2965 |
-
}
|
2966 |
-
|
2967 |
-
}
|
2968 |
-
|
2969 |
-
/**
|
2970 |
-
* Border Units
|
2971 |
-
*
|
2972 |
-
* Returns an array of all available unit types.
|
2973 |
-
*
|
2974 |
-
* @uses apply_filters()
|
2975 |
-
*
|
2976 |
-
* @return array
|
2977 |
-
*
|
2978 |
-
* @access public
|
2979 |
-
* @since 2.5.0
|
2980 |
-
*/
|
2981 |
-
if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) {
|
2982 |
-
|
2983 |
-
function ot_recognized_border_unit_types( $field_id = '' ) {
|
2984 |
-
|
2985 |
-
return apply_filters( 'ot_recognized_border_unit_types', array(
|
2986 |
-
'px' => 'px',
|
2987 |
-
'%' => '%',
|
2988 |
-
'em' => 'em',
|
2989 |
-
'pt' => 'pt'
|
2990 |
-
), $field_id );
|
2991 |
-
|
2992 |
-
}
|
2993 |
-
|
2994 |
-
}
|
2995 |
-
|
2996 |
-
/**
|
2997 |
-
* Dimension Units
|
2998 |
-
*
|
2999 |
-
* Returns an array of all available unit types.
|
3000 |
-
*
|
3001 |
-
* @uses apply_filters()
|
3002 |
-
*
|
3003 |
-
* @return array
|
3004 |
-
*
|
3005 |
-
* @access public
|
3006 |
-
* @since 2.5.0
|
3007 |
-
*/
|
3008 |
-
if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) {
|
3009 |
-
|
3010 |
-
function ot_recognized_dimension_unit_types( $field_id = '' ) {
|
3011 |
-
|
3012 |
-
return apply_filters( 'ot_recognized_dimension_unit_types', array(
|
3013 |
-
'px' => 'px',
|
3014 |
-
'%' => '%',
|
3015 |
-
'em' => 'em',
|
3016 |
-
'pt' => 'pt'
|
3017 |
-
), $field_id );
|
3018 |
-
|
3019 |
-
}
|
3020 |
-
|
3021 |
-
}
|
3022 |
-
|
3023 |
-
/**
|
3024 |
-
* Spacing Units
|
3025 |
-
*
|
3026 |
-
* Returns an array of all available unit types.
|
3027 |
-
*
|
3028 |
-
* @uses apply_filters()
|
3029 |
-
*
|
3030 |
-
* @return array
|
3031 |
-
*
|
3032 |
-
* @access public
|
3033 |
-
* @since 2.5.0
|
3034 |
-
*/
|
3035 |
-
if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) {
|
3036 |
-
|
3037 |
-
function ot_recognized_spacing_unit_types( $field_id = '' ) {
|
3038 |
-
|
3039 |
-
return apply_filters( 'ot_recognized_spacing_unit_types', array(
|
3040 |
-
'px' => 'px',
|
3041 |
-
'%' => '%',
|
3042 |
-
'em' => 'em',
|
3043 |
-
'pt' => 'pt'
|
3044 |
-
), $field_id );
|
3045 |
-
|
3046 |
-
}
|
3047 |
-
|
3048 |
-
}
|
3049 |
-
|
3050 |
-
/**
|
3051 |
-
* Recognized Google font families
|
3052 |
-
*
|
3053 |
-
* @uses apply_filters()
|
3054 |
-
*
|
3055 |
-
* @return array
|
3056 |
-
*
|
3057 |
-
* @access public
|
3058 |
-
* @since 2.5.0
|
3059 |
-
*/
|
3060 |
-
if ( ! function_exists( 'ot_recognized_google_font_families' ) ) {
|
3061 |
-
|
3062 |
-
function ot_recognized_google_font_families( $field_id ) {
|
3063 |
-
|
3064 |
-
$families = array();
|
3065 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3066 |
-
|
3067 |
-
// Forces an array rebuild when we sitch themes
|
3068 |
-
if ( empty( $ot_google_fonts ) ) {
|
3069 |
-
$ot_google_fonts = ot_fetch_google_fonts( true, true );
|
3070 |
-
}
|
3071 |
-
|
3072 |
-
foreach( (array) $ot_google_fonts as $key => $item ) {
|
3073 |
-
|
3074 |
-
if ( isset( $item['family'] ) ) {
|
3075 |
-
|
3076 |
-
$families[ $key ] = $item['family'];
|
3077 |
-
|
3078 |
-
}
|
3079 |
-
|
3080 |
-
}
|
3081 |
-
|
3082 |
-
return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
|
3083 |
-
|
3084 |
-
}
|
3085 |
-
|
3086 |
-
}
|
3087 |
-
|
3088 |
-
/**
|
3089 |
-
* Recognized Google font variants
|
3090 |
-
*
|
3091 |
-
* @uses apply_filters()
|
3092 |
-
*
|
3093 |
-
* @return array
|
3094 |
-
*
|
3095 |
-
* @access public
|
3096 |
-
* @since 2.5.0
|
3097 |
-
*/
|
3098 |
-
if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) {
|
3099 |
-
|
3100 |
-
function ot_recognized_google_font_variants( $field_id, $family ) {
|
3101 |
-
|
3102 |
-
$variants = array();
|
3103 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3104 |
-
|
3105 |
-
if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
|
3106 |
-
|
3107 |
-
$variants = $ot_google_fonts[ $family ]['variants'];
|
3108 |
-
|
3109 |
-
}
|
3110 |
-
|
3111 |
-
return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family );
|
3112 |
-
|
3113 |
-
}
|
3114 |
-
|
3115 |
-
}
|
3116 |
-
|
3117 |
-
/**
|
3118 |
-
* Recognized Google font subsets
|
3119 |
-
*
|
3120 |
-
* @uses apply_filters()
|
3121 |
-
*
|
3122 |
-
* @return array
|
3123 |
-
*
|
3124 |
-
* @access public
|
3125 |
-
* @since 2.5.0
|
3126 |
-
*/
|
3127 |
-
if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
|
3128 |
-
|
3129 |
-
function ot_recognized_google_font_subsets( $field_id, $family ) {
|
3130 |
-
|
3131 |
-
$subsets = array();
|
3132 |
-
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3133 |
-
|
3134 |
-
if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
|
3135 |
-
|
3136 |
-
$subsets = $ot_google_fonts[ $family ]['subsets'];
|
3137 |
-
|
3138 |
-
}
|
3139 |
-
|
3140 |
-
return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family );
|
3141 |
-
|
3142 |
-
}
|
3143 |
-
|
3144 |
-
}
|
3145 |
-
|
3146 |
-
/**
|
3147 |
-
* Measurement Units
|
3148 |
-
*
|
3149 |
-
* Returns an array of all available unit types.
|
3150 |
-
* Renamed in version 2.0 to avoid name collisions.
|
3151 |
-
*
|
3152 |
-
* @uses apply_filters()
|
3153 |
-
*
|
3154 |
-
* @return array
|
3155 |
-
*
|
3156 |
-
* @access public
|
3157 |
-
* @since 1.1.8
|
3158 |
-
* @updated 2.0
|
3159 |
-
*/
|
3160 |
-
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
|
3161 |
-
|
3162 |
-
function ot_measurement_unit_types( $field_id = '' ) {
|
3163 |
-
|
3164 |
-
return apply_filters( 'ot_measurement_unit_types', array(
|
3165 |
-
'px' => 'px',
|
3166 |
-
'%' => '%',
|
3167 |
-
'em' => 'em',
|
3168 |
-
'pt' => 'pt'
|
3169 |
-
), $field_id );
|
3170 |
-
|
3171 |
-
}
|
3172 |
-
|
3173 |
-
}
|
3174 |
-
|
3175 |
-
/**
|
3176 |
-
* Radio Images default array.
|
3177 |
-
*
|
3178 |
-
* Returns an array of all available radio images.
|
3179 |
-
* You can filter this function to change the images
|
3180 |
-
* on a per option basis.
|
3181 |
-
*
|
3182 |
-
* @uses apply_filters()
|
3183 |
-
*
|
3184 |
-
* @return array
|
3185 |
-
*
|
3186 |
-
* @access public
|
3187 |
-
* @since 2.0
|
3188 |
-
*/
|
3189 |
-
if ( ! function_exists( 'ot_radio_images' ) ) {
|
3190 |
-
|
3191 |
-
function ot_radio_images( $field_id = '' ) {
|
3192 |
-
|
3193 |
-
return apply_filters( 'ot_radio_images', array(
|
3194 |
-
array(
|
3195 |
-
'value' => 'left-sidebar',
|
3196 |
-
'label' => __( 'Left Sidebar', 'option-tree' ),
|
3197 |
-
'src' => OT_URL . 'assets/images/layout/left-sidebar.png'
|
3198 |
-
),
|
3199 |
-
array(
|
3200 |
-
'value' => 'right-sidebar',
|
3201 |
-
'label' => __( 'Right Sidebar', 'option-tree' ),
|
3202 |
-
'src' => OT_URL . 'assets/images/layout/right-sidebar.png'
|
3203 |
-
),
|
3204 |
-
array(
|
3205 |
-
'value' => 'full-width',
|
3206 |
-
'label' => __( 'Full Width (no sidebar)', 'option-tree' ),
|
3207 |
-
'src' => OT_URL . 'assets/images/layout/full-width.png'
|
3208 |
-
),
|
3209 |
-
array(
|
3210 |
-
'value' => 'dual-sidebar',
|
3211 |
-
'label' => __( 'Dual Sidebar', 'option-tree' ),
|
3212 |
-
'src' => OT_URL . 'assets/images/layout/dual-sidebar.png'
|
3213 |
-
),
|
3214 |
-
array(
|
3215 |
-
'value' => 'left-dual-sidebar',
|
3216 |
-
'label' => __( 'Left Dual Sidebar', 'option-tree' ),
|
3217 |
-
'src' => OT_URL . 'assets/images/layout/left-dual-sidebar.png'
|
3218 |
-
),
|
3219 |
-
array(
|
3220 |
-
'value' => 'right-dual-sidebar',
|
3221 |
-
'label' => __( 'Right Dual Sidebar', 'option-tree' ),
|
3222 |
-
'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png'
|
3223 |
-
)
|
3224 |
-
), $field_id );
|
3225 |
-
|
3226 |
-
}
|
3227 |
-
|
3228 |
-
}
|
3229 |
-
|
3230 |
-
/**
|
3231 |
-
* Default List Item Settings array.
|
3232 |
-
*
|
3233 |
-
* Returns an array of the default list item settings.
|
3234 |
-
* You can filter this function to change the settings
|
3235 |
-
* on a per option basis.
|
3236 |
-
*
|
3237 |
-
* @uses apply_filters()
|
3238 |
-
*
|
3239 |
-
* @return array
|
3240 |
-
*
|
3241 |
-
* @access public
|
3242 |
-
* @since 2.0
|
3243 |
-
*/
|
3244 |
-
if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
3245 |
-
|
3246 |
-
function ot_list_item_settings( $id ) {
|
3247 |
-
|
3248 |
-
$settings = apply_filters( 'ot_list_item_settings', array(
|
3249 |
-
array(
|
3250 |
-
'id' => 'image',
|
3251 |
-
'label' => __( 'Image', 'option-tree' ),
|
3252 |
-
'desc' => '',
|
3253 |
-
'std' => '',
|
3254 |
-
'type' => 'upload',
|
3255 |
-
'rows' => '',
|
3256 |
-
'class' => '',
|
3257 |
-
'post_type' => '',
|
3258 |
-
'choices' => array()
|
3259 |
-
),
|
3260 |
-
array(
|
3261 |
-
'id' => 'link',
|
3262 |
-
'label' => __( 'Link', 'option-tree' ),
|
3263 |
-
'desc' => '',
|
3264 |
-
'std' => '',
|
3265 |
-
'type' => 'text',
|
3266 |
-
'rows' => '',
|
3267 |
-
'class' => '',
|
3268 |
-
'post_type' => '',
|
3269 |
-
'choices' => array()
|
3270 |
-
),
|
3271 |
-
array(
|
3272 |
-
'id' => 'description',
|
3273 |
-
'label' => __( 'Description', 'option-tree' ),
|
3274 |
-
'desc' => '',
|
3275 |
-
'std' => '',
|
3276 |
-
'type' => 'textarea-simple',
|
3277 |
-
'rows' => 10,
|
3278 |
-
'class' => '',
|
3279 |
-
'post_type' => '',
|
3280 |
-
'choices' => array()
|
3281 |
-
)
|
3282 |
-
), $id );
|
3283 |
-
|
3284 |
-
return $settings;
|
3285 |
-
|
3286 |
-
}
|
3287 |
-
|
3288 |
-
}
|
3289 |
-
|
3290 |
-
/**
|
3291 |
-
* Default Slider Settings array.
|
3292 |
-
*
|
3293 |
-
* Returns an array of the default slider settings.
|
3294 |
-
* You can filter this function to change the settings
|
3295 |
-
* on a per option basis.
|
3296 |
-
*
|
3297 |
-
* @uses apply_filters()
|
3298 |
-
*
|
3299 |
-
* @return array
|
3300 |
-
*
|
3301 |
-
* @access public
|
3302 |
-
* @since 2.0
|
3303 |
-
*/
|
3304 |
-
if ( ! function_exists( 'ot_slider_settings' ) ) {
|
3305 |
-
|
3306 |
-
function ot_slider_settings( $id ) {
|
3307 |
-
|
3308 |
-
$settings = apply_filters( 'image_slider_fields', array(
|
3309 |
-
array(
|
3310 |
-
'name' => 'image',
|
3311 |
-
'type' => 'image',
|
3312 |
-
'label' => __( 'Image', 'option-tree' ),
|
3313 |
-
'class' => ''
|
3314 |
-
),
|
3315 |
-
array(
|
3316 |
-
'name' => 'link',
|
3317 |
-
'type' => 'text',
|
3318 |
-
'label' => __( 'Link', 'option-tree' ),
|
3319 |
-
'class' => ''
|
3320 |
-
),
|
3321 |
-
array(
|
3322 |
-
'name' => 'description',
|
3323 |
-
'type' => 'textarea',
|
3324 |
-
'label' => __( 'Description', 'option-tree' ),
|
3325 |
-
'class' => ''
|
3326 |
-
)
|
3327 |
-
), $id );
|
3328 |
-
|
3329 |
-
/* fix the array keys, values, and just get it 2.0 ready */
|
3330 |
-
foreach( $settings as $_k => $setting ) {
|
3331 |
-
|
3332 |
-
foreach( $setting as $s_key => $s_value ) {
|
3333 |
-
|
3334 |
-
if ( 'name' == $s_key ) {
|
3335 |
-
|
3336 |
-
$settings[$_k]['id'] = $s_value;
|
3337 |
-
unset($settings[$_k]['name']);
|
3338 |
-
|
3339 |
-
} else if ( 'type' == $s_key ) {
|
3340 |
-
|
3341 |
-
if ( 'input' == $s_value ) {
|
3342 |
-
|
3343 |
-
$settings[$_k]['type'] = 'text';
|
3344 |
-
|
3345 |
-
} else if ( 'textarea' == $s_value ) {
|
3346 |
-
|
3347 |
-
$settings[$_k]['type'] = 'textarea-simple';
|
3348 |
-
|
3349 |
-
} else if ( 'image' == $s_value ) {
|
3350 |
-
|
3351 |
-
$settings[$_k]['type'] = 'upload';
|
3352 |
-
|
3353 |
-
}
|
3354 |
-
|
3355 |
-
}
|
3356 |
-
|
3357 |
-
}
|
3358 |
-
|
3359 |
-
}
|
3360 |
-
|
3361 |
-
return $settings;
|
3362 |
-
|
3363 |
-
}
|
3364 |
-
|
3365 |
-
}
|
3366 |
-
|
3367 |
-
/**
|
3368 |
-
* Default Social Links Settings array.
|
3369 |
-
*
|
3370 |
-
* Returns an array of the default social links settings.
|
3371 |
-
* You can filter this function to change the settings
|
3372 |
-
* on a per option basis.
|
3373 |
-
*
|
3374 |
-
* @uses apply_filters()
|
3375 |
-
*
|
3376 |
-
* @return array
|
3377 |
-
*
|
3378 |
-
* @access public
|
3379 |
-
* @since 2.4.0
|
3380 |
-
*/
|
3381 |
-
if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
3382 |
-
|
3383 |
-
function ot_social_links_settings( $id ) {
|
3384 |
-
|
3385 |
-
$settings = apply_filters( 'ot_social_links_settings', array(
|
3386 |
-
array(
|
3387 |
-
'id' => 'name',
|
3388 |
-
'label' => __( 'Name', 'option-tree' ),
|
3389 |
-
'desc' => __( 'Enter the name of the social website.', 'option-tree' ),
|
3390 |
-
'std' => '',
|
3391 |
-
'type' => 'text',
|
3392 |
-
'class' => 'option-tree-setting-title'
|
3393 |
-
),
|
3394 |
-
array(
|
3395 |
-
'id' => 'title',
|
3396 |
-
'label' => 'Title',
|
3397 |
-
'desc' => __( 'Enter the text shown in the title attribute of the link.', 'option-tree' ),
|
3398 |
-
'type' => 'text'
|
3399 |
-
),
|
3400 |
-
array(
|
3401 |
-
'id' => 'href',
|
3402 |
-
'label' => 'Link',
|
3403 |
-
'desc' => sprintf( __( 'Enter a link to the profile or page on the social website. Remember to add the %s part to the front of the link.', 'option-tree' ), '<code>http://</code>' ),
|
3404 |
-
'type' => 'text',
|
3405 |
-
)
|
3406 |
-
), $id );
|
3407 |
-
|
3408 |
-
return $settings;
|
3409 |
-
|
3410 |
-
}
|
3411 |
-
|
3412 |
-
}
|
3413 |
-
|
3414 |
-
/**
|
3415 |
-
* Inserts CSS with field_id markers.
|
3416 |
-
*
|
3417 |
-
* Inserts CSS into a dynamic.css file, placing it between
|
3418 |
-
* BEGIN and END field_id markers. Replaces existing marked info,
|
3419 |
-
* but still retains surrounding data.
|
3420 |
-
*
|
3421 |
-
* @param string $field_id The CSS option field ID.
|
3422 |
-
* @param array $options The current option_tree array.
|
3423 |
-
* @return bool True on write success, false on failure.
|
3424 |
-
*
|
3425 |
-
* @access public
|
3426 |
-
* @since 1.1.8
|
3427 |
-
* @updated 2.5.3
|
3428 |
-
*/
|
3429 |
-
if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
|
3430 |
-
|
3431 |
-
function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = false ) {
|
3432 |
-
|
3433 |
-
/* missing $field_id or $insertion exit early */
|
3434 |
-
if ( '' == $field_id || '' == $insertion )
|
3435 |
-
return;
|
3436 |
-
|
3437 |
-
/* path to the dynamic.css file */
|
3438 |
-
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3439 |
-
if ( is_multisite() ) {
|
3440 |
-
$multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
|
3441 |
-
if ( file_exists( $multisite_filepath ) ) {
|
3442 |
-
$filepath = $multisite_filepath;
|
3443 |
-
}
|
3444 |
-
}
|
3445 |
-
|
3446 |
-
/* allow filter on path */
|
3447 |
-
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3448 |
-
|
3449 |
-
/* grab a copy of the paths array */
|
3450 |
-
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
3451 |
-
if ( is_multisite() ) {
|
3452 |
-
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3453 |
-
}
|
3454 |
-
|
3455 |
-
/* set the path for this field */
|
3456 |
-
$ot_css_file_paths[$field_id] = $filepath;
|
3457 |
-
|
3458 |
-
/* update the paths */
|
3459 |
-
if ( is_multisite() ) {
|
3460 |
-
update_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3461 |
-
} else {
|
3462 |
-
update_option( 'ot_css_file_paths', $ot_css_file_paths );
|
3463 |
-
}
|
3464 |
-
|
3465 |
-
/* insert CSS into file */
|
3466 |
-
if ( file_exists( $filepath ) ) {
|
3467 |
-
|
3468 |
-
$insertion = ot_normalize_css( $insertion );
|
3469 |
-
$regex = "/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/";
|
3470 |
-
$marker = $field_id;
|
3471 |
-
|
3472 |
-
/* Match custom CSS */
|
3473 |
-
preg_match_all( $regex, $insertion, $matches );
|
3474 |
-
|
3475 |
-
/* Loop through CSS */
|
3476 |
-
foreach( $matches[0] as $option ) {
|
3477 |
-
|
3478 |
-
$value = '';
|
3479 |
-
$option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) );
|
3480 |
-
$option_id = isset( $option_array[0] ) ? $option_array[0] : '';
|
3481 |
-
$option_key = isset( $option_array[1] ) ? $option_array[1] : '';
|
3482 |
-
$option_type = ot_get_option_type_by_id( $option_id );
|
3483 |
-
$fallback = '';
|
3484 |
-
|
3485 |
-
// Get the meta array value
|
3486 |
-
if ( $meta ) {
|
3487 |
-
global $post;
|
3488 |
-
|
3489 |
-
$value = get_post_meta( $post->ID, $option_id, true );
|
3490 |
-
|
3491 |
-
// Get the options array value
|
3492 |
-
} else {
|
3493 |
-
|
3494 |
-
$options = get_option( ot_options_id() );
|
3495 |
-
|
3496 |
-
if ( isset( $options[$option_id] ) ) {
|
3497 |
-
|
3498 |
-
$value = $options[$option_id];
|
3499 |
-
|
3500 |
-
}
|
3501 |
-
|
3502 |
-
}
|
3503 |
-
|
3504 |
-
// This in an array of values
|
3505 |
-
if ( is_array( $value ) ) {
|
3506 |
-
|
3507 |
-
if ( empty( $option_key ) ) {
|
3508 |
-
|
3509 |
-
// Measurement
|
3510 |
-
if ( $option_type == 'measurement' ) {
|
3511 |
-
$unit = ! empty( $value[1] ) ? $value[1] : 'px';
|
3512 |
-
|
3513 |
-
// Set $value with measurement properties
|
3514 |
-
if ( isset( $value[0] ) && strlen( $value[0] ) > 0 )
|
3515 |
-
$value = $value[0].$unit;
|
3516 |
-
|
3517 |
-
// Border
|
3518 |
-
} else if ( $option_type == 'border' ) {
|
3519 |
-
$border = array();
|
3520 |
-
|
3521 |
-
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3522 |
-
|
3523 |
-
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
|
3524 |
-
$border[] = $value['width'].$unit;
|
3525 |
-
|
3526 |
-
if ( ! empty( $value['style'] ) )
|
3527 |
-
$border[] = $value['style'];
|
3528 |
-
|
3529 |
-
if ( ! empty( $value['color'] ) )
|
3530 |
-
$border[] = $value['color'];
|
3531 |
-
|
3532 |
-
/* set $value with border properties or empty string */
|
3533 |
-
$value = ! empty( $border ) ? implode( ' ', $border ) : '';
|
3534 |
-
|
3535 |
-
// Box Shadow
|
3536 |
-
} else if ( $option_type == 'box-shadow' ) {
|
3537 |
-
|
3538 |
-
/* set $value with box-shadow properties or empty string */
|
3539 |
-
$value = ! empty( $value ) ? implode( ' ', $value ) : '';
|
3540 |
-
|
3541 |
-
// Dimension
|
3542 |
-
} else if ( $option_type == 'dimension' ) {
|
3543 |
-
$dimension = array();
|
3544 |
-
|
3545 |
-
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3546 |
-
|
3547 |
-
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
|
3548 |
-
$dimension[] = $value['width'].$unit;
|
3549 |
-
|
3550 |
-
if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 )
|
3551 |
-
$dimension[] = $value['height'].$unit;
|
3552 |
-
|
3553 |
-
// Set $value with dimension properties or empty string
|
3554 |
-
$value = ! empty( $dimension ) ? implode( ' ', $dimension ) : '';
|
3555 |
-
|
3556 |
-
// Spacing
|
3557 |
-
} else if ( $option_type == 'spacing' ) {
|
3558 |
-
$spacing = array();
|
3559 |
-
|
3560 |
-
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3561 |
-
|
3562 |
-
if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 )
|
3563 |
-
$spacing[] = $value['top'].$unit;
|
3564 |
-
|
3565 |
-
if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 )
|
3566 |
-
$spacing[] = $value['right'].$unit;
|
3567 |
-
|
3568 |
-
if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 )
|
3569 |
-
$spacing[] = $value['bottom'].$unit;
|
3570 |
-
|
3571 |
-
if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 )
|
3572 |
-
$spacing[] = $value['left'].$unit;
|
3573 |
-
|
3574 |
-
// Set $value with spacing properties or empty string
|
3575 |
-
$value = ! empty( $spacing ) ? implode( ' ', $spacing ) : '';
|
3576 |
-
|
3577 |
-
// Typography
|
3578 |
-
} else if ( $option_type == 'typography' ) {
|
3579 |
-
$font = array();
|
3580 |
-
|
3581 |
-
if ( ! empty( $value['font-color'] ) )
|
3582 |
-
$font[] = "color: " . $value['font-color'] . ";";
|
3583 |
-
|
3584 |
-
if ( ! empty( $value['font-family'] ) ) {
|
3585 |
-
foreach ( ot_recognized_font_families( $marker ) as $key => $v ) {
|
3586 |
-
if ( $key == $value['font-family'] ) {
|
3587 |
-
$font[] = "font-family: " . $v . ";";
|
3588 |
-
}
|
3589 |
-
}
|
3590 |
-
}
|
3591 |
-
|
3592 |
-
if ( ! empty( $value['font-size'] ) )
|
3593 |
-
$font[] = "font-size: " . $value['font-size'] . ";";
|
3594 |
-
|
3595 |
-
if ( ! empty( $value['font-style'] ) )
|
3596 |
-
$font[] = "font-style: " . $value['font-style'] . ";";
|
3597 |
-
|
3598 |
-
if ( ! empty( $value['font-variant'] ) )
|
3599 |
-
$font[] = "font-variant: " . $value['font-variant'] . ";";
|
3600 |
-
|
3601 |
-
if ( ! empty( $value['font-weight'] ) )
|
3602 |
-
$font[] = "font-weight: " . $value['font-weight'] . ";";
|
3603 |
-
|
3604 |
-
if ( ! empty( $value['letter-spacing'] ) )
|
3605 |
-
$font[] = "letter-spacing: " . $value['letter-spacing'] . ";";
|
3606 |
-
|
3607 |
-
if ( ! empty( $value['line-height'] ) )
|
3608 |
-
$font[] = "line-height: " . $value['line-height'] . ";";
|
3609 |
-
|
3610 |
-
if ( ! empty( $value['text-decoration'] ) )
|
3611 |
-
$font[] = "text-decoration: " . $value['text-decoration'] . ";";
|
3612 |
-
|
3613 |
-
if ( ! empty( $value['text-transform'] ) )
|
3614 |
-
$font[] = "text-transform: " . $value['text-transform'] . ";";
|
3615 |
-
|
3616 |
-
// Set $value with font properties or empty string
|
3617 |
-
$value = ! empty( $font ) ? implode( "\n", $font ) : '';
|
3618 |
-
|
3619 |
-
// Background
|
3620 |
-
} else if ( $option_type == 'background' ) {
|
3621 |
-
$bg = array();
|
3622 |
-
|
3623 |
-
if ( ! empty( $value['background-color'] ) )
|
3624 |
-
$bg[] = $value['background-color'];
|
3625 |
-
|
3626 |
-
if ( ! empty( $value['background-image'] ) ) {
|
3627 |
-
|
3628 |
-
// If an attachment ID is stored here fetch its URL and replace the value
|
3629 |
-
if ( wp_attachment_is_image( $value['background-image'] ) ) {
|
3630 |
-
|
3631 |
-
$attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' );
|
3632 |
-
|
3633 |
-
// Check for attachment data
|
3634 |
-
if ( $attachment_data ) {
|
3635 |
-
|
3636 |
-
$value['background-image'] = $attachment_data[0];
|
3637 |
-
|
3638 |
-
}
|
3639 |
-
|
3640 |
-
}
|
3641 |
-
|
3642 |
-
$bg[] = 'url("' . $value['background-image'] . '")';
|
3643 |
-
|
3644 |
-
}
|
3645 |
-
|
3646 |
-
if ( ! empty( $value['background-repeat'] ) )
|
3647 |
-
$bg[] = $value['background-repeat'];
|
3648 |
-
|
3649 |
-
if ( ! empty( $value['background-attachment'] ) )
|
3650 |
-
$bg[] = $value['background-attachment'];
|
3651 |
-
|
3652 |
-
if ( ! empty( $value['background-position'] ) )
|
3653 |
-
$bg[] = $value['background-position'];
|
3654 |
-
|
3655 |
-
if ( ! empty( $value['background-size'] ) )
|
3656 |
-
$size = $value['background-size'];
|
3657 |
-
|
3658 |
-
// Set $value with background properties or empty string
|
3659 |
-
$value = ! empty( $bg ) ? 'background: ' . implode( " ", $bg ) . ';' : '';
|
3660 |
-
|
3661 |
-
if ( isset( $size ) ) {
|
3662 |
-
if ( ! empty( $bg ) ) {
|
3663 |
-
$value.= apply_filters( 'ot_insert_css_with_markers_bg_size_white_space', "\n\x20\x20", $option_id );
|
3664 |
-
}
|
3665 |
-
$value.= "background-size: $size;";
|
3666 |
-
}
|
3667 |
-
|
3668 |
-
}
|
3669 |
-
|
3670 |
-
} else {
|
3671 |
-
|
3672 |
-
$value = $value[$option_key];
|
3673 |
-
|
3674 |
-
}
|
3675 |
-
|
3676 |
-
}
|
3677 |
-
|
3678 |
-
// If an attachment ID is stored here fetch its URL and replace the value
|
3679 |
-
if ( $option_type == 'upload' && wp_attachment_is_image( $value ) ) {
|
3680 |
-
|
3681 |
-
$attachment_data = wp_get_attachment_image_src( $value, 'original' );
|
3682 |
-
|
3683 |
-
// Check for attachment data
|
3684 |
-
if ( $attachment_data ) {
|
3685 |
-
|
3686 |
-
$value = $attachment_data[0];
|
3687 |
-
|
3688 |
-
}
|
3689 |
-
|
3690 |
-
}
|
3691 |
-
|
3692 |
-
// Attempt to fallback when `$value` is empty
|
3693 |
-
if ( empty( $value ) ) {
|
3694 |
-
|
3695 |
-
// We're trying to access a single array key
|
3696 |
-
if ( ! empty( $option_key ) ) {
|
3697 |
-
|
3698 |
-
// Link Color `inherit`
|
3699 |
-
if ( $option_type == 'link-color' ) {
|
3700 |
-
$fallback = 'inherit';
|
3701 |
-
}
|
3702 |
-
|
3703 |
-
} else {
|
3704 |
-
|
3705 |
-
// Border
|
3706 |
-
if ( $option_type == 'border' ) {
|
3707 |
-
$fallback = 'inherit';
|
3708 |
-
}
|
3709 |
-
|
3710 |
-
// Box Shadow
|
3711 |
-
if ( $option_type == 'box-shadow' ) {
|
3712 |
-
$fallback = 'none';
|
3713 |
-
}
|
3714 |
-
|
3715 |
-
// Colorpicker
|
3716 |
-
if ( $option_type == 'colorpicker' ) {
|
3717 |
-
$fallback = 'inherit';
|
3718 |
-
}
|
3719 |
-
|
3720 |
-
// Colorpicker Opacity
|
3721 |
-
if ( $option_type == 'colorpicker-opacity' ) {
|
3722 |
-
$fallback = 'inherit';
|
3723 |
-
}
|
3724 |
-
|
3725 |
-
}
|
3726 |
-
|
3727 |
-
/**
|
3728 |
-
* Filter the `dynamic.css` fallback value.
|
3729 |
-
*
|
3730 |
-
* @since 2.5.3
|
3731 |
-
*
|
3732 |
-
* @param string $fallback The default CSS fallback value.
|
3733 |
-
* @param string $option_id The option ID.
|
3734 |
-
* @param string $option_type The option type.
|
3735 |
-
* @param string $option_key The option array key.
|
3736 |
-
*/
|
3737 |
-
$fallback = apply_filters( 'ot_insert_css_with_markers_fallback', $fallback, $option_id, $option_type, $option_key );
|
3738 |
-
|
3739 |
-
}
|
3740 |
-
|
3741 |
-
// Let's fallback!
|
3742 |
-
if ( ! empty( $fallback ) ) {
|
3743 |
-
$value = $fallback;
|
3744 |
-
}
|
3745 |
-
|
3746 |
-
// Filter the CSS
|
3747 |
-
$value = apply_filters( 'ot_insert_css_with_markers_value', $value, $option_id );
|
3748 |
-
|
3749 |
-
// Insert CSS, even if the value is empty
|
3750 |
-
$insertion = stripslashes( str_replace( $option, $value, $insertion ) );
|
3751 |
-
|
3752 |
-
}
|
3753 |
-
|
3754 |
-
// Can't write to the file so we error out
|
3755 |
-
if ( ! is_writable( $filepath ) ) {
|
3756 |
-
add_settings_error( 'option-tree', 'dynamic_css', sprintf( __( 'Unable to write to file %s.', 'option-tree' ), '<code>' . $filepath . '</code>' ), 'error' );
|
3757 |
-
return false;
|
3758 |
-
}
|
3759 |
-
|
3760 |
-
// Create array from the lines of code
|
3761 |
-
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3762 |
-
|
3763 |
-
// Can't write to the file return false
|
3764 |
-
if ( ! $f = ot_file_open( $filepath, 'w' ) ) {
|
3765 |
-
return false;
|
3766 |
-
}
|
3767 |
-
|
3768 |
-
$searching = true;
|
3769 |
-
$foundit = false;
|
3770 |
-
|
3771 |
-
// Has array of lines
|
3772 |
-
if ( ! empty( $markerdata ) ) {
|
3773 |
-
|
3774 |
-
// Foreach line of code
|
3775 |
-
foreach( $markerdata as $n => $markerline ) {
|
3776 |
-
|
3777 |
-
// Found begining of marker, set $searching to false
|
3778 |
-
if ( $markerline == "/* BEGIN {$marker} */" )
|
3779 |
-
$searching = false;
|
3780 |
-
|
3781 |
-
// Keep searching each line of CSS
|
3782 |
-
if ( $searching == true ) {
|
3783 |
-
if ( $n + 1 < count( $markerdata ) )
|
3784 |
-
ot_file_write( $f, "{$markerline}\n" );
|
3785 |
-
else
|
3786 |
-
ot_file_write( $f, "{$markerline}" );
|
3787 |
-
}
|
3788 |
-
|
3789 |
-
// Found end marker write code
|
3790 |
-
if ( $markerline == "/* END {$marker} */" ) {
|
3791 |
-
ot_file_write( $f, "/* BEGIN {$marker} */\n" );
|
3792 |
-
ot_file_write( $f, "{$insertion}\n" );
|
3793 |
-
ot_file_write( $f, "/* END {$marker} */\n" );
|
3794 |
-
$searching = true;
|
3795 |
-
$foundit = true;
|
3796 |
-
}
|
3797 |
-
|
3798 |
-
}
|
3799 |
-
|
3800 |
-
}
|
3801 |
-
|
3802 |
-
// Nothing inserted, write code. DO IT, DO IT!
|
3803 |
-
if ( ! $foundit ) {
|
3804 |
-
ot_file_write( $f, "/* BEGIN {$marker} */\n" );
|
3805 |
-
ot_file_write( $f, "{$insertion}\n" );
|
3806 |
-
ot_file_write( $f, "/* END {$marker} */\n" );
|
3807 |
-
}
|
3808 |
-
|
3809 |
-
// Close file
|
3810 |
-
ot_file_close( $f );
|
3811 |
-
return true;
|
3812 |
-
}
|
3813 |
-
|
3814 |
-
return false;
|
3815 |
-
|
3816 |
-
}
|
3817 |
-
|
3818 |
-
}
|
3819 |
-
|
3820 |
-
/**
|
3821 |
-
* Remove old CSS.
|
3822 |
-
*
|
3823 |
-
* Removes CSS when the textarea is empty, but still retains surrounding styles.
|
3824 |
-
*
|
3825 |
-
* @param string $field_id The CSS option field ID.
|
3826 |
-
* @return bool True on write success, false on failure.
|
3827 |
-
*
|
3828 |
-
* @access public
|
3829 |
-
* @since 2.0
|
3830 |
-
*/
|
3831 |
-
if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
3832 |
-
|
3833 |
-
function ot_remove_old_css( $field_id = '' ) {
|
3834 |
-
|
3835 |
-
/* missing $field_id string */
|
3836 |
-
if ( '' == $field_id )
|
3837 |
-
return false;
|
3838 |
-
|
3839 |
-
/* path to the dynamic.css file */
|
3840 |
-
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3841 |
-
|
3842 |
-
/* allow filter on path */
|
3843 |
-
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3844 |
-
|
3845 |
-
/* remove CSS from file */
|
3846 |
-
if ( is_writeable( $filepath ) ) {
|
3847 |
-
|
3848 |
-
/* get each line in the file */
|
3849 |
-
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3850 |
-
|
3851 |
-
/* can't write to the file return false */
|
3852 |
-
if ( ! $f = ot_file_open( $filepath, 'w' ) )
|
3853 |
-
return false;
|
3854 |
-
|
3855 |
-
$searching = true;
|
3856 |
-
|
3857 |
-
/* has array of lines */
|
3858 |
-
if ( ! empty( $markerdata ) ) {
|
3859 |
-
|
3860 |
-
/* foreach line of code */
|
3861 |
-
foreach ( $markerdata as $n => $markerline ) {
|
3862 |
-
|
3863 |
-
/* found begining of marker, set $searching to false */
|
3864 |
-
if ( $markerline == "/* BEGIN {$field_id} */" )
|
3865 |
-
$searching = false;
|
3866 |
-
|
3867 |
-
/* $searching is true, keep rewrite each line of CSS */
|
3868 |
-
if ( $searching == true ) {
|
3869 |
-
if ( $n + 1 < count( $markerdata ) )
|
3870 |
-
ot_file_write( $f, "{$markerline}\n" );
|
3871 |
-
else
|
3872 |
-
ot_file_write( $f, "{$markerline}" );
|
3873 |
-
}
|
3874 |
-
|
3875 |
-
/* found end marker delete old CSS */
|
3876 |
-
if ( $markerline == "/* END {$field_id} */" ) {
|
3877 |
-
ot_file_write( $f, "" );
|
3878 |
-
$searching = true;
|
3879 |
-
}
|
3880 |
-
|
3881 |
-
}
|
3882 |
-
|
3883 |
-
}
|
3884 |
-
|
3885 |
-
/* close file */
|
3886 |
-
ot_file_close( $f );
|
3887 |
-
return true;
|
3888 |
-
|
3889 |
-
}
|
3890 |
-
|
3891 |
-
return false;
|
3892 |
-
|
3893 |
-
}
|
3894 |
-
|
3895 |
-
}
|
3896 |
-
|
3897 |
-
/**
|
3898 |
-
* Normalize CSS
|
3899 |
-
*
|
3900 |
-
* Normalize & Convert all line-endings to UNIX format.
|
3901 |
-
*
|
3902 |
-
* @param string $css
|
3903 |
-
* @return string
|
3904 |
-
*
|
3905 |
-
* @access public
|
3906 |
-
* @since 1.1.8
|
3907 |
-
* @updated 2.0
|
3908 |
-
*/
|
3909 |
-
if ( ! function_exists( 'ot_normalize_css' ) ) {
|
3910 |
-
|
3911 |
-
function ot_normalize_css( $css ) {
|
3912 |
-
|
3913 |
-
/* Normalize & Convert */
|
3914 |
-
$css = str_replace( "\r\n", "\n", $css );
|
3915 |
-
$css = str_replace( "\r", "\n", $css );
|
3916 |
-
|
3917 |
-
/* Don't allow out-of-control blank lines */
|
3918 |
-
$css = preg_replace( "/\n{2,}/", "\n\n", $css );
|
3919 |
-
|
3920 |
-
return $css;
|
3921 |
-
}
|
3922 |
-
|
3923 |
-
}
|
3924 |
-
|
3925 |
-
/**
|
3926 |
-
* Helper function to loop over the option types.
|
3927 |
-
*
|
3928 |
-
* @param array $type The current option type.
|
3929 |
-
*
|
3930 |
-
* @return string
|
3931 |
-
*
|
3932 |
-
* @access public
|
3933 |
-
* @since 2.0
|
3934 |
-
*/
|
3935 |
-
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
|
3936 |
-
|
3937 |
-
function ot_loop_through_option_types( $type = '', $child = false ) {
|
3938 |
-
|
3939 |
-
$content = '';
|
3940 |
-
$types = ot_option_types_array();
|
3941 |
-
|
3942 |
-
if ( $child )
|
3943 |
-
unset($types['list-item']);
|
3944 |
-
|
3945 |
-
foreach( $types as $key => $value )
|
3946 |
-
$content.= '<option value="' . $key . '" ' . selected( $type, $key, false ) . '>' . $value . '</option>';
|
3947 |
-
|
3948 |
-
return $content;
|
3949 |
-
|
3950 |
-
}
|
3951 |
-
|
3952 |
-
}
|
3953 |
-
|
3954 |
-
/**
|
3955 |
-
* Helper function to loop over choices.
|
3956 |
-
*
|
3957 |
-
* @param string $name The form element name.
|
3958 |
-
* @param array $choices The array of choices.
|
3959 |
-
*
|
3960 |
-
* @return string
|
3961 |
-
*
|
3962 |
-
* @access public
|
3963 |
-
* @since 2.0
|
3964 |
-
*/
|
3965 |
-
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
|
3966 |
-
|
3967 |
-
function ot_loop_through_choices( $name, $choices = array() ) {
|
3968 |
-
|
3969 |
-
$content = '';
|
3970 |
-
|
3971 |
-
foreach( (array) $choices as $key => $choice )
|
3972 |
-
$content.= '<li class="ui-state-default list-choice">' . ot_choices_view( $name, $key, $choice ) . '</li>';
|
3973 |
-
|
3974 |
-
return $content;
|
3975 |
-
}
|
3976 |
-
|
3977 |
-
}
|
3978 |
-
|
3979 |
-
/**
|
3980 |
-
* Helper function to loop over sub settings.
|
3981 |
-
*
|
3982 |
-
* @param string $name The form element name.
|
3983 |
-
* @param array $settings The array of settings.
|
3984 |
-
*
|
3985 |
-
* @return string
|
3986 |
-
*
|
3987 |
-
* @access public
|
3988 |
-
* @since 2.0
|
3989 |
-
*/
|
3990 |
-
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
|
3991 |
-
|
3992 |
-
function ot_loop_through_sub_settings( $name, $settings = array() ) {
|
3993 |
-
|
3994 |
-
$content = '';
|
3995 |
-
|
3996 |
-
foreach( $settings as $key => $setting )
|
3997 |
-
$content.= '<li class="ui-state-default list-sub-setting">' . ot_settings_view( $name, $key, $setting ) . '</li>';
|
3998 |
-
|
3999 |
-
return $content;
|
4000 |
-
}
|
4001 |
-
|
4002 |
-
}
|
4003 |
-
|
4004 |
-
/**
|
4005 |
-
* Helper function to display sections.
|
4006 |
-
*
|
4007 |
-
* This function is used in AJAX to add a new section
|
4008 |
-
* and when section have already been added and saved.
|
4009 |
-
*
|
4010 |
-
* @param int $key The array key for the current element.
|
4011 |
-
* @param array An array of values for the current section.
|
4012 |
-
*
|
4013 |
-
* @return void
|
4014 |
-
*
|
4015 |
-
* @access public
|
4016 |
-
* @since 2.0
|
4017 |
-
*/
|
4018 |
-
if ( ! function_exists( 'ot_sections_view' ) ) {
|
4019 |
-
|
4020 |
-
function ot_sections_view( $name, $key, $section = array() ) {
|
4021 |
-
|
4022 |
-
return '
|
4023 |
-
<div class="option-tree-setting is-section">
|
4024 |
-
<div class="open">' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( $key + 1 ) ) . '</div>
|
4025 |
-
<div class="button-section">
|
4026 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'edit', 'option-tree' ) . '">
|
4027 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4028 |
-
</a>
|
4029 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4030 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4031 |
-
</a>
|
4032 |
-
</div>
|
4033 |
-
<div class="option-tree-setting-body">
|
4034 |
-
<div class="format-settings">
|
4035 |
-
<div class="format-setting type-text">
|
4036 |
-
<div class="description">' . __( '<strong>Section Title</strong>: Displayed as a menu item on the Theme Options page.', 'option-tree' ) . '</div>
|
4037 |
-
<div class="format-setting-inner">
|
4038 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title section-title" autocomplete="off" />
|
4039 |
-
</div>
|
4040 |
-
</div>
|
4041 |
-
</div>
|
4042 |
-
<div class="format-settings">
|
4043 |
-
<div class="format-setting type-text">
|
4044 |
-
<div class="description">' . __( '<strong>Section ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
|
4045 |
-
<div class="format-setting-inner">
|
4046 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $section['id'] ) ? esc_attr( $section['id'] ) : '' ) . '" class="widefat option-tree-ui-input section-id" autocomplete="off" />
|
4047 |
-
</div>
|
4048 |
-
</div>
|
4049 |
-
</div>
|
4050 |
-
</div>
|
4051 |
-
</div>';
|
4052 |
-
|
4053 |
-
}
|
4054 |
-
|
4055 |
-
}
|
4056 |
-
|
4057 |
-
/**
|
4058 |
-
* Helper function to display settings.
|
4059 |
-
*
|
4060 |
-
* This function is used in AJAX to add a new setting
|
4061 |
-
* and when settings have already been added and saved.
|
4062 |
-
*
|
4063 |
-
* @param int $key The array key for the current element.
|
4064 |
-
* @param array An array of values for the current section.
|
4065 |
-
*
|
4066 |
-
* @return void
|
4067 |
-
*
|
4068 |
-
* @access public
|
4069 |
-
* @since 2.0
|
4070 |
-
*/
|
4071 |
-
if ( ! function_exists( 'ot_settings_view' ) ) {
|
4072 |
-
|
4073 |
-
function ot_settings_view( $name, $key, $setting = array() ) {
|
4074 |
-
|
4075 |
-
$child = ( strpos( $name, '][settings]') !== false ) ? true : false;
|
4076 |
-
$type = isset( $setting['type'] ) ? $setting['type'] : '';
|
4077 |
-
$std = isset( $setting['std'] ) ? $setting['std'] : '';
|
4078 |
-
$operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
|
4079 |
-
|
4080 |
-
// Serialize the standard value just incase
|
4081 |
-
if ( is_array( $std ) ) {
|
4082 |
-
$std = maybe_serialize( $std );
|
4083 |
-
}
|
4084 |
-
|
4085 |
-
if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ) ) ) {
|
4086 |
-
$std_form_element = '<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]">' . esc_html( $std ) . '</textarea>';
|
4087 |
-
} else {
|
4088 |
-
$std_form_element = '<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]" value="' . esc_attr( $std ) . '" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4089 |
-
}
|
4090 |
-
|
4091 |
-
return '
|
4092 |
-
<div class="option-tree-setting">
|
4093 |
-
<div class="open">' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( $key + 1 ) ) . '</div>
|
4094 |
-
<div class="button-section">
|
4095 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4096 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4097 |
-
</a>
|
4098 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4099 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4100 |
-
</a>
|
4101 |
-
</div>
|
4102 |
-
<div class="option-tree-setting-body">
|
4103 |
-
<div class="format-settings">
|
4104 |
-
<div class="format-setting type-text wide-desc">
|
4105 |
-
<div class="description">' . __( '<strong>Label</strong>: Displayed as the label of a form element on the Theme Options page.', 'option-tree' ) . '</div>
|
4106 |
-
<div class="format-setting-inner">
|
4107 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][label]" value="' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4108 |
-
</div>
|
4109 |
-
</div>
|
4110 |
-
</div>
|
4111 |
-
<div class="format-settings">
|
4112 |
-
<div class="format-setting type-text wide-desc">
|
4113 |
-
<div class="description">' . __( '<strong>ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
|
4114 |
-
<div class="format-setting-inner">
|
4115 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $setting['id'] ) ? esc_attr( $setting['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4116 |
-
</div>
|
4117 |
-
</div>
|
4118 |
-
</div>
|
4119 |
-
<div class="format-settings">
|
4120 |
-
<div class="format-setting type-select wide-desc">
|
4121 |
-
<div class="description">' . __( '<strong>Type</strong>: Choose one of the available option types from the dropdown.', 'option-tree' ) . '</div>
|
4122 |
-
<div class="format-setting-inner">
|
4123 |
-
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][type]" value="' . esc_attr( $type ) . '" class="option-tree-ui-select">
|
4124 |
-
' . ot_loop_through_option_types( $type, $child ) . '
|
4125 |
-
|
4126 |
-
</select>
|
4127 |
-
</div>
|
4128 |
-
</div>
|
4129 |
-
</div>
|
4130 |
-
<div class="format-settings">
|
4131 |
-
<div class="format-setting type-textarea wide-desc">
|
4132 |
-
<div class="description">' . __( '<strong>Description</strong>: Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '</div>
|
4133 |
-
<div class="format-setting-inner">
|
4134 |
-
<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][desc]">' . ( isset( $setting['desc'] ) ? esc_html( $setting['desc'] ) : '' ) . '</textarea>
|
4135 |
-
</div>
|
4136 |
-
</div>
|
4137 |
-
</div>
|
4138 |
-
<div class="format-settings">
|
4139 |
-
<div class="format-setting type-textblock wide-desc">
|
4140 |
-
<div class="description">' . __( '<strong>Choices</strong>: This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '</div>
|
4141 |
-
<div class="format-setting-inner">
|
4142 |
-
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4143 |
-
' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . '
|
4144 |
-
</ul>
|
4145 |
-
<a href="javascript:void(0);" class="option-tree-choice-add option-tree-ui-button button hug-left">' . __( 'Add Choice', 'option-tree' ) . '</a>
|
4146 |
-
</div>
|
4147 |
-
</div>
|
4148 |
-
</div>
|
4149 |
-
<div class="format-settings">
|
4150 |
-
<div class="format-setting type-textblock wide-desc">
|
4151 |
-
<div class="description">' . __( '<strong>Settings</strong>: This will only affect the List Item option type.', 'option-tree' ) . '</div>
|
4152 |
-
<div class="format-setting-inner">
|
4153 |
-
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4154 |
-
' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . '
|
4155 |
-
</ul>
|
4156 |
-
<a href="javascript:void(0);" class="option-tree-list-item-setting-add option-tree-ui-button button hug-left">' . __( 'Add Setting', 'option-tree' ) . '</a>
|
4157 |
-
</div>
|
4158 |
-
</div>
|
4159 |
-
</div>
|
4160 |
-
<div class="format-settings">
|
4161 |
-
<div class="format-setting type-text wide-desc">
|
4162 |
-
<div class="description">' . __( '<strong>Standard</strong>: Setting the standard value for your option only works for some option types. Read the <code>OptionTree->Documentation</code> for more information on which ones.', 'option-tree' ) . '</div>
|
4163 |
-
<div class="format-setting-inner">
|
4164 |
-
' . $std_form_element . '
|
4165 |
-
</div>
|
4166 |
-
</div>
|
4167 |
-
</div>
|
4168 |
-
<div class="format-settings">
|
4169 |
-
<div class="format-setting type-text wide-desc">
|
4170 |
-
<div class="description">' . __( '<strong>Rows</strong>: Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '</div>
|
4171 |
-
<div class="format-setting-inner">
|
4172 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][rows]" value="' . ( isset( $setting['rows'] ) ? esc_attr( $setting['rows'] ) : '' ) . '" class="widefat option-tree-ui-input" />
|
4173 |
-
</div>
|
4174 |
-
</div>
|
4175 |
-
</div>
|
4176 |
-
<div class="format-settings">
|
4177 |
-
<div class="format-setting type-text wide-desc">
|
4178 |
-
<div class="description">' . __( '<strong>Post Type</strong>: Add a comma separated list of post type like \'post,page\'. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select.', 'option-tree' ) . '</div>
|
4179 |
-
<div class="format-setting-inner">
|
4180 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][post_type]" value="' . ( isset( $setting['post_type'] ) ? esc_attr( $setting['post_type'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4181 |
-
</div>
|
4182 |
-
</div>
|
4183 |
-
</div>
|
4184 |
-
<div class="format-settings">
|
4185 |
-
<div class="format-setting type-text wide-desc">
|
4186 |
-
<div class="description">' . __( '<strong>Taxonomy</strong>: Add a comma separated list of any registered taxonomy like \'category,post_tag\'. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ) . '</div>
|
4187 |
-
<div class="format-setting-inner">
|
4188 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][taxonomy]" value="' . ( isset( $setting['taxonomy'] ) ? esc_attr( $setting['taxonomy'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4189 |
-
</div>
|
4190 |
-
</div>
|
4191 |
-
</div>
|
4192 |
-
<div class="format-settings">
|
4193 |
-
<div class="format-setting type-text wide-desc">
|
4194 |
-
<div class="description">' . __( '<strong>Min, Max, & Step</strong>: Add a comma separated list of options in the following format <code>0,100,1</code> (slide from <code>0-100</code> in intervals of <code>1</code>). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' ) . '</div>
|
4195 |
-
<div class="format-setting-inner">
|
4196 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][min_max_step]" value="' . ( isset( $setting['min_max_step'] ) ? esc_attr( $setting['min_max_step'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4197 |
-
</div>
|
4198 |
-
</div>
|
4199 |
-
</div>
|
4200 |
-
<div class="format-settings">
|
4201 |
-
<div class="format-setting type-text wide-desc">
|
4202 |
-
<div class="description">' . __( '<strong>CSS Class</strong>: Add and optional class to this option type.', 'option-tree' ) . '</div>
|
4203 |
-
<div class="format-setting-inner">
|
4204 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][class]" value="' . ( isset( $setting['class'] ) ? esc_attr( $setting['class'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4205 |
-
</div>
|
4206 |
-
</div>
|
4207 |
-
</div>
|
4208 |
-
<div class="format-settings">
|
4209 |
-
<div class="format-setting type-text wide-desc">
|
4210 |
-
<div class="description">' . sprintf( __( '<strong>Condition</strong>: Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, <code>value</code> is a placeholder for your condition, which can be in the form of %s.', 'option-tree' ), '<code>field_id:is(value)</code>, <code>field_id:not(value)</code>, <code>field_id:contains(value)</code>, <code>field_id:less_than(value)</code>, <code>field_id:less_than_or_equal_to(value)</code>, <code>field_id:greater_than(value)</code>, or <code>field_id:greater_than_or_equal_to(value)</code>' ) . '</div>
|
4211 |
-
<div class="format-setting-inner">
|
4212 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][condition]" value="' . ( isset( $setting['condition'] ) ? esc_attr( $setting['condition'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4213 |
-
</div>
|
4214 |
-
</div>
|
4215 |
-
</div>
|
4216 |
-
<div class="format-settings">
|
4217 |
-
<div class="format-setting type-select wide-desc">
|
4218 |
-
<div class="description">' . __( '<strong>Operator</strong>: Choose the logical operator to compute the result of the conditions.', 'option-tree' ) . '</div>
|
4219 |
-
<div class="format-setting-inner">
|
4220 |
-
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][operator]" value="' . $operator . '" class="option-tree-ui-select">
|
4221 |
-
<option value="and" ' . selected( $operator, 'and', false ) . '>' . __( 'and', 'option-tree' ) . '</option>
|
4222 |
-
<option value="or" ' . selected( $operator, 'or', false ) . '>' . __( 'or', 'option-tree' ) . '</option>
|
4223 |
-
</select>
|
4224 |
-
</div>
|
4225 |
-
</div>
|
4226 |
-
</div>
|
4227 |
-
</div>
|
4228 |
-
</div>
|
4229 |
-
' . ( ! $child ? '<input type="hidden" class="hidden-section" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][section]" value="' . ( isset( $setting['section'] ) ? esc_attr( $setting['section'] ) : '' ) . '" />' : '' );
|
4230 |
-
|
4231 |
-
}
|
4232 |
-
|
4233 |
-
}
|
4234 |
-
|
4235 |
-
/**
|
4236 |
-
* Helper function to display setting choices.
|
4237 |
-
*
|
4238 |
-
* This function is used in AJAX to add a new choice
|
4239 |
-
* and when choices have already been added and saved.
|
4240 |
-
*
|
4241 |
-
* @param string $name The form element name.
|
4242 |
-
* @param array $key The array key for the current element.
|
4243 |
-
* @param array An array of values for the current choice.
|
4244 |
-
*
|
4245 |
-
* @return void
|
4246 |
-
*
|
4247 |
-
* @access public
|
4248 |
-
* @since 2.0
|
4249 |
-
*/
|
4250 |
-
if ( ! function_exists( 'ot_choices_view' ) ) {
|
4251 |
-
|
4252 |
-
function ot_choices_view( $name, $key, $choice = array() ) {
|
4253 |
-
|
4254 |
-
return '
|
4255 |
-
<div class="option-tree-setting">
|
4256 |
-
<div class="open">' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( $key + 1 ) ) . '</div>
|
4257 |
-
<div class="button-section">
|
4258 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4259 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4260 |
-
</a>
|
4261 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4262 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4263 |
-
</a>
|
4264 |
-
</div>
|
4265 |
-
<div class="option-tree-setting-body">
|
4266 |
-
<div class="format-settings">
|
4267 |
-
<div class="format-setting-label">
|
4268 |
-
<h5>' . __( 'Label', 'option-tree' ) . '</h5>
|
4269 |
-
</div>
|
4270 |
-
<div class="format-setting type-text wide-desc">
|
4271 |
-
<div class="format-setting-inner">
|
4272 |
-
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][label]" value="' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4273 |
-
</div>
|
4274 |
-
</div>
|
4275 |
-
</div>
|
4276 |
-
<div class="format-settings">
|
4277 |
-
<div class="format-setting-label">
|
4278 |
-
<h5>' . __( 'Value', 'option-tree' ) . '</h5>
|
4279 |
-
</div>
|
4280 |
-
<div class="format-setting type-text wide-desc">
|
4281 |
-
<div class="format-setting-inner">
|
4282 |
-
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][value]" value="' . ( isset( $choice['value'] ) ? esc_attr( $choice['value'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4283 |
-
</div>
|
4284 |
-
</div>
|
4285 |
-
</div>
|
4286 |
-
<div class="format-settings">
|
4287 |
-
<div class="format-setting-label">
|
4288 |
-
<h5>' . __( 'Image Source (Radio Image only)', 'option-tree' ) . '</h5>
|
4289 |
-
</div>
|
4290 |
-
<div class="format-setting type-text wide-desc">
|
4291 |
-
<div class="format-setting-inner">
|
4292 |
-
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][src]" value="' . ( isset( $choice['src'] ) ? esc_attr( $choice['src'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4293 |
-
</div>
|
4294 |
-
</div>
|
4295 |
-
</div>
|
4296 |
-
</div>';
|
4297 |
-
|
4298 |
-
}
|
4299 |
-
|
4300 |
-
}
|
4301 |
-
|
4302 |
-
/**
|
4303 |
-
* Helper function to display sections.
|
4304 |
-
*
|
4305 |
-
* This function is used in AJAX to add a new section
|
4306 |
-
* and when section have already been added and saved.
|
4307 |
-
*
|
4308 |
-
* @param int $key The array key for the current element.
|
4309 |
-
* @param array An array of values for the current section.
|
4310 |
-
*
|
4311 |
-
* @return void
|
4312 |
-
*
|
4313 |
-
* @access public
|
4314 |
-
* @since 2.0
|
4315 |
-
*/
|
4316 |
-
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
|
4317 |
-
|
4318 |
-
function ot_contextual_help_view( $name, $key, $content = array() ) {
|
4319 |
-
|
4320 |
-
return '
|
4321 |
-
<div class="option-tree-setting">
|
4322 |
-
<div class="open">' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( $key + 1 ) ) . '</div>
|
4323 |
-
<div class="button-section">
|
4324 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4325 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4326 |
-
</a>
|
4327 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4328 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4329 |
-
</a>
|
4330 |
-
</div>
|
4331 |
-
<div class="option-tree-setting-body">
|
4332 |
-
<div class="format-settings">
|
4333 |
-
<div class="format-setting type-text no-desc">
|
4334 |
-
<div class="description">' . __( '<strong>Title</strong>: Displayed as a contextual help menu item on the Theme Options page.', 'option-tree' ) . '</div>
|
4335 |
-
<div class="format-setting-inner">
|
4336 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4337 |
-
</div>
|
4338 |
-
</div>
|
4339 |
-
</div>
|
4340 |
-
<div class="format-settings">
|
4341 |
-
<div class="format-setting type-text no-desc">
|
4342 |
-
<div class="description">' . __( '<strong>ID</strong>: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '</div>
|
4343 |
-
<div class="format-setting-inner">
|
4344 |
-
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $content['id'] ) ? esc_attr( $content['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4345 |
-
</div>
|
4346 |
-
</div>
|
4347 |
-
</div>
|
4348 |
-
<div class="format-settings">
|
4349 |
-
<div class="format-setting type-textarea no-desc">
|
4350 |
-
<div class="description">' . __( '<strong>Content</strong>: Enter the HTML content about this contextual help item displayed on the Theme Option page for end users to read.', 'option-tree' ) . '</div>
|
4351 |
-
<div class="format-setting-inner">
|
4352 |
-
<textarea class="textarea" rows="15" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][content]">' . ( isset( $content['content'] ) ? esc_html( $content['content'] ) : '' ) . '</textarea>
|
4353 |
-
</div>
|
4354 |
-
</div>
|
4355 |
-
</div>
|
4356 |
-
</div>
|
4357 |
-
</div>';
|
4358 |
-
|
4359 |
-
}
|
4360 |
-
|
4361 |
-
}
|
4362 |
-
|
4363 |
-
/**
|
4364 |
-
* Helper function to display sections.
|
4365 |
-
*
|
4366 |
-
* @param string $key
|
4367 |
-
* @param string $data
|
4368 |
-
* @param string $active_layout
|
4369 |
-
*
|
4370 |
-
* @return void
|
4371 |
-
*
|
4372 |
-
* @access public
|
4373 |
-
* @since 2.0
|
4374 |
-
*/
|
4375 |
-
if ( ! function_exists( 'ot_layout_view' ) ) {
|
4376 |
-
|
4377 |
-
function ot_layout_view( $key, $data = '', $active_layout = '' ) {
|
4378 |
-
|
4379 |
-
return '
|
4380 |
-
<div class="option-tree-setting">
|
4381 |
-
<div class="open">' . ( isset( $key ) ? esc_attr( $key ) : __( 'Layout', 'option-tree' ) ) . '</div>
|
4382 |
-
<div class="button-section">
|
4383 |
-
<a href="javascript:void(0);" class="option-tree-layout-activate option-tree-ui-button button left-item' . ( $active_layout == $key ? ' active' : '' ) . '" title="' . __( 'Activate', 'option-tree' ) . '">
|
4384 |
-
<span class="icon ot-icon-square-o"></span>' . __( 'Activate', 'option-tree' ) . '
|
4385 |
-
</a>
|
4386 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="'. __( 'Delete', 'option-tree' ) . '">
|
4387 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4388 |
-
</a>
|
4389 |
-
</div>
|
4390 |
-
<input type="hidden" name="' . ot_layouts_id() . '[' . esc_attr( $key ) . ']" value="' . $data . '" />
|
4391 |
-
</div>';
|
4392 |
-
|
4393 |
-
}
|
4394 |
-
|
4395 |
-
}
|
4396 |
-
|
4397 |
-
/**
|
4398 |
-
* Helper function to display list items.
|
4399 |
-
*
|
4400 |
-
* This function is used in AJAX to add a new list items
|
4401 |
-
* and when they have already been added and saved.
|
4402 |
-
*
|
4403 |
-
* @param string $name The form field name.
|
4404 |
-
* @param int $key The array key for the current element.
|
4405 |
-
* @param array An array of values for the current list item.
|
4406 |
-
*
|
4407 |
-
* @return void
|
4408 |
-
*
|
4409 |
-
* @access public
|
4410 |
-
* @since 2.0
|
4411 |
-
*/
|
4412 |
-
if ( ! function_exists( 'ot_list_item_view' ) ) {
|
4413 |
-
|
4414 |
-
function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
4415 |
-
|
4416 |
-
/* required title setting */
|
4417 |
-
$required_setting = array(
|
4418 |
-
array(
|
4419 |
-
'id' => 'title',
|
4420 |
-
'label' => __( 'Title', 'option-tree' ),
|
4421 |
-
'desc' => '',
|
4422 |
-
'std' => '',
|
4423 |
-
'type' => 'text',
|
4424 |
-
'rows' => '',
|
4425 |
-
'class' => 'option-tree-setting-title',
|
4426 |
-
'post_type' => '',
|
4427 |
-
'choices' => array()
|
4428 |
-
)
|
4429 |
-
);
|
4430 |
-
|
4431 |
-
/* load the old filterable slider settings */
|
4432 |
-
if ( 'slider' == $type ) {
|
4433 |
-
|
4434 |
-
$settings = ot_slider_settings( $name );
|
4435 |
-
|
4436 |
-
}
|
4437 |
-
|
4438 |
-
/* if no settings array load the filterable list item settings */
|
4439 |
-
if ( empty( $settings ) ) {
|
4440 |
-
|
4441 |
-
$settings = ot_list_item_settings( $name );
|
4442 |
-
|
4443 |
-
}
|
4444 |
-
|
4445 |
-
/* merge the two settings array */
|
4446 |
-
$settings = array_merge( $required_setting, $settings );
|
4447 |
-
|
4448 |
-
echo '
|
4449 |
-
<div class="option-tree-setting">
|
4450 |
-
<div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
|
4451 |
-
<div class="button-section">
|
4452 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4453 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4454 |
-
</a>
|
4455 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4456 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4457 |
-
</a>
|
4458 |
-
</div>
|
4459 |
-
<div class="option-tree-setting-body">';
|
4460 |
-
|
4461 |
-
foreach( $settings as $field ) {
|
4462 |
-
|
4463 |
-
// Set field value
|
4464 |
-
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
4465 |
-
|
4466 |
-
/* set default to standard value */
|
4467 |
-
if ( isset( $field['std'] ) ) {
|
4468 |
-
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4469 |
-
}
|
4470 |
-
|
4471 |
-
// filter the title label and description
|
4472 |
-
if ( $field['id'] == 'title' ) {
|
4473 |
-
|
4474 |
-
// filter the label
|
4475 |
-
$field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name );
|
4476 |
-
|
4477 |
-
// filter the description
|
4478 |
-
$field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name );
|
4479 |
-
|
4480 |
-
}
|
4481 |
-
|
4482 |
-
/* make life easier */
|
4483 |
-
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4484 |
-
|
4485 |
-
/* build the arguments array */
|
4486 |
-
$_args = array(
|
4487 |
-
'type' => $field['type'],
|
4488 |
-
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4489 |
-
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4490 |
-
'field_value' => $field_value,
|
4491 |
-
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4492 |
-
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4493 |
-
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4494 |
-
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4495 |
-
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4496 |
-
'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4497 |
-
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4498 |
-
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4499 |
-
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4500 |
-
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4501 |
-
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4502 |
-
'post_id' => $post_id,
|
4503 |
-
'get_option' => $get_option
|
4504 |
-
);
|
4505 |
-
|
4506 |
-
$conditions = '';
|
4507 |
-
|
4508 |
-
/* setup the conditions */
|
4509 |
-
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4510 |
-
|
4511 |
-
/* doing magic on the conditions so they work in a list item */
|
4512 |
-
$conditionals = explode( ',', $field['condition'] );
|
4513 |
-
foreach( $conditionals as $condition ) {
|
4514 |
-
$parts = explode( ':', $condition );
|
4515 |
-
if ( isset( $parts[0] ) ) {
|
4516 |
-
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4517 |
-
}
|
4518 |
-
}
|
4519 |
-
|
4520 |
-
$conditions = ' data-condition="' . $field['condition'] . '"';
|
4521 |
-
$conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
|
4522 |
-
|
4523 |
-
}
|
4524 |
-
|
4525 |
-
// Build the setting CSS class
|
4526 |
-
if ( ! empty( $_args['field_class'] ) ) {
|
4527 |
-
|
4528 |
-
$classes = explode( ' ', $_args['field_class'] );
|
4529 |
-
|
4530 |
-
foreach( $classes as $_key => $value ) {
|
4531 |
-
|
4532 |
-
$classes[$_key] = $value . '-wrap';
|
4533 |
-
|
4534 |
-
}
|
4535 |
-
|
4536 |
-
$class = 'format-settings ' . implode( ' ', $classes );
|
4537 |
-
|
4538 |
-
} else {
|
4539 |
-
|
4540 |
-
$class = 'format-settings';
|
4541 |
-
|
4542 |
-
}
|
4543 |
-
|
4544 |
-
/* option label */
|
4545 |
-
echo '<div id="setting_' . $_args['field_id'] . '" class="' . $class . '"' . $conditions . '>';
|
4546 |
-
|
4547 |
-
/* don't show title with textblocks */
|
4548 |
-
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
4549 |
-
echo '<div class="format-setting-label">';
|
4550 |
-
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4551 |
-
echo '</div>';
|
4552 |
-
}
|
4553 |
-
|
4554 |
-
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
4555 |
-
if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' )
|
4556 |
-
$_args['type'] = 'textarea-simple';
|
4557 |
-
|
4558 |
-
/* option body, list-item is not allowed inside another list-item */
|
4559 |
-
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' ) {
|
4560 |
-
echo ot_display_by_type( $_args );
|
4561 |
-
}
|
4562 |
-
|
4563 |
-
echo '</div>';
|
4564 |
-
|
4565 |
-
}
|
4566 |
-
|
4567 |
-
echo '</div>';
|
4568 |
-
|
4569 |
-
echo '</div>';
|
4570 |
-
|
4571 |
-
}
|
4572 |
-
|
4573 |
-
}
|
4574 |
-
|
4575 |
-
/**
|
4576 |
-
* Helper function to display social links.
|
4577 |
-
*
|
4578 |
-
* This function is used in AJAX to add a new list items
|
4579 |
-
* and when they have already been added and saved.
|
4580 |
-
*
|
4581 |
-
* @param string $name The form field name.
|
4582 |
-
* @param int $key The array key for the current element.
|
4583 |
-
* @param array An array of values for the current list item.
|
4584 |
-
*
|
4585 |
-
* @return void
|
4586 |
-
*
|
4587 |
-
* @access public
|
4588 |
-
* @since 2.4.0
|
4589 |
-
*/
|
4590 |
-
if ( ! function_exists( 'ot_social_links_view' ) ) {
|
4591 |
-
|
4592 |
-
function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
4593 |
-
|
4594 |
-
/* if no settings array load the filterable social links settings */
|
4595 |
-
if ( empty( $settings ) ) {
|
4596 |
-
|
4597 |
-
$settings = ot_social_links_settings( $name );
|
4598 |
-
|
4599 |
-
}
|
4600 |
-
|
4601 |
-
echo '
|
4602 |
-
<div class="option-tree-setting">
|
4603 |
-
<div class="open">' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '</div>
|
4604 |
-
<div class="button-section">
|
4605 |
-
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . __( 'Edit', 'option-tree' ) . '">
|
4606 |
-
<span class="icon ot-icon-pencil"></span>' . __( 'Edit', 'option-tree' ) . '
|
4607 |
-
</a>
|
4608 |
-
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . __( 'Delete', 'option-tree' ) . '">
|
4609 |
-
<span class="icon ot-icon-trash-o"></span>' . __( 'Delete', 'option-tree' ) . '
|
4610 |
-
</a>
|
4611 |
-
</div>
|
4612 |
-
<div class="option-tree-setting-body">';
|
4613 |
-
|
4614 |
-
foreach( $settings as $field ) {
|
4615 |
-
|
4616 |
-
// Set field value
|
4617 |
-
$field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : '';
|
4618 |
-
|
4619 |
-
/* set default to standard value */
|
4620 |
-
if ( isset( $field['std'] ) ) {
|
4621 |
-
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4622 |
-
}
|
4623 |
-
|
4624 |
-
/* make life easier */
|
4625 |
-
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4626 |
-
|
4627 |
-
/* build the arguments array */
|
4628 |
-
$_args = array(
|
4629 |
-
'type' => $field['type'],
|
4630 |
-
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4631 |
-
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4632 |
-
'field_value' => $field_value,
|
4633 |
-
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4634 |
-
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4635 |
-
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4636 |
-
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4637 |
-
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4638 |
-
'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4639 |
-
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4640 |
-
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4641 |
-
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4642 |
-
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4643 |
-
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4644 |
-
'post_id' => $post_id,
|
4645 |
-
'get_option' => $get_option
|
4646 |
-
);
|
4647 |
-
|
4648 |
-
$conditions = '';
|
4649 |
-
|
4650 |
-
/* setup the conditions */
|
4651 |
-
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4652 |
-
|
4653 |
-
/* doing magic on the conditions so they work in a list item */
|
4654 |
-
$conditionals = explode( ',', $field['condition'] );
|
4655 |
-
foreach( $conditionals as $condition ) {
|
4656 |
-
$parts = explode( ':', $condition );
|
4657 |
-
if ( isset( $parts[0] ) ) {
|
4658 |
-
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4659 |
-
}
|
4660 |
-
}
|
4661 |
-
|
4662 |
-
$conditions = ' data-condition="' . $field['condition'] . '"';
|
4663 |
-
$conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
|
4664 |
-
|
4665 |
-
}
|
4666 |
-
|
4667 |
-
/* option label */
|
4668 |
-
echo '<div id="setting_' . $_args['field_id'] . '" class="format-settings"' . $conditions . '>';
|
4669 |
-
|
4670 |
-
/* don't show title with textblocks */
|
4671 |
-
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
4672 |
-
echo '<div class="format-setting-label">';
|
4673 |
-
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4674 |
-
echo '</div>';
|
4675 |
-
}
|
4676 |
-
|
4677 |
-
/* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */
|
4678 |
-
if ( $_args['type'] == 'textarea' )
|
4679 |
-
$_args['type'] = 'textarea-simple';
|
4680 |
-
|
4681 |
-
/* option body, list-item is not allowed inside another list-item */
|
4682 |
-
if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' && $_args['type'] !== 'social-links' ) {
|
4683 |
-
echo ot_display_by_type( $_args );
|
4684 |
-
}
|
4685 |
-
|
4686 |
-
echo '</div>';
|
4687 |
-
|
4688 |
-
}
|
4689 |
-
|
4690 |
-
echo '</div>';
|
4691 |
-
|
4692 |
-
echo '</div>';
|
4693 |
-
|
4694 |
-
}
|
4695 |
-
|
4696 |
-
}
|
4697 |
-
|
4698 |
-
/**
|
4699 |
-
* Helper function to display Theme Options layouts form.
|
4700 |
-
*
|
4701 |
-
* @return string
|
4702 |
-
*
|
4703 |
-
* @access public
|
4704 |
-
* @since 2.0
|
4705 |
-
*/
|
4706 |
-
if ( ! function_exists( 'ot_theme_options_layouts_form' ) ) {
|
4707 |
-
|
4708 |
-
function ot_theme_options_layouts_form( $active = false ) {
|
4709 |
-
|
4710 |
-
echo '<form method="post" id="option-tree-options-layouts-form">';
|
4711 |
-
|
4712 |
-
/* form nonce */
|
4713 |
-
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
4714 |
-
|
4715 |
-
/* get the saved layouts */
|
4716 |
-
$layouts = get_option( ot_layouts_id() );
|
4717 |
-
|
4718 |
-
/* set active layout */
|
4719 |
-
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
4720 |
-
|
4721 |
-
if ( is_array( $layouts ) && count( $layouts ) > 1 ) {
|
4722 |
-
|
4723 |
-
$active_layout = esc_attr( $layouts['active_layout'] );
|
4724 |
-
|
4725 |
-
echo '<input type="hidden" id="the_current_layout" value="' . $active_layout . '" />';
|
4726 |
-
|
4727 |
-
echo '<div class="option-tree-active-layout">';
|
4728 |
-
|
4729 |
-
echo '<select name="' . ot_layouts_id() . '[active_layout]" class="option-tree-ui-select">';
|
4730 |
-
|
4731 |
-
foreach( $layouts as $key => $data ) {
|
4732 |
-
|
4733 |
-
if ( $key == 'active_layout' )
|
4734 |
-
continue;
|
4735 |
-
|
4736 |
-
echo '<option' . selected( $key, $active_layout, false ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $key ) . '</option>';
|
4737 |
-
}
|
4738 |
-
|
4739 |
-
echo '</select>';
|
4740 |
-
|
4741 |
-
echo '</div>';
|
4742 |
-
|
4743 |
-
foreach( $layouts as $key => $data ) {
|
4744 |
-
|
4745 |
-
if ( $key == 'active_layout' )
|
4746 |
-
continue;
|
4747 |
-
|
4748 |
-
echo '<input type="hidden" name="' . ot_layouts_id() . '[' . $key . ']" value="' . ( isset( $data ) ? $data : '' ) . '" />';
|
4749 |
-
|
4750 |
-
}
|
4751 |
-
|
4752 |
-
}
|
4753 |
-
|
4754 |
-
/* new layout wrapper */
|
4755 |
-
echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
|
4756 |
-
|
4757 |
-
/* add new layout */
|
4758 |
-
echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4759 |
-
|
4760 |
-
echo '<button type="submit" class="option-tree-ui-button button button-primary save-layout" title="' . __( 'New Layout', 'option-tree' ) . '">' . __( 'New Layout', 'option-tree' ) . '</button>';
|
4761 |
-
|
4762 |
-
echo '</div>';
|
4763 |
-
|
4764 |
-
echo '</form>';
|
4765 |
-
|
4766 |
-
}
|
4767 |
-
|
4768 |
-
}
|
4769 |
-
|
4770 |
-
/**
|
4771 |
-
* Helper function to validate option ID's
|
4772 |
-
*
|
4773 |
-
* @param string $input The string to sanitize.
|
4774 |
-
* @return string
|
4775 |
-
*
|
4776 |
-
* @access public
|
4777 |
-
* @since 2.0
|
4778 |
-
*/
|
4779 |
-
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
|
4780 |
-
|
4781 |
-
function ot_sanitize_option_id( $input ) {
|
4782 |
-
|
4783 |
-
return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
|
4784 |
-
|
4785 |
-
}
|
4786 |
-
|
4787 |
-
}
|
4788 |
-
|
4789 |
-
/**
|
4790 |
-
* Helper function to validate layout ID's
|
4791 |
-
*
|
4792 |
-
* @param string $input The string to sanitize.
|
4793 |
-
* @return string
|
4794 |
-
*
|
4795 |
-
* @access public
|
4796 |
-
* @since 2.0
|
4797 |
-
*/
|
4798 |
-
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
|
4799 |
-
|
4800 |
-
function ot_sanitize_layout_id( $input ) {
|
4801 |
-
|
4802 |
-
return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
|
4803 |
-
|
4804 |
-
}
|
4805 |
-
|
4806 |
-
}
|
4807 |
-
|
4808 |
-
/**
|
4809 |
-
* Convert choices array to string
|
4810 |
-
*
|
4811 |
-
* @return string
|
4812 |
-
*
|
4813 |
-
* @access public
|
4814 |
-
* @since 2.0
|
4815 |
-
*/
|
4816 |
-
if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
|
4817 |
-
|
4818 |
-
function ot_convert_array_to_string( $input ) {
|
4819 |
-
|
4820 |
-
if ( is_array( $input ) ) {
|
4821 |
-
|
4822 |
-
foreach( $input as $k => $choice ) {
|
4823 |
-
$choices[$k] = $choice['value'] . '|' . $choice['label'];
|
4824 |
-
|
4825 |
-
if ( isset( $choice['src'] ) )
|
4826 |
-
$choices[$k].= '|' . $choice['src'];
|
4827 |
-
|
4828 |
-
}
|
4829 |
-
|
4830 |
-
return implode( ',', $choices );
|
4831 |
-
}
|
4832 |
-
|
4833 |
-
return false;
|
4834 |
-
}
|
4835 |
-
}
|
4836 |
-
|
4837 |
-
/**
|
4838 |
-
* Convert choices string to array
|
4839 |
-
*
|
4840 |
-
* @return array
|
4841 |
-
*
|
4842 |
-
* @access public
|
4843 |
-
* @since 2.0
|
4844 |
-
*/
|
4845 |
-
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
|
4846 |
-
|
4847 |
-
function ot_convert_string_to_array( $input ) {
|
4848 |
-
|
4849 |
-
if ( '' !== $input ) {
|
4850 |
-
|
4851 |
-
/* empty choices array */
|
4852 |
-
$choices = array();
|
4853 |
-
|
4854 |
-
/* exlode the string into an array */
|
4855 |
-
foreach( explode( ',', $input ) as $k => $choice ) {
|
4856 |
-
|
4857 |
-
/* if ":" is splitting the string go deeper */
|
4858 |
-
if ( preg_match( '/\|/', $choice ) ) {
|
4859 |
-
$split = explode( '|', $choice );
|
4860 |
-
$choices[$k]['value'] = trim( $split[0] );
|
4861 |
-
$choices[$k]['label'] = trim( $split[1] );
|
4862 |
-
|
4863 |
-
/* if radio image there are three values */
|
4864 |
-
if ( isset( $split[2] ) )
|
4865 |
-
$choices[$k]['src'] = trim( $split[2] );
|
4866 |
-
|
4867 |
-
} else {
|
4868 |
-
$choices[$k]['value'] = trim( $choice );
|
4869 |
-
$choices[$k]['label'] = trim( $choice );
|
4870 |
-
}
|
4871 |
-
|
4872 |
-
}
|
4873 |
-
|
4874 |
-
/* return a formated choices array */
|
4875 |
-
return $choices;
|
4876 |
-
|
4877 |
-
}
|
4878 |
-
|
4879 |
-
return false;
|
4880 |
-
|
4881 |
-
}
|
4882 |
-
}
|
4883 |
-
|
4884 |
-
/**
|
4885 |
-
* Helper function - strpos() with arrays.
|
4886 |
-
*
|
4887 |
-
* @param string $haystack
|
4888 |
-
* @param array $needles
|
4889 |
-
* @return bool
|
4890 |
-
*
|
4891 |
-
* @access public
|
4892 |
-
* @since 2.0
|
4893 |
-
*/
|
4894 |
-
if ( ! function_exists( 'ot_strpos_array' ) ) {
|
4895 |
-
|
4896 |
-
function ot_strpos_array( $haystack, $needles = array() ) {
|
4897 |
-
|
4898 |
-
foreach( $needles as $needle ) {
|
4899 |
-
$pos = strpos( $haystack, $needle );
|
4900 |
-
if ( $pos !== false ) {
|
4901 |
-
return true;
|
4902 |
-
}
|
4903 |
-
}
|
4904 |
-
|
4905 |
-
return false;
|
4906 |
-
}
|
4907 |
-
|
4908 |
-
}
|
4909 |
-
|
4910 |
-
/**
|
4911 |
-
* Helper function - strpos() with arrays.
|
4912 |
-
*
|
4913 |
-
* @param string $haystack
|
4914 |
-
* @param array $needles
|
4915 |
-
* @return bool
|
4916 |
-
*
|
4917 |
-
* @access public
|
4918 |
-
* @since 2.0
|
4919 |
-
*/
|
4920 |
-
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
|
4921 |
-
|
4922 |
-
function ot_array_keys_exists( $array, $keys ) {
|
4923 |
-
|
4924 |
-
foreach($keys as $k) {
|
4925 |
-
if ( isset($array[$k]) ) {
|
4926 |
-
return true;
|
4927 |
-
}
|
4928 |
-
}
|
4929 |
-
|
4930 |
-
return false;
|
4931 |
-
}
|
4932 |
-
|
4933 |
-
}
|
4934 |
|
4935 |
-
/**
|
4936 |
-
|
4937 |
-
|
4938 |
-
|
4939 |
-
|
4940 |
-
|
4941 |
-
|
4942 |
-
|
4943 |
-
|
4944 |
-
|
4945 |
|
4946 |
-
|
4947 |
-
|
4948 |
-
|
4949 |
-
|
4950 |
-
foreach( $input as &$val ) {
|
4951 |
-
|
4952 |
-
if ( is_array( $val ) ) {
|
4953 |
-
|
4954 |
-
$val = ot_stripslashes( $val );
|
4955 |
-
|
4956 |
-
} else {
|
4957 |
-
|
4958 |
-
$val = stripslashes( trim( $val ) );
|
4959 |
-
|
4960 |
-
}
|
4961 |
-
|
4962 |
-
}
|
4963 |
-
|
4964 |
-
} else {
|
4965 |
-
|
4966 |
-
$input = stripslashes( trim( $input ) );
|
4967 |
-
|
4968 |
-
}
|
4969 |
-
|
4970 |
-
return $input;
|
4971 |
-
|
4972 |
-
}
|
4973 |
|
4974 |
-
|
4975 |
|
4976 |
-
|
4977 |
-
|
4978 |
-
|
4979 |
-
* @param string $string The string to be filtered
|
4980 |
-
* @return string
|
4981 |
-
*
|
4982 |
-
* @access public
|
4983 |
-
* @since 2.0.9
|
4984 |
-
*/
|
4985 |
-
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
4986 |
|
4987 |
-
|
4988 |
-
|
4989 |
-
|
4990 |
-
if ( trim( $string ) === '' )
|
4991 |
-
return '';
|
4992 |
-
|
4993 |
-
/* remove all new lines & <p> tags */
|
4994 |
-
$string = str_replace( array( "\n", "<p>" ), "", $string );
|
4995 |
-
|
4996 |
-
/* replace <br /> with \r */
|
4997 |
-
$string = str_replace( array( "<br />", "<br>", "<br/>" ), "\r", $string );
|
4998 |
-
|
4999 |
-
/* replace </p> with \r\n */
|
5000 |
-
$string = str_replace( "</p>", "\r\n", $string );
|
5001 |
-
|
5002 |
-
/* return clean string */
|
5003 |
-
return trim( $string );
|
5004 |
-
|
5005 |
-
}
|
5006 |
|
5007 |
-
|
5008 |
|
5009 |
-
|
5010 |
-
* Returns an array of elements from start to limit, inclusive.
|
5011 |
-
*
|
5012 |
-
* Occasionally zero will be some impossibly large number to
|
5013 |
-
* the "E" power when creating a range from negative to positive.
|
5014 |
-
* This function attempts to fix that by setting that number back to "0".
|
5015 |
-
*
|
5016 |
-
* @param string $start First value of the sequence.
|
5017 |
-
* @param string $limit The sequence is ended upon reaching the limit value.
|
5018 |
-
* @param string $step If a step value is given, it will be used as the increment
|
5019 |
-
* between elements in the sequence. step should be given as a
|
5020 |
-
* positive number. If not specified, step will default to 1.
|
5021 |
-
* @return array
|
5022 |
-
*
|
5023 |
-
* @access public
|
5024 |
-
* @since 2.0.12
|
5025 |
-
*/
|
5026 |
-
function ot_range( $start, $limit, $step = 1 ) {
|
5027 |
-
|
5028 |
-
if ( $step < 0 )
|
5029 |
-
$step = 1;
|
5030 |
-
|
5031 |
-
$range = range( $start, $limit, $step );
|
5032 |
-
|
5033 |
-
foreach( $range as $k => $v ) {
|
5034 |
-
if ( strpos( $v, 'E' ) ) {
|
5035 |
-
$range[$k] = 0;
|
5036 |
-
}
|
5037 |
-
}
|
5038 |
-
|
5039 |
-
return $range;
|
5040 |
-
}
|
5041 |
|
5042 |
-
|
5043 |
-
* Helper function to return encoded strings
|
5044 |
-
*
|
5045 |
-
* @return string
|
5046 |
-
*
|
5047 |
-
* @access public
|
5048 |
-
* @since 2.0.13
|
5049 |
-
*/
|
5050 |
-
function ot_encode( $value ) {
|
5051 |
|
5052 |
-
|
5053 |
-
return $func( $value );
|
5054 |
-
|
5055 |
-
}
|
5056 |
|
5057 |
-
|
5058 |
-
* Helper function to return decoded strings
|
5059 |
-
*
|
5060 |
-
* @return string
|
5061 |
-
*
|
5062 |
-
* @access public
|
5063 |
-
* @since 2.0.13
|
5064 |
-
*/
|
5065 |
-
function ot_decode( $value ) {
|
5066 |
|
5067 |
-
|
5068 |
-
|
5069 |
-
|
5070 |
-
}
|
5071 |
|
5072 |
-
|
5073 |
-
* Helper function to open a file
|
5074 |
-
*
|
5075 |
-
* @access public
|
5076 |
-
* @since 2.0.13
|
5077 |
-
*/
|
5078 |
-
function ot_file_open( $handle, $mode ) {
|
5079 |
|
5080 |
-
|
5081 |
-
return @$func( $handle, $mode );
|
5082 |
-
|
5083 |
-
}
|
5084 |
|
5085 |
-
|
5086 |
-
* Helper function to close a file
|
5087 |
-
*
|
5088 |
-
* @access public
|
5089 |
-
* @since 2.0.13
|
5090 |
-
*/
|
5091 |
-
function ot_file_close( $handle ) {
|
5092 |
|
5093 |
-
|
5094 |
-
return $func( $handle );
|
5095 |
-
|
5096 |
-
}
|
5097 |
|
5098 |
-
|
5099 |
-
|
5100 |
-
*
|
5101 |
-
* @access public
|
5102 |
-
* @since 2.0.13
|
5103 |
-
*/
|
5104 |
-
function ot_file_write( $handle, $string ) {
|
5105 |
|
5106 |
-
|
5107 |
-
return $func( $handle, $string );
|
5108 |
-
|
5109 |
-
}
|
5110 |
|
5111 |
-
|
5112 |
-
* Helper function to filter standard option values.
|
5113 |
-
*
|
5114 |
-
* @param mixed $value Saved string or array value
|
5115 |
-
* @param mixed $std Standard string or array value
|
5116 |
-
* @return mixed String or array
|
5117 |
-
*
|
5118 |
-
* @access public
|
5119 |
-
* @since 2.0.15
|
5120 |
-
*/
|
5121 |
-
function ot_filter_std_value( $value = '', $std = '' ) {
|
5122 |
-
|
5123 |
-
$std = maybe_unserialize( $std );
|
5124 |
-
|
5125 |
-
if ( is_array( $value ) && is_array( $std ) ) {
|
5126 |
-
|
5127 |
-
foreach( $value as $k => $v ) {
|
5128 |
-
|
5129 |
-
if ( '' == $value[$k] && isset( $std[$k] ) ) {
|
5130 |
-
|
5131 |
-
$value[$k] = $std[$k];
|
5132 |
-
|
5133 |
-
}
|
5134 |
-
|
5135 |
-
}
|
5136 |
-
|
5137 |
-
} else if ( '' == $value && ! empty( $std ) ) {
|
5138 |
-
|
5139 |
-
$value = $std;
|
5140 |
-
|
5141 |
-
}
|
5142 |
|
5143 |
-
|
5144 |
-
|
5145 |
-
}
|
5146 |
|
5147 |
-
|
5148 |
-
* Helper function to set the Google fonts array.
|
5149 |
-
*
|
5150 |
-
* @param string $id The option ID.
|
5151 |
-
* @param bool $value The option value
|
5152 |
-
* @return void
|
5153 |
-
*
|
5154 |
-
* @access public
|
5155 |
-
* @since 2.5.0
|
5156 |
-
*/
|
5157 |
-
function ot_set_google_fonts( $id = '', $value = '' ) {
|
5158 |
|
5159 |
-
|
|
|
5160 |
|
5161 |
-
|
5162 |
-
$ot_set_google_fonts[$id] = $value;
|
5163 |
-
} else if ( isset( $ot_set_google_fonts[$id] ) ) {
|
5164 |
-
unset( $ot_set_google_fonts[$id] );
|
5165 |
-
}
|
5166 |
|
5167 |
-
|
5168 |
|
5169 |
-
}
|
5170 |
|
5171 |
-
|
5172 |
-
* Helper function to remove unused options from the Google fonts array.
|
5173 |
-
*
|
5174 |
-
* @param array $options The array of saved options.
|
5175 |
-
* @return array
|
5176 |
-
*
|
5177 |
-
* @access public
|
5178 |
-
* @since 2.5.0
|
5179 |
-
*/
|
5180 |
-
function ot_update_google_fonts_after_save( $options ) {
|
5181 |
|
5182 |
-
|
|
|
5183 |
|
5184 |
-
|
5185 |
-
if ( ! isset( $options[$key] ) ) {
|
5186 |
-
unset( $ot_set_google_fonts[$key] );
|
5187 |
-
}
|
5188 |
-
}
|
5189 |
-
set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
|
5190 |
|
5191 |
-
|
5192 |
-
add_action( 'ot_after_theme_options_save', 'ot_update_google_fonts_after_save', 1 );
|
5193 |
|
5194 |
-
|
5195 |
-
* Helper function to fetch the Google fonts array.
|
5196 |
-
*
|
5197 |
-
* @param bool $normalize Whether or not to return a normalized array. Default 'true'.
|
5198 |
-
* @param bool $force_rebuild Whether or not to force the array to be rebuilt. Default 'false'.
|
5199 |
-
* @return array
|
5200 |
-
*
|
5201 |
-
* @access public
|
5202 |
-
* @since 2.5.0
|
5203 |
-
*/
|
5204 |
-
function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
|
5205 |
|
5206 |
-
|
5207 |
-
$ot_google_fonts_cache_key = apply_filters( 'ot_google_fonts_cache_key', 'ot_google_fonts_cache' );
|
5208 |
|
5209 |
-
|
5210 |
-
$ot_google_fonts = apply_filters( 'ot_google_fonts_cache', get_transient( $ot_google_fonts_cache_key ) );
|
5211 |
|
5212 |
-
|
5213 |
|
5214 |
-
|
|
|
5215 |
|
5216 |
-
|
5217 |
-
$ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' );
|
5218 |
-
$ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', 'AIzaSyB8G-4UtQr9fhDYTiNrDP40Y5GYQQKrNWI' );
|
5219 |
|
5220 |
-
|
5221 |
-
$ot_google_fonts_fields = apply_filters( 'ot_google_fonts_fields', array( 'family', 'variants', 'subsets' ) );
|
5222 |
-
$ot_google_fonts_sort = apply_filters( 'ot_google_fonts_sort', 'alpha' );
|
5223 |
|
5224 |
-
|
5225 |
-
$ot_google_fonts_query_args = array(
|
5226 |
-
'key' => $ot_google_fonts_api_key,
|
5227 |
-
'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')',
|
5228 |
-
'sort' => $ot_google_fonts_sort
|
5229 |
-
);
|
5230 |
|
5231 |
-
|
5232 |
-
$ot_google_fonts_query = esc_url_raw( add_query_arg( $ot_google_fonts_query_args, $ot_google_fonts_api_url ) );
|
5233 |
-
$ot_google_fonts_response = wp_safe_remote_get( $ot_google_fonts_query, array( 'sslverify' => false, 'timeout' => 15 ) );
|
5234 |
|
5235 |
-
|
5236 |
-
if ( 200 == wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) {
|
5237 |
|
5238 |
-
|
|
|
|
|
5239 |
|
5240 |
-
|
5241 |
-
|
|
|
|
|
|
|
5242 |
|
5243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5244 |
|
5245 |
-
|
5246 |
-
|
5247 |
-
// Normalize the array key
|
5248 |
-
$ot_google_fonts_tmp = array();
|
5249 |
-
foreach( $ot_google_fonts as $key => $value ) {
|
5250 |
-
$id = remove_accents( $value['family'] );
|
5251 |
-
$id = strtolower( $id );
|
5252 |
-
$id = preg_replace( '/[^a-z0-9_\-]/', '', $id );
|
5253 |
-
$ot_google_fonts_tmp[$id] = $value;
|
5254 |
-
}
|
5255 |
-
|
5256 |
-
$ot_google_fonts = $ot_google_fonts_tmp;
|
5257 |
-
set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
|
5258 |
-
set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS );
|
5259 |
|
5260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5261 |
|
5262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5263 |
|
5264 |
-
|
5265 |
|
5266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5267 |
|
5268 |
-
|
5269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5270 |
}
|
5271 |
|
5272 |
-
|
5273 |
-
* Helper function to normalize the Google fonts array.
|
5274 |
-
*
|
5275 |
-
* @param array $google_fonts An array of fonts to nrmalize.
|
5276 |
-
* @return array
|
5277 |
-
*
|
5278 |
-
* @access public
|
5279 |
-
* @since 2.5.0
|
5280 |
-
*/
|
5281 |
-
function ot_normalize_google_fonts( $google_fonts ) {
|
5282 |
|
5283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5284 |
|
5285 |
-
|
5286 |
|
5287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5288 |
|
5289 |
-
|
5290 |
|
5291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5292 |
|
5293 |
-
|
5294 |
-
'family' => $google_font['family']
|
5295 |
-
);
|
5296 |
|
5297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5298 |
|
5299 |
-
|
5300 |
|
5301 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5302 |
|
5303 |
-
|
5304 |
|
5305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5306 |
|
5307 |
-
|
5308 |
|
5309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5310 |
|
5311 |
-
|
5312 |
|
5313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5314 |
|
5315 |
-
|
5316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5317 |
}
|
5318 |
|
5319 |
-
|
5320 |
-
* Helper function to register a WPML string
|
5321 |
-
*
|
5322 |
-
* @access public
|
5323 |
-
* @since 2.1
|
5324 |
-
*/
|
5325 |
-
function ot_wpml_register_string( $id, $value ) {
|
5326 |
|
5327 |
-
|
5328 |
-
|
5329 |
-
|
5330 |
-
|
5331 |
-
|
5332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5333 |
}
|
5334 |
|
5335 |
-
|
5336 |
-
* Helper function to unregister a WPML string
|
5337 |
-
*
|
5338 |
-
* @access public
|
5339 |
-
* @since 2.1
|
5340 |
-
*/
|
5341 |
-
function ot_wpml_unregister_string( $id ) {
|
5342 |
|
5343 |
-
|
5344 |
-
|
5345 |
-
|
5346 |
-
|
5347 |
-
|
5348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5349 |
}
|
5350 |
|
5351 |
-
|
5352 |
-
* Maybe migrate Settings
|
5353 |
-
*
|
5354 |
-
* @return void
|
5355 |
-
*
|
5356 |
-
* @access public
|
5357 |
-
* @since 2.3.3
|
5358 |
-
*/
|
5359 |
-
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
|
5360 |
|
5361 |
-
|
5362 |
-
|
5363 |
-
|
5364 |
-
|
5365 |
-
|
5366 |
-
|
5367 |
-
|
5368 |
-
|
5369 |
-
|
5370 |
-
|
5371 |
-
|
5372 |
-
|
5373 |
-
|
5374 |
-
|
5375 |
-
|
5376 |
-
|
5377 |
-
|
5378 |
-
|
5379 |
-
|
5380 |
-
|
5381 |
-
|
5382 |
-
|
|
|
|
|
|
|
5383 |
}
|
5384 |
|
5385 |
-
|
5386 |
-
* Maybe migrate Option
|
5387 |
-
*
|
5388 |
-
* @return void
|
5389 |
-
*
|
5390 |
-
* @access public
|
5391 |
-
* @since 2.3.3
|
5392 |
-
*/
|
5393 |
-
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
|
5394 |
|
5395 |
-
|
5396 |
-
|
5397 |
-
|
5398 |
-
|
5399 |
-
|
5400 |
-
|
5401 |
-
|
5402 |
-
|
5403 |
-
|
5404 |
-
|
5405 |
-
|
5406 |
-
|
5407 |
-
|
5408 |
-
|
5409 |
-
|
5410 |
-
|
5411 |
-
|
5412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5413 |
}
|
5414 |
|
5415 |
-
|
5416 |
-
|
5417 |
-
|
5418 |
-
|
5419 |
-
|
5420 |
-
|
5421 |
-
|
5422 |
-
|
5423 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5424 |
|
5425 |
-
|
5426 |
-
|
5427 |
-
// Filter the ID to migrate from
|
5428 |
-
$layouts_id = apply_filters( 'ot_migrate_layouts_id', '' );
|
5429 |
-
|
5430 |
-
// Attempt to migrate Layouts
|
5431 |
-
if ( ! empty( $layouts_id ) && get_option( ot_layouts_id() ) === false && ot_layouts_id() !== $layouts_id ) {
|
5432 |
-
|
5433 |
-
// Old options
|
5434 |
-
$layouts = get_option( $layouts_id );
|
5435 |
-
|
5436 |
-
// Migrate to new ID
|
5437 |
-
update_option( ot_layouts_id(), $layouts );
|
5438 |
-
|
5439 |
-
}
|
5440 |
-
|
5441 |
-
}
|
5442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5443 |
}
|
5444 |
|
5445 |
-
|
5446 |
-
* Returns an array with the post format gallery meta box.
|
5447 |
-
*
|
5448 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
5449 |
-
* post_types and is what tells the metabox where to
|
5450 |
-
* display. Default 'post'.
|
5451 |
-
* @return array
|
5452 |
-
*
|
5453 |
-
* @access public
|
5454 |
-
* @since 2.4.0
|
5455 |
-
*/
|
5456 |
-
function ot_meta_box_post_format_gallery( $pages = 'post' ) {
|
5457 |
|
5458 |
-
|
5459 |
-
|
5460 |
-
|
5461 |
-
|
5462 |
-
|
5463 |
-
|
5464 |
-
|
5465 |
-
|
5466 |
-
|
5467 |
-
|
5468 |
-
|
5469 |
-
|
5470 |
-
|
5471 |
-
|
5472 |
-
|
5473 |
-
|
5474 |
-
|
5475 |
-
|
5476 |
-
|
5477 |
-
|
5478 |
-
|
5479 |
-
|
5480 |
-
|
5481 |
-
|
|
|
|
|
|
|
5482 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5483 |
}
|
5484 |
|
5485 |
-
|
5486 |
-
* Returns an array with the post format link metabox.
|
5487 |
-
*
|
5488 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
5489 |
-
* post_types and is what tells the metabox where to
|
5490 |
-
* display. Default 'post'.
|
5491 |
-
* @return array
|
5492 |
-
*
|
5493 |
-
* @access public
|
5494 |
-
* @since 2.4.0
|
5495 |
-
*/
|
5496 |
-
function ot_meta_box_post_format_link( $pages = 'post' ) {
|
5497 |
-
|
5498 |
-
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ) ) )
|
5499 |
-
return false;
|
5500 |
-
|
5501 |
-
if ( is_string( $pages ) )
|
5502 |
-
$pages = explode( ',', $pages );
|
5503 |
-
|
5504 |
-
return apply_filters( 'ot_meta_box_post_format_link', array(
|
5505 |
-
'id' => 'ot-post-format-link',
|
5506 |
-
'title' => __( 'Link', 'option-tree' ),
|
5507 |
-
'desc' => '',
|
5508 |
-
'pages' => $pages,
|
5509 |
-
'context' => 'side',
|
5510 |
-
'priority' => 'low',
|
5511 |
-
'fields' => array(
|
5512 |
-
array(
|
5513 |
-
'id' => '_format_link_url',
|
5514 |
-
'label' => '',
|
5515 |
-
'desc' => __( 'Link URL', 'option-tree' ),
|
5516 |
-
'std' => '',
|
5517 |
-
'type' => 'text'
|
5518 |
-
),
|
5519 |
-
array(
|
5520 |
-
'id' => '_format_link_title',
|
5521 |
-
'label' => '',
|
5522 |
-
'desc' => __( 'Link Title', 'option-tree' ),
|
5523 |
-
'std' => '',
|
5524 |
-
'type' => 'text'
|
5525 |
-
)
|
5526 |
-
)
|
5527 |
-
), $pages );
|
5528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5529 |
}
|
5530 |
|
5531 |
-
|
5532 |
-
* Returns an array with the post format quote metabox.
|
5533 |
-
*
|
5534 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
5535 |
-
* post_types and is what tells the metabox where to
|
5536 |
-
* display. Default 'post'.
|
5537 |
-
* @return array
|
5538 |
-
*
|
5539 |
-
* @access public
|
5540 |
-
* @since 2.4.0
|
5541 |
-
*/
|
5542 |
-
function ot_meta_box_post_format_quote( $pages = 'post' ) {
|
5543 |
-
|
5544 |
-
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ) ) )
|
5545 |
-
return false;
|
5546 |
-
|
5547 |
-
if ( is_string( $pages ) )
|
5548 |
-
$pages = explode( ',', $pages );
|
5549 |
-
|
5550 |
-
return apply_filters( 'ot_meta_box_post_format_quote', array(
|
5551 |
-
'id' => 'ot-post-format-quote',
|
5552 |
-
'title' => __( 'Quote', 'option-tree' ),
|
5553 |
-
'desc' => '',
|
5554 |
-
'pages' => $pages,
|
5555 |
-
'context' => 'side',
|
5556 |
-
'priority' => 'low',
|
5557 |
-
'fields' => array(
|
5558 |
-
array(
|
5559 |
-
'id' => '_format_quote_source_name',
|
5560 |
-
'label' => '',
|
5561 |
-
'desc' => __( 'Source Name (ex. author, singer, actor)', 'option-tree' ),
|
5562 |
-
'std' => '',
|
5563 |
-
'type' => 'text'
|
5564 |
-
),
|
5565 |
-
array(
|
5566 |
-
'id' => '_format_quote_source_url',
|
5567 |
-
'label' => '',
|
5568 |
-
'desc' => __( 'Source URL', 'option-tree' ),
|
5569 |
-
'std' => '',
|
5570 |
-
'type' => 'text'
|
5571 |
-
),
|
5572 |
-
array(
|
5573 |
-
'id' => '_format_quote_source_title',
|
5574 |
-
'label' => '',
|
5575 |
-
'desc' => __( 'Source Title (ex. book, song, movie)', 'option-tree' ),
|
5576 |
-
'std' => '',
|
5577 |
-
'type' => 'text'
|
5578 |
-
),
|
5579 |
-
array(
|
5580 |
-
'id' => '_format_quote_source_date',
|
5581 |
-
'label' => '',
|
5582 |
-
'desc' => __( 'Source Date', 'option-tree' ),
|
5583 |
-
'std' => '',
|
5584 |
-
'type' => 'text'
|
5585 |
-
)
|
5586 |
-
)
|
5587 |
-
), $pages );
|
5588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5589 |
}
|
5590 |
|
5591 |
-
|
5592 |
-
* Returns an array with the post format video metabox.
|
5593 |
-
*
|
5594 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
5595 |
-
* post_types and is what tells the metabox where to
|
5596 |
-
* display. Default 'post'.
|
5597 |
-
* @return array
|
5598 |
-
*
|
5599 |
-
* @access public
|
5600 |
-
* @since 2.4.0
|
5601 |
-
*/
|
5602 |
-
function ot_meta_box_post_format_video( $pages = 'post' ) {
|
5603 |
-
|
5604 |
-
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ) ) )
|
5605 |
-
return false;
|
5606 |
-
|
5607 |
-
if ( is_string( $pages ) )
|
5608 |
-
$pages = explode( ',', $pages );
|
5609 |
-
|
5610 |
-
return apply_filters( 'ot_meta_box_post_format_video', array(
|
5611 |
-
'id' => 'ot-post-format-video',
|
5612 |
-
'title' => __( 'Video', 'option-tree' ),
|
5613 |
-
'desc' => '',
|
5614 |
-
'pages' => $pages,
|
5615 |
-
'context' => 'side',
|
5616 |
-
'priority' => 'low',
|
5617 |
-
'fields' => array(
|
5618 |
-
array(
|
5619 |
-
'id' => '_format_video_embed',
|
5620 |
-
'label' => '',
|
5621 |
-
'desc' => sprintf( __( 'Embed video from services like Youtube, Vimeo, or Hulu. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ), '<a href="http://codex.wordpress.org/Embeds" target="_blank">' . __( 'Wordpress Codex', 'option-tree' ) .'</a>', '<code>[video]</code>' ),
|
5622 |
-
'std' => '',
|
5623 |
-
'type' => 'textarea'
|
5624 |
-
)
|
5625 |
-
)
|
5626 |
-
), $pages );
|
5627 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5628 |
}
|
5629 |
|
5630 |
-
|
5631 |
-
* Returns an array with the post format audio metabox.
|
5632 |
-
*
|
5633 |
-
* @param mixed $pages Excepts a comma separated string or array of
|
5634 |
-
* post_types and is what tells the metabox where to
|
5635 |
-
* display. Default 'post'.
|
5636 |
-
* @return array
|
5637 |
-
*
|
5638 |
-
* @access public
|
5639 |
-
* @since 2.4.0
|
5640 |
-
*/
|
5641 |
-
function ot_meta_box_post_format_audio( $pages = 'post' ) {
|
5642 |
-
|
5643 |
-
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ) ) )
|
5644 |
-
return false;
|
5645 |
-
|
5646 |
-
if ( is_string( $pages ) )
|
5647 |
-
$pages = explode( ',', $pages );
|
5648 |
-
|
5649 |
-
return apply_filters( 'ot_meta_box_post_format_audio', array(
|
5650 |
-
'id' => 'ot-post-format-audio',
|
5651 |
-
'title' => __( 'Audio', 'option-tree' ),
|
5652 |
-
'desc' => '',
|
5653 |
-
'pages' => $pages,
|
5654 |
-
'context' => 'side',
|
5655 |
-
'priority' => 'low',
|
5656 |
-
'fields' => array(
|
5657 |
-
array(
|
5658 |
-
'id' => '_format_audio_embed',
|
5659 |
-
'label' => '',
|
5660 |
-
'desc' => sprintf( __( 'Embed audio from services like SoundCloud and Rdio. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ), '<a href="http://codex.wordpress.org/Embeds" target="_blank">' . __( 'Wordpress Codex', 'option-tree' ) .'</a>', '<code>[audio]</code>' ),
|
5661 |
-
'std' => '',
|
5662 |
-
'type' => 'textarea'
|
5663 |
-
)
|
5664 |
-
)
|
5665 |
-
), $pages );
|
5666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5667 |
}
|
5668 |
|
5669 |
-
|
5670 |
-
* Returns the option type by ID.
|
5671 |
-
*
|
5672 |
-
* @param string $option_id The option ID
|
5673 |
-
* @return string $settings_id The settings array ID
|
5674 |
-
* @return string The option type.
|
5675 |
-
*
|
5676 |
-
* @access public
|
5677 |
-
* @since 2.4.2
|
5678 |
-
*/
|
5679 |
-
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
|
5680 |
|
5681 |
-
|
5682 |
-
|
5683 |
-
|
5684 |
-
|
5685 |
-
|
5686 |
-
|
5687 |
-
|
5688 |
-
|
5689 |
-
|
5690 |
-
|
5691 |
-
|
5692 |
-
|
5693 |
-
|
5694 |
-
|
5695 |
-
|
5696 |
-
|
5697 |
-
|
5698 |
-
|
5699 |
-
|
5700 |
-
|
5701 |
-
|
5702 |
-
|
5703 |
-
|
5704 |
-
|
5705 |
-
|
5706 |
-
|
5707 |
-
|
5708 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5709 |
}
|
5710 |
|
5711 |
-
|
5712 |
-
|
5713 |
-
|
5714 |
-
|
5715 |
-
|
5716 |
-
|
5717 |
-
|
5718 |
-
|
5719 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5720 |
|
5721 |
-
|
5722 |
-
|
5723 |
-
|
5724 |
-
'category-checkbox',
|
5725 |
-
'category-select',
|
5726 |
-
'tag-checkbox',
|
5727 |
-
'tag-select',
|
5728 |
-
'taxonomy-checkbox',
|
5729 |
-
'taxonomy-select'
|
5730 |
-
);
|
5731 |
|
5732 |
-
|
5733 |
|
5734 |
-
|
|
|
|
|
5735 |
|
5736 |
-
|
|
|
|
|
5737 |
|
5738 |
-
|
|
|
5739 |
|
5740 |
-
|
|
|
|
|
5741 |
|
5742 |
-
|
5743 |
|
5744 |
-
|
5745 |
-
|
|
|
5746 |
|
5747 |
-
|
5748 |
-
|
5749 |
-
|
5750 |
-
}
|
5751 |
-
}
|
5752 |
|
5753 |
-
|
5754 |
-
|
5755 |
-
|
5756 |
-
'taxonomy' => $value['taxonomy'],
|
5757 |
-
'parent' => $value['id'],
|
5758 |
-
'value' => $sub_options
|
5759 |
-
);
|
5760 |
-
}
|
5761 |
-
}
|
5762 |
|
5763 |
-
|
|
|
|
|
5764 |
|
5765 |
-
|
|
|
5766 |
|
5767 |
-
|
5768 |
-
|
5769 |
-
|
5770 |
-
$options[] = array(
|
5771 |
-
'id' => $value['id'],
|
5772 |
-
'taxonomy' => $value['taxonomy'],
|
5773 |
-
'value' => $saved
|
5774 |
-
);
|
5775 |
-
}
|
5776 |
-
}
|
5777 |
|
5778 |
-
|
|
|
|
|
5779 |
|
5780 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
5781 |
|
5782 |
-
|
|
|
|
|
5783 |
|
5784 |
-
|
|
|
|
|
5785 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5786 |
}
|
5787 |
|
5788 |
-
|
5789 |
-
* Build an array of potential Meta Box options that could share terms
|
5790 |
-
*
|
5791 |
-
* @return array
|
5792 |
-
*
|
5793 |
-
* @access private
|
5794 |
-
* @since 2.5.4
|
5795 |
-
*/
|
5796 |
-
function _ot_meta_box_potential_shared_terms() {
|
5797 |
-
global $ot_meta_boxes;
|
5798 |
|
5799 |
-
|
5800 |
-
|
5801 |
-
|
5802 |
-
|
5803 |
-
|
5804 |
-
|
5805 |
-
|
5806 |
-
|
5807 |
-
|
5808 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5809 |
|
5810 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5811 |
|
5812 |
-
|
5813 |
|
5814 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5815 |
|
5816 |
-
|
5817 |
|
5818 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5819 |
|
5820 |
-
|
5821 |
|
5822 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5823 |
|
5824 |
-
|
5825 |
|
5826 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5827 |
|
5828 |
-
|
5829 |
|
5830 |
-
|
5831 |
-
|
5832 |
-
|
5833 |
-
|
5834 |
-
|
5835 |
-
|
5836 |
-
|
5837 |
-
|
5838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5839 |
|
5840 |
-
|
5841 |
|
5842 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5843 |
|
5844 |
-
|
5845 |
-
'id' => $value['id'],
|
5846 |
-
'taxonomy' => $value['taxonomy'],
|
5847 |
-
);
|
5848 |
|
5849 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5850 |
|
5851 |
-
|
5852 |
|
5853 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5854 |
|
5855 |
-
|
5856 |
|
5857 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5858 |
|
5859 |
-
|
5860 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5861 |
}
|
5862 |
|
5863 |
-
|
5864 |
-
* Update terms when a term gets split.
|
5865 |
-
*
|
5866 |
-
* @param int $term_id ID of the formerly shared term.
|
5867 |
-
* @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
|
5868 |
-
* @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
|
5869 |
-
* @param string $taxonomy Taxonomy for the split term.
|
5870 |
-
* @return void
|
5871 |
-
*
|
5872 |
-
* @access public
|
5873 |
-
* @since 2.5.4
|
5874 |
-
*/
|
5875 |
-
function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
|
5876 |
|
5877 |
-
|
5878 |
-
|
5879 |
-
|
5880 |
-
|
|
|
|
|
|
|
5881 |
|
5882 |
-
|
5883 |
-
if ( ! empty( $settings ) && ! empty( $old_options ) ) {
|
5884 |
|
5885 |
-
|
5886 |
-
|
5887 |
|
5888 |
-
|
5889 |
-
|
5890 |
-
}
|
5891 |
|
5892 |
-
|
5893 |
-
|
5894 |
-
}
|
5895 |
|
5896 |
-
|
5897 |
-
if ( array_key_exists( $option['id'], $old_options ) || ( isset( $option['parent'] ) && array_key_exists( $option['parent'], $old_options ) ) ) {
|
5898 |
|
5899 |
-
|
5900 |
-
if ( isset( $option['parent'] ) ) {
|
5901 |
|
5902 |
-
|
5903 |
-
foreach( $option['value'] as $key => $value ) {
|
5904 |
|
5905 |
-
|
5906 |
-
if ( is_array( $value ) ) {
|
5907 |
|
5908 |
-
|
5909 |
-
foreach( $value as $sub_key => $sub_value ) {
|
5910 |
|
5911 |
-
|
5912 |
|
5913 |
-
|
5914 |
-
$new_options[$option['parent']][$key][$option['id']][$new_term_id] = $new_term_id;
|
5915 |
|
5916 |
-
|
|
|
|
|
5917 |
|
5918 |
-
|
|
|
|
|
5919 |
|
5920 |
-
|
5921 |
|
5922 |
-
|
5923 |
-
$new_options[$option['parent']][$key][$option['id']] = $new_term_id;
|
5924 |
|
5925 |
-
|
|
|
5926 |
|
5927 |
-
|
|
|
5928 |
|
5929 |
-
|
|
|
5930 |
|
5931 |
-
|
5932 |
-
if ( is_array( $option['value'] ) ) {
|
5933 |
|
5934 |
-
|
5935 |
-
|
|
|
|
|
|
|
|
|
|
|
5936 |
|
5937 |
-
|
5938 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5939 |
|
5940 |
-
|
5941 |
-
$new_options[$option['id']][$new_term_id] = $new_term_id;
|
5942 |
|
5943 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5944 |
|
5945 |
-
|
5946 |
|
5947 |
-
|
5948 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5949 |
|
5950 |
-
|
5951 |
|
5952 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5953 |
|
5954 |
-
|
5955 |
|
5956 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5957 |
|
5958 |
-
|
5959 |
|
5960 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5961 |
|
5962 |
-
|
5963 |
-
if ( $old_options !== $new_options ) {
|
5964 |
-
update_option( ot_options_id(), $new_options );
|
5965 |
-
}
|
5966 |
|
5967 |
-
|
5968 |
-
|
5969 |
-
|
5970 |
-
|
5971 |
-
|
5972 |
-
|
5973 |
-
|
5974 |
-
|
5975 |
-
|
5976 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5977 |
|
5978 |
-
|
5979 |
-
$old_meta = array();
|
5980 |
-
|
5981 |
-
foreach( $meta_settings as $option ) {
|
5982 |
|
5983 |
-
|
5984 |
-
|
5985 |
-
|
5986 |
-
|
5987 |
-
|
5988 |
-
|
5989 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5990 |
|
5991 |
-
|
5992 |
-
|
5993 |
-
|
5994 |
-
|
5995 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5996 |
|
5997 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5998 |
|
5999 |
-
|
6000 |
|
6001 |
-
|
6002 |
-
|
6003 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6004 |
|
6005 |
-
|
6006 |
-
|
6007 |
|
6008 |
-
|
6009 |
-
|
6010 |
|
6011 |
-
|
|
|
6012 |
|
6013 |
-
|
|
|
|
|
|
|
6014 |
|
6015 |
-
|
6016 |
-
|
6017 |
|
6018 |
-
|
6019 |
-
|
|
|
6020 |
|
6021 |
-
|
6022 |
-
|
|
|
6023 |
|
6024 |
-
|
6025 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6026 |
|
6027 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6028 |
|
6029 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6030 |
|
6031 |
-
|
6032 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6033 |
|
6034 |
-
|
6035 |
|
6036 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6037 |
|
6038 |
-
|
6039 |
|
6040 |
-
|
6041 |
|
6042 |
-
|
6043 |
|
6044 |
-
|
6045 |
-
if ( $old_meta !== $new_meta ) {
|
6046 |
-
|
6047 |
-
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
6048 |
-
|
6049 |
-
}
|
6050 |
|
6051 |
-
|
6052 |
|
6053 |
-
|
|
|
|
|
6054 |
|
6055 |
-
|
|
|
|
|
6056 |
|
6057 |
-
|
6058 |
-
|
6059 |
-
|
6060 |
-
|
6061 |
-
|
6062 |
-
|
6063 |
-
'compare' => 'IN'
|
6064 |
-
),
|
6065 |
-
) );
|
6066 |
|
6067 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6068 |
|
6069 |
-
|
6070 |
|
6071 |
-
|
6072 |
-
|
6073 |
-
|
|
|
|
|
|
|
|
|
6074 |
|
6075 |
-
|
6076 |
-
|
6077 |
|
6078 |
-
|
6079 |
-
|
6080 |
|
6081 |
-
|
6082 |
-
|
6083 |
|
6084 |
-
|
6085 |
-
|
|
|
|
|
|
|
6086 |
|
6087 |
-
|
6088 |
-
$new_meta[$new_term_id] = $new_term_id;
|
6089 |
|
6090 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
6091 |
|
6092 |
-
|
|
|
6093 |
|
6094 |
-
|
6095 |
-
|
6096 |
|
6097 |
-
|
|
|
6098 |
|
6099 |
-
|
|
|
|
|
|
|
|
|
6100 |
|
6101 |
-
|
6102 |
-
|
6103 |
-
|
6104 |
-
|
6105 |
-
|
6106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6107 |
|
6108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6109 |
|
6110 |
-
|
6111 |
|
6112 |
-
|
6113 |
|
6114 |
-
|
|
|
|
|
|
|
|
|
6115 |
|
6116 |
-
|
|
|
|
|
6117 |
|
6118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6120 |
}
|
6121 |
-
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
|
6122 |
|
6123 |
-
|
6124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
* Functions used only while viewing the admin UI.
|
4 |
*
|
5 |
+
* Limit loading these function only when needed
|
6 |
* and not in the front end.
|
7 |
*
|
8 |
+
* @package OptionTree
|
|
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
12 |
+
exit( 'No direct script access allowed' );
|
13 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
if ( ! function_exists( 'ot_register_theme_options_page' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
/**
|
18 |
+
* Registers the Theme Option page
|
19 |
+
*
|
20 |
+
* @uses ot_register_settings()
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @since 2.1
|
24 |
+
*/
|
25 |
+
function ot_register_theme_options_page() {
|
26 |
+
|
27 |
+
// Get the settings array.
|
28 |
+
$get_settings = get_option( ot_settings_id() );
|
29 |
+
|
30 |
+
// Sections array.
|
31 |
+
$sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array();
|
32 |
+
|
33 |
+
// Settings array.
|
34 |
+
$settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array();
|
35 |
+
|
36 |
+
// Contexual help array.
|
37 |
+
$contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array();
|
38 |
+
|
39 |
+
// Build the Theme Options.
|
40 |
+
if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) {
|
41 |
+
|
42 |
+
$caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' );
|
43 |
+
|
44 |
+
ot_register_settings(
|
45 |
+
array(
|
46 |
+
array(
|
47 |
+
'id' => ot_options_id(),
|
48 |
+
'pages' => array(
|
49 |
+
array(
|
50 |
+
'id' => 'ot_theme_options',
|
51 |
+
'parent_slug' => apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ),
|
52 |
+
'page_title' => apply_filters( 'ot_theme_options_page_title', esc_html__( 'Theme Options', 'option-tree' ) ),
|
53 |
+
'menu_title' => apply_filters( 'ot_theme_options_menu_title', esc_html__( 'Theme Options', 'option-tree' ) ),
|
54 |
+
'capability' => $caps,
|
55 |
+
'menu_slug' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ),
|
56 |
+
'icon_url' => apply_filters( 'ot_theme_options_icon_url', null ),
|
57 |
+
'position' => apply_filters( 'ot_theme_options_position', null ),
|
58 |
+
'updated_message' => apply_filters( 'ot_theme_options_updated_message', esc_html__( 'Theme Options updated.', 'option-tree' ) ),
|
59 |
+
'reset_message' => apply_filters( 'ot_theme_options_reset_message', esc_html__( 'Theme Options reset.', 'option-tree' ) ),
|
60 |
+
'button_text' => apply_filters( 'ot_theme_options_button_text', esc_html__( 'Save Changes', 'option-tree' ) ),
|
61 |
+
'contextual_help' => apply_filters( 'ot_theme_options_contextual_help', $contextual_help ),
|
62 |
+
'sections' => apply_filters( 'ot_theme_options_sections', $sections ),
|
63 |
+
'settings' => apply_filters( 'ot_theme_options_settings', $settings ),
|
64 |
+
),
|
65 |
+
),
|
66 |
+
),
|
67 |
+
)
|
68 |
+
);
|
69 |
+
|
70 |
+
// Filters the options.php to add the minimum user capabilities.
|
71 |
+
add_filter(
|
72 |
+
'option_page_capability_' . ot_options_id(),
|
73 |
+
function() use ( $caps ) {
|
74 |
+
return $caps;
|
75 |
+
},
|
76 |
+
999
|
77 |
+
);
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
}
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
if ( ! function_exists( 'ot_register_settings_page' ) ) {
|
85 |
|
86 |
+
/**
|
87 |
+
* Registers the Settings page.
|
88 |
+
*
|
89 |
+
* @access public
|
90 |
+
* @since 2.1
|
91 |
+
*/
|
92 |
+
function ot_register_settings_page() {
|
93 |
+
global $ot_has_custom_theme_options;
|
94 |
+
|
95 |
+
$custom_options = ( true === $ot_has_custom_theme_options || has_action( 'admin_init', 'custom_theme_options' ) || has_action( 'init', 'custom_theme_options' ) );
|
96 |
+
|
97 |
+
// Display UI Builder admin notice.
|
98 |
+
if ( true === OT_SHOW_OPTIONS_UI && isset( $_REQUEST['page'] ) && 'ot-settings' === $_REQUEST['page'] && $custom_options ) { // phpcs:ignore
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Error message for custom theme options.
|
102 |
+
*/
|
103 |
+
function ot_has_custom_theme_options() {
|
104 |
+
echo '<div class="error"><p>' . esc_html__( 'The Theme Options UI Builder is being overridden by a custom file in your theme. Any changes you make via the UI Builder will not be saved.', 'option-tree' ) . '</p></div>';
|
105 |
+
}
|
106 |
+
|
107 |
+
add_action( 'admin_notices', 'ot_has_custom_theme_options' );
|
108 |
+
}
|
109 |
+
|
110 |
+
// Create the filterable pages array.
|
111 |
+
$ot_register_pages_array = array(
|
112 |
+
array(
|
113 |
+
'id' => 'ot',
|
114 |
+
'page_title' => esc_html__( 'OptionTree', 'option-tree' ),
|
115 |
+
'menu_title' => esc_html__( 'OptionTree', 'option-tree' ),
|
116 |
+
'capability' => 'edit_theme_options',
|
117 |
+
'menu_slug' => 'ot-settings',
|
118 |
+
'icon_url' => null,
|
119 |
+
'position' => 61,
|
120 |
+
'hidden_page' => true,
|
121 |
+
),
|
122 |
+
array(
|
123 |
+
'id' => 'settings',
|
124 |
+
'parent_slug' => 'ot-settings',
|
125 |
+
'page_title' => esc_html__( 'Settings', 'option-tree' ),
|
126 |
+
'menu_title' => esc_html__( 'Settings', 'option-tree' ),
|
127 |
+
'capability' => 'edit_theme_options',
|
128 |
+
'menu_slug' => 'ot-settings',
|
129 |
+
'icon_url' => null,
|
130 |
+
'position' => null,
|
131 |
+
'updated_message' => esc_html__( 'Theme Options updated.', 'option-tree' ),
|
132 |
+
'reset_message' => esc_html__( 'Theme Options reset.', 'option-tree' ),
|
133 |
+
'button_text' => esc_html__( 'Save Settings', 'option-tree' ),
|
134 |
+
'show_buttons' => false,
|
135 |
+
'sections' => array(
|
136 |
+
array(
|
137 |
+
'id' => 'create_setting',
|
138 |
+
'title' => esc_html__( 'Theme Options UI', 'option-tree' ),
|
139 |
+
),
|
140 |
+
array(
|
141 |
+
'id' => 'import',
|
142 |
+
'title' => esc_html__( 'Import', 'option-tree' ),
|
143 |
+
),
|
144 |
+
array(
|
145 |
+
'id' => 'export',
|
146 |
+
'title' => esc_html__( 'Export', 'option-tree' ),
|
147 |
+
),
|
148 |
+
array(
|
149 |
+
'id' => 'layouts',
|
150 |
+
'title' => esc_html__( 'Layouts', 'option-tree' ),
|
151 |
+
),
|
152 |
+
),
|
153 |
+
'settings' => array(
|
154 |
+
array(
|
155 |
+
'id' => 'theme_options_ui_text',
|
156 |
+
'label' => esc_html__( 'Theme Options UI Builder', 'option-tree' ),
|
157 |
+
'type' => 'theme_options_ui',
|
158 |
+
'section' => 'create_setting',
|
159 |
+
),
|
160 |
+
array(
|
161 |
+
'id' => 'import_settings_text',
|
162 |
+
'label' => esc_html__( 'Settings', 'option-tree' ),
|
163 |
+
'type' => 'import-settings',
|
164 |
+
'section' => 'import',
|
165 |
+
),
|
166 |
+
array(
|
167 |
+
'id' => 'import_data_text',
|
168 |
+
'label' => esc_html__( 'Theme Options', 'option-tree' ),
|
169 |
+
'type' => 'import-data',
|
170 |
+
'section' => 'import',
|
171 |
+
),
|
172 |
+
array(
|
173 |
+
'id' => 'import_layouts_text',
|
174 |
+
'label' => esc_html__( 'Layouts', 'option-tree' ),
|
175 |
+
'type' => 'import-layouts',
|
176 |
+
'section' => 'import',
|
177 |
+
),
|
178 |
+
array(
|
179 |
+
'id' => 'export_settings_file_text',
|
180 |
+
'label' => esc_html__( 'Settings PHP File', 'option-tree' ),
|
181 |
+
'type' => 'export-settings-file',
|
182 |
+
'section' => 'export',
|
183 |
+
),
|
184 |
+
array(
|
185 |
+
'id' => 'export_settings_text',
|
186 |
+
'label' => esc_html__( 'Settings', 'option-tree' ),
|
187 |
+
'type' => 'export-settings',
|
188 |
+
'section' => 'export',
|
189 |
+
),
|
190 |
+
array(
|
191 |
+
'id' => 'export_data_text',
|
192 |
+
'label' => esc_html__( 'Theme Options', 'option-tree' ),
|
193 |
+
'type' => 'export-data',
|
194 |
+
'section' => 'export',
|
195 |
+
),
|
196 |
+
array(
|
197 |
+
'id' => 'export_layout_text',
|
198 |
+
'label' => esc_html__( 'Layouts', 'option-tree' ),
|
199 |
+
'type' => 'export-layouts',
|
200 |
+
'section' => 'export',
|
201 |
+
),
|
202 |
+
array(
|
203 |
+
'id' => 'modify_layouts_text',
|
204 |
+
'label' => esc_html__( 'Layout Management', 'option-tree' ),
|
205 |
+
'type' => 'modify-layouts',
|
206 |
+
'section' => 'layouts',
|
207 |
+
),
|
208 |
+
),
|
209 |
+
),
|
210 |
+
array(
|
211 |
+
'id' => 'documentation',
|
212 |
+
'parent_slug' => 'ot-settings',
|
213 |
+
'page_title' => esc_html__( 'Documentation', 'option-tree' ),
|
214 |
+
'menu_title' => esc_html__( 'Documentation', 'option-tree' ),
|
215 |
+
'capability' => 'edit_theme_options',
|
216 |
+
'menu_slug' => 'ot-documentation',
|
217 |
+
'icon_url' => null,
|
218 |
+
'position' => null,
|
219 |
+
'updated_message' => esc_html__( 'Theme Options updated.', 'option-tree' ),
|
220 |
+
'reset_message' => esc_html__( 'Theme Options reset.', 'option-tree' ),
|
221 |
+
'button_text' => esc_html__( 'Save Settings', 'option-tree' ),
|
222 |
+
'show_buttons' => false,
|
223 |
+
'sections' => array(
|
224 |
+
array(
|
225 |
+
'id' => 'creating_options',
|
226 |
+
'title' => esc_html__( 'Creating Options', 'option-tree' ),
|
227 |
+
),
|
228 |
+
array(
|
229 |
+
'id' => 'option_types',
|
230 |
+
'title' => esc_html__( 'Option Types', 'option-tree' ),
|
231 |
+
),
|
232 |
+
array(
|
233 |
+
'id' => 'functions',
|
234 |
+
'title' => esc_html__( 'Function References', 'option-tree' ),
|
235 |
+
),
|
236 |
+
array(
|
237 |
+
'id' => 'theme_mode',
|
238 |
+
'title' => esc_html__( 'Theme Mode', 'option-tree' ),
|
239 |
+
),
|
240 |
+
array(
|
241 |
+
'id' => 'meta_boxes',
|
242 |
+
'title' => esc_html__( 'Meta Boxes', 'option-tree' ),
|
243 |
+
),
|
244 |
+
array(
|
245 |
+
'id' => 'examples',
|
246 |
+
'title' => esc_html__( 'Code Examples', 'option-tree' ),
|
247 |
+
),
|
248 |
+
array(
|
249 |
+
'id' => 'layouts_overview',
|
250 |
+
'title' => esc_html__( 'Layouts Overview', 'option-tree' ),
|
251 |
+
),
|
252 |
+
),
|
253 |
+
'settings' => array(
|
254 |
+
array(
|
255 |
+
'id' => 'creating_options_text',
|
256 |
+
'label' => esc_html__( 'Overview of available Theme Option fields.', 'option-tree' ),
|
257 |
+
'type' => 'creating-options',
|
258 |
+
'section' => 'creating_options',
|
259 |
+
),
|
260 |
+
array(
|
261 |
+
'id' => 'option_types_text',
|
262 |
+
'label' => esc_html__( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ),
|
263 |
+
'type' => 'option-types',
|
264 |
+
'section' => 'option_types',
|
265 |
+
),
|
266 |
+
array(
|
267 |
+
'id' => 'functions_ot_get_option',
|
268 |
+
'label' => esc_html__( 'Function Reference:ot_get_option()', 'option-tree' ),
|
269 |
+
'type' => 'ot-get-option',
|
270 |
+
'section' => 'functions',
|
271 |
+
),
|
272 |
+
array(
|
273 |
+
'id' => 'functions_get_option_tree',
|
274 |
+
'label' => esc_html__( 'Function Reference:get_option_tree()', 'option-tree' ),
|
275 |
+
'type' => 'get-option-tree',
|
276 |
+
'section' => 'functions',
|
277 |
+
),
|
278 |
+
array(
|
279 |
+
'id' => 'theme_mode_text',
|
280 |
+
'label' => esc_html__( 'Theme Mode', 'option-tree' ),
|
281 |
+
'type' => 'theme-mode',
|
282 |
+
'section' => 'theme_mode',
|
283 |
+
),
|
284 |
+
array(
|
285 |
+
'id' => 'meta_boxes_text',
|
286 |
+
'label' => esc_html__( 'Meta Boxes', 'option-tree' ),
|
287 |
+
'type' => 'meta-boxes',
|
288 |
+
'section' => 'meta_boxes',
|
289 |
+
),
|
290 |
+
array(
|
291 |
+
'id' => 'example_text',
|
292 |
+
'label' => esc_html__( 'Code examples for front-end development.', 'option-tree' ),
|
293 |
+
'type' => 'examples',
|
294 |
+
'section' => 'examples',
|
295 |
+
),
|
296 |
+
array(
|
297 |
+
'id' => 'layouts_overview_text',
|
298 |
+
'label' => esc_html__( 'What\'s a layout anyhow?', 'option-tree' ),
|
299 |
+
'type' => 'layouts-overview',
|
300 |
+
'section' => 'layouts_overview',
|
301 |
+
),
|
302 |
+
),
|
303 |
+
),
|
304 |
+
);
|
305 |
+
|
306 |
+
// Loop over the settings and remove as needed.
|
307 |
+
foreach ( $ot_register_pages_array as $key => $page ) {
|
308 |
+
|
309 |
+
// Remove various options from the Settings UI.
|
310 |
+
if ( 'settings' === $page['id'] ) {
|
311 |
+
|
312 |
+
// Remove the Theme Options UI.
|
313 |
+
if ( false === OT_SHOW_OPTIONS_UI ) {
|
314 |
+
|
315 |
+
foreach ( $page['sections'] as $section_key => $section ) {
|
316 |
+
if ( 'create_setting' === $section['id'] ) {
|
317 |
+
unset( $ot_register_pages_array[ $key ]['sections'][ $section_key ] );
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
322 |
+
if ( 'create_setting' === $setting['section'] ) {
|
323 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
324 |
+
}
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
// Remove parts of the Imports UI.
|
329 |
+
if ( false === OT_SHOW_SETTINGS_IMPORT ) {
|
330 |
+
|
331 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
332 |
+
if ( 'import' === $setting['section'] && in_array( $setting['id'], array( 'import_xml_text', 'import_settings_text' ), true ) ) {
|
333 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
|
338 |
+
// Remove parts of the Export UI.
|
339 |
+
if ( false === OT_SHOW_SETTINGS_EXPORT ) {
|
340 |
+
|
341 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
342 |
+
if ( 'export' === $setting['section'] && in_array( $setting['id'], array( 'export_settings_file_text', 'export_settings_text' ), true ) ) {
|
343 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
344 |
+
}
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
// Remove the Layouts UI.
|
349 |
+
if ( false === OT_SHOW_NEW_LAYOUT ) {
|
350 |
+
|
351 |
+
foreach ( $page['sections'] as $section_key => $section ) {
|
352 |
+
if ( 'layouts' === $section['id'] ) {
|
353 |
+
unset( $ot_register_pages_array[ $key ]['sections'][ $section_key ] );
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
foreach ( $page['settings'] as $setting_key => $setting ) {
|
358 |
+
if ( 'layouts' === $setting['section'] ) {
|
359 |
+
unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] );
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
// Remove the Documentation UI.
|
366 |
+
if ( false === OT_SHOW_DOCS && 'documentation' === $page['id'] ) {
|
367 |
+
unset( $ot_register_pages_array[ $key ] );
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
$ot_register_pages_array = apply_filters( 'ot_register_pages_array', $ot_register_pages_array );
|
372 |
+
|
373 |
+
// Register the pages.
|
374 |
+
ot_register_settings(
|
375 |
+
array(
|
376 |
+
array(
|
377 |
+
'id' => ot_settings_id(),
|
378 |
+
'pages' => $ot_register_pages_array,
|
379 |
+
),
|
380 |
+
)
|
381 |
+
);
|
382 |
+
|
383 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
}
|
385 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
if ( ! function_exists( 'ot_after_theme_options_save' ) ) {
|
387 |
|
388 |
+
/**
|
389 |
+
* Runs directly after the Theme Options are save.
|
390 |
+
*
|
391 |
+
* @access public
|
392 |
+
* @since 2.0
|
393 |
+
*/
|
394 |
+
function ot_after_theme_options_save() {
|
395 |
+
|
396 |
+
$page = isset( $_REQUEST['page'] ) ? esc_attr( wp_unslash( $_REQUEST['page'] ) ) : ''; // phpcs:ignore
|
397 |
+
$updated = isset( $_REQUEST['settings-updated'] ) && true === filter_var( wp_unslash( $_REQUEST['settings-updated'] ), FILTER_VALIDATE_BOOLEAN ); // phpcs:ignore
|
398 |
+
|
399 |
+
// Only execute after the theme options are saved.
|
400 |
+
if ( apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) === $page && $updated ) {
|
401 |
+
|
402 |
+
// Grab a copy of the theme options.
|
403 |
+
$options = get_option( ot_options_id() );
|
|
|
404 |
|
405 |
+
// Execute the action hook and pass the theme options to it.
|
406 |
+
do_action( 'ot_after_theme_options_save', $options );
|
407 |
+
}
|
408 |
+
}
|
409 |
}
|
410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
if ( ! function_exists( 'ot_validate_setting' ) ) {
|
412 |
|
413 |
+
/**
|
414 |
+
* Validate the options by type before saving.
|
415 |
+
*
|
416 |
+
* This function will run on only some of the option types
|
417 |
+
* as all of them don't need to be validated, just the
|
418 |
+
* ones users are going to input data into; because they
|
419 |
+
* can't be trusted.
|
420 |
+
*
|
421 |
+
* @param mixed $input Setting value.
|
422 |
+
* @param string $type Setting type.
|
423 |
+
* @param string $field_id Setting field ID.
|
424 |
+
* @param string $wmpl_id WPML field ID.
|
425 |
+
* @return mixed
|
426 |
+
*
|
427 |
+
* @access public
|
428 |
+
* @since 2.0
|
429 |
+
*/
|
430 |
+
function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
|
431 |
+
|
432 |
+
// Exit early if missing data.
|
433 |
+
if ( ! $input || ! $type || ! $field_id ) {
|
434 |
+
return $input;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Filter to modify a setting field value before validation.
|
439 |
+
*
|
440 |
+
* This cannot be used to filter the returned value of a custom
|
441 |
+
* setting type. You must use the `ot_validate_setting_input_safe`
|
442 |
+
* filter to ensure custom setting types are saved to the database.
|
443 |
+
*
|
444 |
+
* @param mixed $input The setting field value.
|
445 |
+
* @param string $type The setting field type.
|
446 |
+
* @param string $field_id The setting field ID.
|
447 |
+
*/
|
448 |
+
$input = apply_filters( 'ot_validate_setting', $input, $type, $field_id );
|
449 |
+
|
450 |
+
/**
|
451 |
+
* Filter to validate a setting field value.
|
452 |
+
*
|
453 |
+
* @param mixed $input_safe This is either null, or the filtered input value.
|
454 |
+
* @param mixed $input The setting field value.
|
455 |
+
* @param string $type The setting field type.
|
456 |
+
* @param string $field_id The setting field ID.
|
457 |
+
*/
|
458 |
+
$input_safe = apply_filters( 'ot_validate_setting_input_safe', null, $input, $type, $field_id );
|
459 |
+
|
460 |
+
// The value was filtered and is safe to return.
|
461 |
+
if ( ! is_null( $input_safe ) ) {
|
462 |
+
return $input_safe;
|
463 |
+
}
|
464 |
+
|
465 |
+
/* translators: %1$s: the input id, %2$s: the field id */
|
466 |
+
$string_nums = esc_html__( 'The %1$s input field for %2$s only allows numeric values.', 'option-tree' );
|
467 |
+
|
468 |
+
if ( 'background' === $type ) {
|
469 |
+
|
470 |
+
$input_safe = array();
|
471 |
+
|
472 |
+
// Loop over array and check for values.
|
473 |
+
foreach ( (array) $input as $key => $value ) {
|
474 |
+
if ( 'background-color' === $key ) {
|
475 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
476 |
+
} elseif ( 'background-image' === $key ) {
|
477 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'upload', $field_id );
|
478 |
+
} else {
|
479 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
480 |
+
}
|
481 |
+
}
|
482 |
+
} elseif ( 'border' === $type ) {
|
483 |
+
|
484 |
+
$input_safe = array();
|
485 |
+
|
486 |
+
// Loop over array and set errors or unset key from array.
|
487 |
+
foreach ( $input as $key => $value ) {
|
488 |
+
|
489 |
+
if ( empty( $value ) ) {
|
490 |
+
continue;
|
491 |
+
}
|
492 |
+
|
493 |
+
// Validate width.
|
494 |
+
if ( 'width' === $key ) {
|
495 |
+
if ( ! is_numeric( $value ) ) {
|
496 |
+
add_settings_error( 'option-tree', 'invalid_border_width', sprintf( $string_nums, '<code>width</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
497 |
+
} else {
|
498 |
+
$input_safe[ $key ] = absint( $value );
|
499 |
+
}
|
500 |
+
} elseif ( 'color' === $key ) {
|
501 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
502 |
+
} else {
|
503 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
504 |
+
}
|
505 |
+
}
|
506 |
+
} elseif ( 'box-shadow' === $type ) {
|
507 |
+
|
508 |
+
$input_safe = array();
|
509 |
+
|
510 |
+
// Loop over array and check for values.
|
511 |
+
foreach ( (array) $input as $key => $value ) {
|
512 |
+
if ( 'inset' === $key ) {
|
513 |
+
$input_safe[ $key ] = 'inset';
|
514 |
+
} elseif ( 'color' === $key ) {
|
515 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
516 |
+
} else {
|
517 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
518 |
+
}
|
519 |
+
}
|
520 |
+
} elseif ( 'checkbox' === $type ) {
|
521 |
+
|
522 |
+
$input_safe = array();
|
523 |
+
|
524 |
+
// Loop over array and check for values.
|
525 |
+
foreach ( (array) $input as $key => $value ) {
|
526 |
+
if ( ! empty( $value ) ) {
|
527 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
528 |
+
}
|
529 |
+
}
|
530 |
+
} elseif ( 'colorpicker' === $type ) {
|
531 |
+
|
532 |
+
$input_safe = '';
|
533 |
+
|
534 |
+
// Only strings are allowed.
|
535 |
+
if ( is_string( $input ) ) {
|
536 |
+
|
537 |
+
/* translators: %s: the field id */
|
538 |
+
$string_color = esc_html__( 'The %s Colorpicker only allows valid hexadecimal or rgba values depending on the setting type.', 'option-tree' );
|
539 |
+
|
540 |
+
if ( 0 === preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input ) && 0 === preg_match( '/^rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]{1,4})\s*\)/i', $input ) ) {
|
541 |
+
add_settings_error( 'option-tree', 'invalid_hex_or_rgba', sprintf( $string_color, '<code>' . $field_id . '</code>' ), 'error' );
|
542 |
+
} else {
|
543 |
+
$input_safe = $input;
|
544 |
+
}
|
545 |
+
}
|
546 |
+
} elseif ( 'colorpicker-opacity' === $type ) {
|
547 |
+
$input_safe = ot_validate_setting( $input, 'colorpicker', $field_id );
|
548 |
+
} elseif ( in_array( $type, array( 'category-checkbox', 'custom-post-type-checkbox', 'page-checkbox', 'post-checkbox', 'tag-checkbox', 'taxonomy-checkbox' ), true ) ) {
|
549 |
+
|
550 |
+
$input_safe = array();
|
551 |
+
|
552 |
+
// Loop over array and check for values.
|
553 |
+
foreach ( (array) $input as $key => $value ) {
|
554 |
+
if ( filter_var( $value, FILTER_VALIDATE_INT ) && 0 < $value ) {
|
555 |
+
$input_safe[ $key ] = absint( $value );
|
556 |
+
}
|
557 |
+
}
|
558 |
+
} elseif ( in_array( $type, array( 'category-select', 'custom-post-type-select', 'page-select', 'post-select', 'tag-select', 'taxonomy-select' ), true ) ) {
|
559 |
+
|
560 |
+
$input_safe = '';
|
561 |
+
|
562 |
+
if ( filter_var( $input, FILTER_VALIDATE_INT ) && 0 < $input ) {
|
563 |
+
$input_safe = absint( $input );
|
564 |
+
}
|
565 |
+
} elseif ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ), true ) ) {
|
566 |
+
$filter = function( $tags, $context ) {
|
567 |
+
if ( 'post' === $context ) {
|
568 |
+
if ( current_user_can( 'unfiltered_html' ) || true === OT_ALLOW_UNFILTERED_HTML ) {
|
569 |
+
$tags['script'] = array_fill_keys( array( 'async', 'charset', 'defer', 'src', 'type' ), 1 );
|
570 |
+
$tags['style'] = array_fill_keys( array( 'media', 'type' ), 1 );
|
571 |
+
$tags['iframe'] = array_fill_keys( array( 'align', 'frameborder', 'height', 'longdesc', 'marginheight', 'marginwidth', 'name', 'sandbox', 'scrolling', 'src', 'srcdoc', 'width' ), 1 );
|
572 |
+
|
573 |
+
$tags = apply_filters( 'ot_allowed_html', $tags );
|
574 |
+
}
|
575 |
+
}
|
576 |
+
return $tags;
|
577 |
+
};
|
578 |
+
|
579 |
+
add_filter( 'wp_kses_allowed_html', $filter, 10, 2 );
|
580 |
+
$input_safe = wp_kses_post( $input );
|
581 |
+
remove_filter( 'wp_kses_allowed_html', $filter );
|
582 |
+
} elseif ( 'date-picker' === $type || 'date-time-picker' === $type ) {
|
583 |
+
if ( ! empty( $input ) && (bool) strtotime( $input ) ) {
|
584 |
+
$input_safe = sanitize_text_field( $input );
|
585 |
+
}
|
586 |
+
} elseif ( 'dimension' === $type ) {
|
587 |
+
|
588 |
+
$input_safe = array();
|
589 |
+
|
590 |
+
// Loop over array and set errors.
|
591 |
+
foreach ( $input as $key => $value ) {
|
592 |
+
if ( ! empty( $value ) ) {
|
593 |
+
if ( ! is_numeric( $value ) && 'unit' !== $key ) {
|
594 |
+
add_settings_error( 'option-tree', 'invalid_dimension_' . $key, sprintf( $string_nums, '<code>' . $key . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
595 |
+
} else {
|
596 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
597 |
+
}
|
598 |
+
}
|
599 |
+
}
|
600 |
+
} elseif ( 'gallery' === $type ) {
|
601 |
+
|
602 |
+
$input_safe = '';
|
603 |
+
|
604 |
+
if ( '' !== trim( $input ) ) {
|
605 |
+
$input_safe = sanitize_text_field( $input );
|
606 |
+
}
|
607 |
+
} elseif ( 'google-fonts' === $type ) {
|
608 |
+
|
609 |
+
$input_safe = array();
|
610 |
+
|
611 |
+
// Loop over array.
|
612 |
+
foreach ( $input as $key => $value ) {
|
613 |
+
if ( '%key%' === $key ) {
|
614 |
+
continue;
|
615 |
+
}
|
616 |
+
|
617 |
+
foreach ( $value as $fk => $fvalue ) {
|
618 |
+
if ( is_array( $fvalue ) ) {
|
619 |
+
foreach ( $fvalue as $sk => $svalue ) {
|
620 |
+
$input_safe[ $key ][ $fk ][ $sk ] = sanitize_text_field( $svalue );
|
621 |
+
}
|
622 |
+
} else {
|
623 |
+
$input_safe[ $key ][ $fk ] = sanitize_text_field( $fvalue );
|
624 |
+
}
|
625 |
+
}
|
626 |
+
}
|
627 |
+
|
628 |
+
array_values( $input_safe );
|
629 |
+
} elseif ( 'link-color' === $type ) {
|
630 |
+
|
631 |
+
$input_safe = array();
|
632 |
+
|
633 |
+
// Loop over array and check for values.
|
634 |
+
if ( is_array( $input ) && ! empty( $input ) ) {
|
635 |
+
foreach ( $input as $key => $value ) {
|
636 |
+
if ( ! empty( $value ) ) {
|
637 |
+
$input_safe[ $key ] = ot_validate_setting( $input[ $key ], 'colorpicker', $field_id . '-' . $key );
|
638 |
+
}
|
639 |
+
}
|
640 |
+
}
|
641 |
+
|
642 |
+
array_filter( $input_safe );
|
643 |
+
} elseif ( 'measurement' === $type ) {
|
644 |
+
|
645 |
+
$input_safe = array();
|
646 |
+
|
647 |
+
foreach ( $input as $key => $value ) {
|
648 |
+
if ( ! empty( $value ) ) {
|
649 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
650 |
+
}
|
651 |
+
}
|
652 |
+
} elseif ( 'numeric-slider' === $type ) {
|
653 |
+
$input_safe = '';
|
654 |
+
|
655 |
+
if ( ! empty( $input ) ) {
|
656 |
+
if ( ! is_numeric( $input ) ) {
|
657 |
+
add_settings_error( 'option-tree', 'invalid_numeric_slider', sprintf( $string_nums, '<code>' . esc_html__( 'slider', 'option-tree' ) . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
658 |
+
} else {
|
659 |
+
$input_safe = sanitize_text_field( $input );
|
660 |
+
}
|
661 |
+
}
|
662 |
+
} elseif ( 'on-off' === $type ) {
|
663 |
+
$input_safe = '';
|
664 |
+
|
665 |
+
if ( ! empty( $input ) ) {
|
666 |
+
$input_safe = sanitize_text_field( $input );
|
667 |
+
}
|
668 |
+
} elseif ( 'radio' === $type || 'radio-image' === $type || 'select' === $type || 'sidebar-select' === $type ) {
|
669 |
+
$input_safe = '';
|
670 |
+
|
671 |
+
if ( ! empty( $input ) ) {
|
672 |
+
$input_safe = sanitize_text_field( $input );
|
673 |
+
}
|
674 |
+
} elseif ( 'spacing' === $type ) {
|
675 |
+
|
676 |
+
$input_safe = array();
|
677 |
+
|
678 |
+
// Loop over array and set errors.
|
679 |
+
foreach ( $input as $key => $value ) {
|
680 |
+
if ( ! empty( $value ) ) {
|
681 |
+
if ( ! is_numeric( $value ) && 'unit' !== $key ) {
|
682 |
+
add_settings_error( 'option-tree', 'invalid_spacing_' . $key, sprintf( $string_nums, '<code>' . $key . '</code>', '<code>' . $field_id . '</code>' ), 'error' );
|
683 |
+
} else {
|
684 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
685 |
+
}
|
686 |
+
}
|
687 |
+
}
|
688 |
+
} elseif ( 'typography' === $type && isset( $input['font-color'] ) ) {
|
689 |
+
|
690 |
+
$input_safe = array();
|
691 |
+
|
692 |
+
// Loop over array and check for values.
|
693 |
+
foreach ( $input as $key => $value ) {
|
694 |
+
if ( 'font-color' === $key ) {
|
695 |
+
$input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id );
|
696 |
+
} else {
|
697 |
+
$input_safe[ $key ] = sanitize_text_field( $value );
|
698 |
+
}
|
699 |
+
}
|
700 |
+
} elseif ( 'upload' === $type ) {
|
701 |
+
|
702 |
+
$input_safe = filter_var( $input, FILTER_VALIDATE_INT );
|
703 |
+
|
704 |
+
if ( false === $input_safe && is_string( $input ) ) {
|
705 |
+
$input_safe = esc_url_raw( $input );
|
706 |
+
}
|
707 |
+
} elseif ( 'url' === $type ) {
|
708 |
+
|
709 |
+
$input_safe = '';
|
710 |
+
|
711 |
+
if ( ! empty( $input ) ) {
|
712 |
+
$input_safe = esc_url_raw( $input );
|
713 |
+
}
|
714 |
+
} else {
|
715 |
+
|
716 |
+
/* translators: %1$s: the calling function, %2$s the filter name, %3$s the option type, %4$s the version number */
|
717 |
+
$string_error = esc_html__( 'Notice: %1$s was called incorrectly. All stored data must be filtered through %2$s, the %3$s option type is not using this filter. This is required since version %4$s.', 'option-tree' );
|
718 |
+
|
719 |
+
// Log a user notice that things have changed since the last version.
|
720 |
+
add_settings_error( 'option-tree', 'ot_validate_setting_error', sprintf( $string_error, '<code>ot_validate_setting</code>', '<code>ot_validate_setting_input_safe</code>', '<code>' . $type . '</code>', '<code>2.7.0</code>' ), 'error' );
|
721 |
+
|
722 |
+
$input_safe = '';
|
723 |
+
|
724 |
+
/*
|
725 |
+
* We don't know what the setting type is, so fallback to `sanitize_textarea_field`
|
726 |
+
* on all values and do a best-effort sanitize of the user data before saving it.
|
727 |
+
*/
|
728 |
+
if ( ! is_object( $input ) ) {
|
729 |
+
|
730 |
+
// Contains an integer, float, string or boolean.
|
731 |
+
if ( is_scalar( $input ) ) {
|
732 |
+
$input_safe = sanitize_textarea_field( $input );
|
733 |
+
} else {
|
734 |
+
|
735 |
+
/**
|
736 |
+
* Filter the array values recursively.
|
737 |
+
*
|
738 |
+
* @param array $values The value to sanitize.
|
739 |
+
*
|
740 |
+
* @return array
|
741 |
+
*/
|
742 |
+
function _sanitize_recursive( $values = array() ) {
|
743 |
+
$result = array();
|
744 |
+
foreach ( $values as $key => $value ) {
|
745 |
+
if ( ! is_object( $value ) ) {
|
746 |
+
if ( is_scalar( $value ) ) {
|
747 |
+
$result[ $key ] = sanitize_textarea_field( $value );
|
748 |
+
} else {
|
749 |
+
$result[ $key ] = _sanitize_recursive( $value );
|
750 |
+
}
|
751 |
+
}
|
752 |
+
}
|
753 |
+
|
754 |
+
return $result;
|
755 |
+
}
|
756 |
+
|
757 |
+
$input_safe = _sanitize_recursive( $input );
|
758 |
+
}
|
759 |
+
}
|
760 |
+
}
|
761 |
+
|
762 |
+
// WPML Register and Unregister strings.
|
763 |
+
if ( ! empty( $wmpl_id ) ) {
|
764 |
+
|
765 |
+
// Allow filtering on the WPML option types.
|
766 |
+
$single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) );
|
767 |
+
|
768 |
+
if ( in_array( $type, $single_string_types, true ) ) {
|
769 |
+
if ( ! empty( $input_safe ) ) {
|
770 |
+
ot_wpml_register_string( $wmpl_id, $input_safe );
|
771 |
+
} else {
|
772 |
+
ot_wpml_unregister_string( $wmpl_id );
|
773 |
+
}
|
774 |
+
}
|
775 |
+
}
|
776 |
+
|
777 |
+
/**
|
778 |
+
* Filter to modify the validated setting field value.
|
779 |
+
*
|
780 |
+
* It's important to note that the filter does not have access to
|
781 |
+
* the original value and can only modify the validated input value.
|
782 |
+
* This is a breaking change as of version 2.7.0.
|
783 |
+
*
|
784 |
+
* @param mixed $input_safe The setting field value.
|
785 |
+
* @param string $type The setting field type.
|
786 |
+
* @param string $field_id The setting field ID.
|
787 |
+
*/
|
788 |
+
$input_safe = apply_filters( 'ot_after_validate_setting', $input_safe, $type, $field_id );
|
789 |
+
|
790 |
+
return $input_safe;
|
791 |
+
}
|
792 |
}
|
793 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
794 |
if ( ! function_exists( 'ot_admin_styles' ) ) {
|
795 |
|
796 |
+
/**
|
797 |
+
* Setup the default admin styles
|
798 |
+
*
|
799 |
+
* @access public
|
800 |
+
* @since 2.0
|
801 |
+
*/
|
802 |
+
function ot_admin_styles() {
|
803 |
+
global $wp_styles, $post;
|
804 |
+
|
805 |
+
// Execute styles before actions.
|
806 |
+
do_action( 'ot_admin_styles_before' );
|
807 |
+
|
808 |
+
// Load WP colorpicker.
|
809 |
+
wp_enqueue_style( 'wp-color-picker' );
|
810 |
+
|
811 |
+
// Load admin styles.
|
812 |
+
wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION );
|
813 |
+
|
814 |
+
// Load the RTL stylesheet.
|
815 |
+
$wp_styles->add_data( 'ot-admin-css', 'rtl', true );
|
816 |
+
|
817 |
+
// Remove styles added by the Easy Digital Downloads plugin.
|
818 |
+
if ( isset( $post->post_type ) && 'post' === $post->post_type ) {
|
819 |
+
wp_dequeue_style( 'jquery-ui-css' );
|
820 |
+
}
|
821 |
+
|
822 |
+
/**
|
823 |
+
* Filter the screen IDs used to dequeue `jquery-ui-css`.
|
824 |
+
*
|
825 |
+
* @since 2.5.0
|
826 |
+
*
|
827 |
+
* @param array $screen_ids An array of screen IDs.
|
828 |
+
*/
|
829 |
+
$screen_ids = apply_filters(
|
830 |
+
'ot_dequeue_jquery_ui_css_screen_ids',
|
831 |
+
array(
|
832 |
+
'toplevel_page_ot-settings',
|
833 |
+
'optiontree_page_ot-documentation',
|
834 |
+
'appearance_page_ot-theme-options',
|
835 |
+
)
|
836 |
+
);
|
837 |
+
|
838 |
+
// Remove styles added by the WP Review plugin and any custom pages added through filtering.
|
839 |
+
if ( in_array( get_current_screen()->id, $screen_ids, true ) ) {
|
840 |
+
wp_dequeue_style( 'plugin_name-admin-ui-css' );
|
841 |
+
wp_dequeue_style( 'jquery-ui-css' );
|
842 |
+
}
|
843 |
+
|
844 |
+
// Execute styles after actions.
|
845 |
+
do_action( 'ot_admin_styles_after' );
|
846 |
+
}
|
847 |
}
|
848 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
849 |
if ( ! function_exists( 'ot_admin_scripts' ) ) {
|
850 |
|
851 |
+
/**
|
852 |
+
* Setup the default admin scripts.
|
853 |
+
*
|
854 |
+
* @uses add_thickbox() Include Thickbox for file uploads.
|
855 |
+
* @uses wp_enqueue_script() Add OptionTree scripts.
|
856 |
+
* @uses wp_localize_script() Used to include arbitrary Javascript data.
|
857 |
+
*
|
858 |
+
* @access public
|
859 |
+
* @since 2.0
|
860 |
+
*/
|
861 |
+
function ot_admin_scripts() {
|
862 |
+
|
863 |
+
// Execute scripts before actions.
|
864 |
+
do_action( 'ot_admin_scripts_before' );
|
865 |
+
|
866 |
+
if ( function_exists( 'wp_enqueue_media' ) ) {
|
867 |
+
// WP 3.5 Media Uploader.
|
868 |
+
wp_enqueue_media();
|
869 |
+
} else {
|
870 |
+
// Legacy Thickbox.
|
871 |
+
add_thickbox();
|
872 |
+
}
|
873 |
+
|
874 |
+
// Load jQuery-ui slider.
|
875 |
+
wp_enqueue_script( 'jquery-ui-slider' );
|
876 |
+
|
877 |
+
// Load jQuery-ui datepicker.
|
878 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
879 |
+
|
880 |
+
// Load WP colorpicker.
|
881 |
+
wp_enqueue_script( 'wp-color-picker' );
|
882 |
+
|
883 |
+
// Load Ace Editor for CSS Editing.
|
884 |
+
wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js', null, '1.1.3', false );
|
885 |
+
|
886 |
+
// Load jQuery UI timepicker addon.
|
887 |
+
wp_enqueue_script( 'jquery-ui-timepicker', OT_URL . 'assets/js/vendor/jquery/jquery-ui-timepicker.js', array( 'jquery', 'jquery-ui-slider', 'jquery-ui-datepicker' ), '1.4.3', false );
|
888 |
+
|
889 |
+
// Load the post formats.
|
890 |
+
if ( true === OT_META_BOXES && true === OT_POST_FORMATS ) {
|
891 |
+
wp_enqueue_script( 'ot-postformats', OT_URL . 'assets/js/ot-postformats.js', array( 'jquery' ), '1.0.1', false );
|
892 |
+
}
|
893 |
+
|
894 |
+
// Load all the required scripts.
|
895 |
+
wp_enqueue_script( 'ot-admin-js', OT_URL . 'assets/js/ot-admin.js', array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-sortable', 'jquery-ui-slider', 'wp-color-picker', 'ace-editor', 'jquery-ui-datepicker', 'jquery-ui-timepicker' ), OT_VERSION, false );
|
896 |
+
|
897 |
+
// Create localized JS array.
|
898 |
+
$localized_array = array(
|
899 |
+
'ajax' => admin_url( 'admin-ajax.php' ),
|
900 |
+
'nonce' => wp_create_nonce( 'option_tree' ),
|
901 |
+
'upload_text' => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ),
|
902 |
+
'remove_media_text' => esc_html__( 'Remove Media', 'option-tree' ),
|
903 |
+
'reset_agree' => esc_html__( 'Are you sure you want to reset back to the defaults?', 'option-tree' ),
|
904 |
+
'remove_no' => esc_html__( 'You can\'t remove this! But you can edit the values.', 'option-tree' ),
|
905 |
+
'remove_agree' => esc_html__( 'Are you sure you want to remove this?', 'option-tree' ),
|
906 |
+
'activate_layout_agree' => esc_html__( 'Are you sure you want to activate this layout?', 'option-tree' ),
|
907 |
+
'setting_limit' => esc_html__( 'Sorry, you can\'t have settings three levels deep.', 'option-tree' ),
|
908 |
+
'delete' => esc_html__( 'Delete Gallery', 'option-tree' ),
|
909 |
+
'edit' => esc_html__( 'Edit Gallery', 'option-tree' ),
|
910 |
+
'create' => esc_html__( 'Create Gallery', 'option-tree' ),
|
911 |
+
'confirm' => esc_html__( 'Are you sure you want to delete this Gallery?', 'option-tree' ),
|
912 |
+
'date_current' => esc_html__( 'Today', 'option-tree' ),
|
913 |
+
'date_time_current' => esc_html__( 'Now', 'option-tree' ),
|
914 |
+
'date_close' => esc_html__( 'Close', 'option-tree' ),
|
915 |
+
'replace' => esc_html__( 'Featured Image', 'option-tree' ),
|
916 |
+
'with' => esc_html__( 'Image', 'option-tree' ),
|
917 |
+
);
|
918 |
+
|
919 |
+
// Localized script attached to 'option_tree'.
|
920 |
+
wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array );
|
921 |
+
|
922 |
+
// Execute scripts after actions.
|
923 |
+
do_action( 'ot_admin_scripts_after' );
|
924 |
+
}
|
925 |
}
|
926 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
927 |
if ( ! function_exists( 'ot_get_media_post_ID' ) ) {
|
928 |
|
929 |
+
/**
|
930 |
+
* Returns the ID of a custom post type by post_title.
|
931 |
+
*
|
932 |
+
* @return int
|
933 |
+
*
|
934 |
+
* @access public
|
935 |
+
* @since 2.0
|
936 |
+
* @updated 2.7.0
|
937 |
+
*/
|
938 |
+
function ot_get_media_post_ID() { // phpcs:ignore
|
939 |
+
|
940 |
+
// Option ID.
|
941 |
+
$option_id = 'ot_media_post_ID';
|
942 |
+
|
943 |
+
// Get the media post ID.
|
944 |
+
$post_ID = get_option( $option_id, false );
|
945 |
+
|
946 |
+
// Add $post_ID to the DB.
|
947 |
+
if ( false === $post_ID || empty( $post_ID ) || ! is_integer( $post_ID ) ) {
|
948 |
+
global $wpdb;
|
949 |
+
|
950 |
+
// Get the media post ID.
|
951 |
+
$post_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts p WHERE p.post_title = %s AND p.post_type = %s AND p.post_status = %s", 'Media', 'option-tree', 'private' ) ); // phpcs:ignore
|
952 |
+
|
953 |
+
// Add to the DB.
|
954 |
+
if ( null !== $post_ID && 0 < $post_ID ) {
|
955 |
+
update_option( $option_id, $post_ID );
|
956 |
+
} else {
|
957 |
+
$post_ID = 0;
|
958 |
+
}
|
959 |
+
}
|
960 |
+
|
961 |
+
return $post_ID;
|
962 |
+
}
|
963 |
}
|
964 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
965 |
if ( ! function_exists( 'ot_create_media_post' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
|
967 |
+
/**
|
968 |
+
* Register custom post type & create the media post used to attach images.
|
969 |
+
*
|
970 |
+
* @access public
|
971 |
+
* @since 2.0
|
972 |
+
*/
|
973 |
+
function ot_create_media_post() {
|
974 |
+
|
975 |
+
register_post_type(
|
976 |
+
'option-tree',
|
977 |
+
array(
|
978 |
+
'labels' => array( 'name' => esc_html__( 'Option Tree', 'option-tree' ) ),
|
979 |
+
'public' => false,
|
980 |
+
'show_ui' => false,
|
981 |
+
'capability_type' => 'post',
|
982 |
+
'exclude_from_search' => true,
|
983 |
+
'hierarchical' => false,
|
984 |
+
'rewrite' => false,
|
985 |
+
'supports' => array( 'title', 'editor' ),
|
986 |
+
'can_export' => false,
|
987 |
+
'show_in_nav_menus' => false,
|
988 |
+
)
|
989 |
+
);
|
990 |
+
|
991 |
+
// Look for custom page.
|
992 |
+
$post_id = ot_get_media_post_ID();
|
993 |
+
|
994 |
+
// No post exists.
|
995 |
+
if ( 0 === $post_id ) {
|
996 |
+
|
997 |
+
// Insert the post into the database.
|
998 |
+
wp_insert_post(
|
999 |
+
array(
|
1000 |
+
'post_title' => 'Media',
|
1001 |
+
'post_name' => 'media',
|
1002 |
+
'post_status' => 'private',
|
1003 |
+
'post_type' => 'option-tree',
|
1004 |
+
'comment_status' => 'closed',
|
1005 |
+
'ping_status' => 'closed',
|
1006 |
+
)
|
1007 |
+
);
|
1008 |
+
}
|
1009 |
+
}
|
1010 |
}
|
1011 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1012 |
if ( ! function_exists( 'ot_default_settings' ) ) {
|
1013 |
|
1014 |
+
/**
|
1015 |
+
* Setup default settings array.
|
1016 |
+
*
|
1017 |
+
* @access public
|
1018 |
+
* @since 2.0
|
1019 |
+
*/
|
1020 |
+
function ot_default_settings() {
|
1021 |
+
global $wpdb;
|
1022 |
+
|
1023 |
+
if ( ! get_option( ot_settings_id() ) ) {
|
1024 |
+
|
1025 |
+
$section_count = 0;
|
1026 |
+
$settings_count = 0;
|
1027 |
+
$settings = array();
|
1028 |
+
$table_name = $wpdb->prefix . 'option_tree';
|
1029 |
+
|
1030 |
+
$find_table = wp_cache_get( 'find_table', 'option_tree' );
|
1031 |
+
if ( false === $find_table ) {
|
1032 |
+
$find_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ); // phpcs:ignore
|
1033 |
+
wp_cache_set( 'find_table', $find_table, 'option_tree', 86400 );
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
if ( $find_table === $table_name ) {
|
1037 |
+
|
1038 |
+
$old_settings = wp_cache_get( 'old_settings', 'option_tree' );
|
1039 |
+
if ( false === $old_settings ) {
|
1040 |
+
$old_settings = $wpdb->get_results( "SELECT * FROM ${table_name} ORDER BY item_sort ASC" ); // phpcs:ignore
|
1041 |
+
wp_cache_set( 'old_settings', $old_settings, 'option_tree', 86400 );
|
1042 |
+
}
|
1043 |
+
|
1044 |
+
if ( ! $old_settings ) {
|
1045 |
+
return;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
foreach ( $old_settings as $setting ) {
|
1049 |
+
|
1050 |
+
// Heading is a section now.
|
1051 |
+
if ( 'heading' === $setting->item_type ) {
|
1052 |
+
|
1053 |
+
// Add section to the sections array.
|
1054 |
+
$settings['sections'][ $section_count ]['id'] = $setting->item_id;
|
1055 |
+
$settings['sections'][ $section_count ]['title'] = $setting->item_title;
|
1056 |
+
|
1057 |
+
// Ssave the last section id to use in creating settings.
|
1058 |
+
$section = $setting->item_id;
|
1059 |
+
|
1060 |
+
// Increment the section count.
|
1061 |
+
$section_count++;
|
1062 |
+
|
1063 |
+
} else {
|
1064 |
+
|
1065 |
+
// Add setting to the settings array.
|
1066 |
+
$settings['settings'][ $settings_count ]['id'] = $setting->item_id;
|
1067 |
+
$settings['settings'][ $settings_count ]['label'] = $setting->item_title;
|
1068 |
+
$settings['settings'][ $settings_count ]['desc'] = $setting->item_desc;
|
1069 |
+
$settings['settings'][ $settings_count ]['section'] = $section;
|
1070 |
+
$settings['settings'][ $settings_count ]['type'] = ot_map_old_option_types( $setting->item_type );
|
1071 |
+
$settings['settings'][ $settings_count ]['std'] = '';
|
1072 |
+
$settings['settings'][ $settings_count ]['class'] = '';
|
1073 |
+
|
1074 |
+
// Textarea rows.
|
1075 |
+
$rows = '';
|
1076 |
+
if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'css', 'javascript', 'textarea' ), true ) ) {
|
1077 |
+
if ( (int) $setting->item_options > 0 ) {
|
1078 |
+
$rows = (int) $setting->item_options;
|
1079 |
+
} else {
|
1080 |
+
$rows = 15;
|
1081 |
+
}
|
1082 |
+
}
|
1083 |
+
$settings['settings'][ $settings_count ]['rows'] = $rows;
|
1084 |
+
|
1085 |
+
// Post type.
|
1086 |
+
$post_type = '';
|
1087 |
+
if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ), true ) ) {
|
1088 |
+
if ( '' !== $setting->item_options ) {
|
1089 |
+
$post_type = $setting->item_options;
|
1090 |
+
} else {
|
1091 |
+
$post_type = 'post';
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
$settings['settings'][ $settings_count ]['post_type'] = $post_type;
|
1095 |
+
|
1096 |
+
// Cchoices.
|
1097 |
+
$choices = array();
|
1098 |
+
if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'checkbox', 'radio', 'select' ), true ) ) {
|
1099 |
+
if ( '' !== $setting->item_options ) {
|
1100 |
+
$choices = ot_convert_string_to_array( $setting->item_options );
|
1101 |
+
}
|
1102 |
+
}
|
1103 |
+
$settings['settings'][ $settings_count ]['choices'] = $choices;
|
1104 |
+
|
1105 |
+
$settings_count++;
|
1106 |
+
}
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
// Make sure each setting has a section just in case.
|
1110 |
+
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
1111 |
+
foreach ( $settings['settings'] as $k => $setting ) {
|
1112 |
+
if ( '' === $setting['section'] ) {
|
1113 |
+
$settings['settings'][ $k ]['section'] = $settings['sections'][0]['id'];
|
1114 |
+
}
|
1115 |
+
}
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
// If array if not properly formed create fallback settings array.
|
1120 |
+
if ( ! isset( $settings['sections'] ) || ! isset( $settings['settings'] ) ) {
|
1121 |
+
|
1122 |
+
$settings = array(
|
1123 |
+
'sections' => array(
|
1124 |
+
array(
|
1125 |
+
'id' => 'general',
|
1126 |
+
'title' => esc_html__( 'General', 'option-tree' ),
|
1127 |
+
),
|
1128 |
+
),
|
1129 |
+
'settings' => array(
|
1130 |
+
array(
|
1131 |
+
'id' => 'sample_text',
|
1132 |
+
'label' => esc_html__( 'Sample Text Field Label', 'option-tree' ),
|
1133 |
+
'desc' => esc_html__( 'Description for the sample text field.', 'option-tree' ),
|
1134 |
+
'section' => 'general',
|
1135 |
+
'type' => 'text',
|
1136 |
+
'std' => '',
|
1137 |
+
'class' => '',
|
1138 |
+
'rows' => '',
|
1139 |
+
'post_type' => '',
|
1140 |
+
'choices' => array(),
|
1141 |
+
),
|
1142 |
+
),
|
1143 |
+
);
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
// Update the settings array.
|
1147 |
+
update_option( ot_settings_id(), $settings );
|
1148 |
+
|
1149 |
+
// Get option tree array.
|
1150 |
+
$options = get_option( ot_options_id() );
|
1151 |
+
|
1152 |
+
$options_safe = array();
|
1153 |
+
|
1154 |
+
// Validate options.
|
1155 |
+
if ( is_array( $options ) ) {
|
1156 |
+
|
1157 |
+
foreach ( $settings['settings'] as $setting ) {
|
1158 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
1159 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
1160 |
+
}
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
// Execute the action hook and pass the theme options to it.
|
1164 |
+
do_action( 'ot_before_theme_options_save', $options_safe );
|
1165 |
+
|
1166 |
+
// Update the option tree array.
|
1167 |
+
update_option( ot_options_id(), $options_safe );
|
1168 |
+
}
|
1169 |
+
}
|
1170 |
+
}
|
1171 |
}
|
1172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1173 |
if ( ! function_exists( 'ot_save_css' ) ) {
|
1174 |
|
1175 |
+
/**
|
1176 |
+
* Helper function to update the CSS option type after save.
|
1177 |
+
*
|
1178 |
+
* This function is called during the `ot_after_theme_options_save` hook,
|
1179 |
+
* which is passed the currently stored options array.
|
1180 |
+
*
|
1181 |
+
* @param array $options The current stored options array.
|
1182 |
+
*
|
1183 |
+
* @access public
|
1184 |
+
* @since 2.0
|
1185 |
+
*/
|
1186 |
+
function ot_save_css( $options ) {
|
1187 |
+
|
1188 |
+
// Grab a copy of the settings.
|
1189 |
+
$settings = get_option( ot_settings_id() );
|
1190 |
+
|
1191 |
+
// Has settings.
|
1192 |
+
if ( isset( $settings['settings'] ) ) {
|
1193 |
+
|
1194 |
+
// Loop through sections and insert CSS when needed.
|
1195 |
+
foreach ( $settings['settings'] as $k => $setting ) {
|
1196 |
+
|
1197 |
+
// Is the CSS option type.
|
1198 |
+
if ( isset( $setting['type'] ) && 'css' === $setting['type'] ) {
|
1199 |
+
|
1200 |
+
// Insert CSS into dynamic.css.
|
1201 |
+
if ( isset( $options[ $setting['id'] ] ) && '' !== $options[ $setting['id'] ] ) {
|
1202 |
+
ot_insert_css_with_markers( $setting['id'], $options[ $setting['id'] ] );
|
1203 |
+
|
1204 |
+
// Remove old CSS from dynamic.css.
|
1205 |
+
} else {
|
1206 |
+
ot_remove_old_css( $setting['id'] );
|
1207 |
+
}
|
1208 |
+
}
|
1209 |
+
}
|
1210 |
+
}
|
1211 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1212 |
}
|
1213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1214 |
if ( ! function_exists( 'ot_import' ) ) {
|
1215 |
|
1216 |
+
/**
|
1217 |
+
* Import before the screen is displayed.
|
1218 |
+
*
|
1219 |
+
* @access public
|
1220 |
+
* @since 2.0
|
1221 |
+
*/
|
1222 |
+
function ot_import() {
|
1223 |
+
|
1224 |
+
// Check and verify import settings nonce.
|
1225 |
+
if ( isset( $_POST['import_settings_nonce'] ) && wp_verify_nonce( $_POST['import_settings_nonce'], 'import_settings_form' ) ) { // phpcs:ignore
|
1226 |
+
|
1227 |
+
// Default message.
|
1228 |
+
$message = 'failed';
|
1229 |
+
|
1230 |
+
$settings = isset( $_POST['import_settings'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_settings'] ) ) ) : array();
|
1231 |
+
|
1232 |
+
if ( is_array( $settings ) && ! empty( $settings ) ) {
|
1233 |
+
|
1234 |
+
$settings_safe = ot_validate_settings( $settings );
|
1235 |
+
|
1236 |
+
// Save & show success message.
|
1237 |
+
if ( is_array( $settings_safe ) ) {
|
1238 |
+
update_option( ot_settings_id(), $settings_safe );
|
1239 |
+
$message = 'success';
|
1240 |
+
}
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
// Redirect back to self.
|
1244 |
+
wp_safe_redirect(
|
1245 |
+
esc_url_raw(
|
1246 |
+
add_query_arg(
|
1247 |
+
array(
|
1248 |
+
'action' => 'import-settings',
|
1249 |
+
'message' => $message,
|
1250 |
+
),
|
1251 |
+
wp_get_referer()
|
1252 |
+
)
|
1253 |
+
)
|
1254 |
+
);
|
1255 |
+
exit;
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
// Check and verify import theme options data nonce.
|
1259 |
+
if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) { // phpcs:ignore
|
1260 |
+
|
1261 |
+
// Default message.
|
1262 |
+
$message = 'failed';
|
1263 |
+
$options = isset( $_POST['import_data'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_data'] ) ) ) : array();
|
1264 |
+
|
1265 |
+
if ( $options ) {
|
1266 |
+
|
1267 |
+
$options_safe = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1268 |
|
1269 |
+
// Get settings array.
|
1270 |
+
$settings = get_option( ot_settings_id() );
|
1271 |
+
|
1272 |
+
// Has options.
|
1273 |
+
if ( is_array( $options ) ) {
|
1274 |
+
|
1275 |
+
// Validate options.
|
1276 |
+
if ( is_array( $settings ) ) {
|
1277 |
+
foreach ( $settings['settings'] as $setting ) {
|
1278 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
1279 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
1280 |
+
}
|
1281 |
+
}
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
// Execute the action hook and pass the theme options to it.
|
1285 |
+
do_action( 'ot_before_theme_options_save', $options_safe );
|
1286 |
+
|
1287 |
+
// Update the option tree array.
|
1288 |
+
update_option( ot_options_id(), $options_safe );
|
1289 |
+
|
1290 |
+
$message = 'success';
|
1291 |
+
}
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
// Redirect back to self.
|
1295 |
+
wp_safe_redirect(
|
1296 |
+
esc_url_raw(
|
1297 |
+
add_query_arg(
|
1298 |
+
array(
|
1299 |
+
'action' => 'import-data',
|
1300 |
+
'message' => $message,
|
1301 |
+
),
|
1302 |
+
wp_get_referer()
|
1303 |
+
)
|
1304 |
+
)
|
1305 |
+
);
|
1306 |
+
exit;
|
1307 |
+
}
|
1308 |
+
|
1309 |
+
// Check and verify import layouts nonce.
|
1310 |
+
if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) { // phpcs:ignore
|
1311 |
+
|
1312 |
+
// Default message.
|
1313 |
+
$message = 'failed';
|
1314 |
+
$layouts = isset( $_POST['import_layouts'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_layouts'] ) ) ) : array();
|
1315 |
+
|
1316 |
+
if ( $layouts ) {
|
1317 |
+
|
1318 |
+
// Get settings array.
|
1319 |
+
$settings = get_option( ot_settings_id() );
|
1320 |
+
|
1321 |
+
// Has layouts.
|
1322 |
+
if ( is_array( $layouts ) && ! empty( $layouts ) && ! empty( $layouts['active_layout'] ) ) {
|
1323 |
+
|
1324 |
+
$layouts_safe = array(
|
1325 |
+
'active_layout' => esc_attr( $layouts['active_layout'] ),
|
1326 |
+
);
|
1327 |
+
|
1328 |
+
// Validate options.
|
1329 |
+
if ( is_array( $settings ) ) {
|
1330 |
+
|
1331 |
+
foreach ( $layouts as $key => $value ) {
|
1332 |
+
|
1333 |
+
if ( 'active_layout' === $key ) {
|
1334 |
+
continue;
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
// Convert the options to an array.
|
1338 |
+
$options = ot_decode( $value );
|
1339 |
+
|
1340 |
+
$options_safe = array();
|
1341 |
+
|
1342 |
+
foreach ( $settings['settings'] as $setting ) {
|
1343 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
1344 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
1345 |
+
}
|
1346 |
+
}
|
1347 |
+
|
1348 |
+
// Store the sanitized values for later.
|
1349 |
+
if ( $key === $layouts['active_layout'] ) {
|
1350 |
+
$new_options_safe = $options_safe;
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
$layouts_safe[ $key ] = ot_encode( $options_safe );
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
// Update the option tree array with sanitized values.
|
1358 |
+
if ( isset( $new_options_safe ) ) {
|
1359 |
+
|
1360 |
+
// Execute the action hook and pass the theme options to it.
|
1361 |
+
do_action( 'ot_before_theme_options_save', $new_options_safe );
|
1362 |
+
|
1363 |
+
update_option( ot_options_id(), $new_options_safe );
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
// Update the option tree layouts array.
|
1367 |
+
update_option( ot_layouts_id(), $layouts_safe );
|
1368 |
+
|
1369 |
+
$message = 'success';
|
1370 |
+
}
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
// Redirect back to self.
|
1374 |
+
wp_safe_redirect(
|
1375 |
+
esc_url_raw(
|
1376 |
+
add_query_arg(
|
1377 |
+
array(
|
1378 |
+
'action' => 'import-layouts',
|
1379 |
+
'message' => $message,
|
1380 |
+
),
|
1381 |
+
wp_get_referer()
|
1382 |
+
)
|
1383 |
+
)
|
1384 |
+
);
|
1385 |
+
exit;
|
1386 |
+
}
|
1387 |
+
|
1388 |
+
return false;
|
1389 |
+
}
|
1390 |
}
|
1391 |
|
1392 |
+
if ( ! function_exists( 'ot_export' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1393 |
|
1394 |
+
/**
|
1395 |
+
* Export before the screen is displayed.
|
1396 |
+
*
|
1397 |
+
* @return void
|
1398 |
+
*
|
1399 |
+
* @access public
|
1400 |
+
* @since 2.0.8
|
1401 |
+
*/
|
1402 |
+
function ot_export() {
|
1403 |
+
|
1404 |
+
// Check and verify export settings file nonce.
|
1405 |
+
if ( isset( $_POST['export_settings_file_nonce'] ) && wp_verify_nonce( $_POST['export_settings_file_nonce'], 'export_settings_file_form' ) ) { // phpcs:ignore
|
1406 |
+
ot_export_php_settings_array();
|
1407 |
+
}
|
1408 |
+
}
|
1409 |
}
|
1410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1411 |
if ( ! function_exists( 'ot_export_php_settings_array' ) ) {
|
1412 |
|
1413 |
+
/**
|
1414 |
+
* Export the Theme Mode theme-options.php
|
1415 |
+
*
|
1416 |
+
* @access public
|
1417 |
+
* @since 2.0.8
|
1418 |
+
*/
|
1419 |
+
function ot_export_php_settings_array() {
|
1420 |
+
|
1421 |
+
$content = '';
|
1422 |
+
$build_settings = '';
|
1423 |
+
$contextual_help = '';
|
1424 |
+
$sections = '';
|
1425 |
+
$settings = '';
|
1426 |
+
$option_tree_settings = get_option( ot_settings_id(), array() );
|
1427 |
+
|
1428 |
+
/**
|
1429 |
+
* Domain string helper.
|
1430 |
+
*
|
1431 |
+
* @param string $string A string.
|
1432 |
+
* @return string
|
1433 |
+
*/
|
1434 |
+
function ot_i18n_string( $string ) {
|
1435 |
+
if ( ! empty( $string ) && isset( $_POST['domain'] ) && ! empty( $_POST['domain'] ) ) { // phpcs:ignore
|
1436 |
+
$domain = str_replace( ' ', '-', trim( sanitize_text_field( wp_unslash( $_POST['domain'] ) ) ) ); // phpcs:ignore
|
1437 |
+
return "esc_html__( '$string', '$domain' )";
|
1438 |
+
}
|
1439 |
+
return "'$string'";
|
1440 |
+
}
|
1441 |
+
|
1442 |
+
header( 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' );
|
1443 |
+
header( 'Pragma: no-cache ' );
|
1444 |
+
header( 'Content-Description: File Transfer' );
|
1445 |
+
header( 'Content-Disposition: attachment; filename="theme-options.php"' );
|
1446 |
+
header( 'Content-Type: application/octet-stream' );
|
1447 |
+
header( 'Content-Transfer-Encoding: binary' );
|
1448 |
+
|
1449 |
+
// Build contextual help content.
|
1450 |
+
if ( isset( $option_tree_settings['contextual_help']['content'] ) ) {
|
1451 |
+
$help = '';
|
1452 |
+
foreach ( $option_tree_settings['contextual_help']['content'] as $value ) {
|
1453 |
+
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1454 |
+
$_title = ot_i18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
|
1455 |
+
$_content = ot_i18n_string( isset( $value['content'] ) ? html_entity_decode( str_replace( "'", "\'", $value['content'] ) ) : '' );
|
1456 |
+
$help .= "
|
1457 |
+
array(
|
1458 |
+
'id' => '$_id',
|
1459 |
+
'title' => $_title,
|
1460 |
+
'content' => $_content,
|
1461 |
+
),";
|
1462 |
+
}
|
1463 |
+
$contextual_help = "
|
1464 |
+
'content' => array($help
|
1465 |
+
),";
|
1466 |
+
}
|
1467 |
+
|
1468 |
+
// Build contextual help sidebar.
|
1469 |
+
if ( isset( $option_tree_settings['contextual_help']['sidebar'] ) ) {
|
1470 |
+
$_sidebar = ot_i18n_string( html_entity_decode( str_replace( "'", "\'", $option_tree_settings['contextual_help']['sidebar'] ) ) );
|
1471 |
+
$contextual_help .= "
|
1472 |
+
'sidebar' => $_sidebar,";
|
1473 |
+
}
|
1474 |
+
|
1475 |
+
// Check that $contexual_help has a value and add to $build_settings.
|
1476 |
+
if ( '' !== $contextual_help ) {
|
1477 |
+
$build_settings .= "
|
1478 |
+
'contextual_help' => array($contextual_help
|
1479 |
+
),";
|
1480 |
+
}
|
1481 |
+
|
1482 |
+
// Build sections.
|
1483 |
+
if ( isset( $option_tree_settings['sections'] ) ) {
|
1484 |
+
foreach ( $option_tree_settings['sections'] as $value ) {
|
1485 |
+
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1486 |
+
$_title = ot_i18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' );
|
1487 |
+
$sections .= "
|
1488 |
+
array(
|
1489 |
+
'id' => '$_id',
|
1490 |
+
'title' => $_title,
|
1491 |
+
),";
|
1492 |
+
}
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
// Check that $sections has a value and add to $build_settings.
|
1496 |
+
if ( '' !== $sections ) {
|
1497 |
+
$build_settings .= "
|
1498 |
+
'sections' => array($sections
|
1499 |
+
)";
|
1500 |
+
}
|
1501 |
+
|
1502 |
+
/* build settings */
|
1503 |
+
if ( isset( $option_tree_settings['settings'] ) ) {
|
1504 |
+
foreach ( $option_tree_settings['settings'] as $value ) {
|
1505 |
+
$_id = isset( $value['id'] ) ? $value['id'] : '';
|
1506 |
+
$_label = ot_i18n_string( isset( $value['label'] ) ? str_replace( "'", "\'", $value['label'] ) : '' );
|
1507 |
+
$_desc = ot_i18n_string( isset( $value['desc'] ) ? str_replace( "'", "\'", $value['desc'] ) : '' );
|
1508 |
+
$_std = isset( $value['std'] ) ? str_replace( "'", "\'", $value['std'] ) : '';
|
1509 |
+
$_type = isset( $value['type'] ) ? $value['type'] : '';
|
1510 |
+
$_section = isset( $value['section'] ) ? $value['section'] : '';
|
1511 |
+
$_rows = isset( $value['rows'] ) ? $value['rows'] : '';
|
1512 |
+
$_post_type = isset( $value['post_type'] ) ? $value['post_type'] : '';
|
1513 |
+
$_taxonomy = isset( $value['taxonomy'] ) ? $value['taxonomy'] : '';
|
1514 |
+
$_min_max_step = isset( $value['min_max_step'] ) ? $value['min_max_step'] : '';
|
1515 |
+
$_class = isset( $value['class'] ) ? $value['class'] : '';
|
1516 |
+
$_condition = isset( $value['condition'] ) ? $value['condition'] : '';
|
1517 |
+
$_operator = isset( $value['operator'] ) ? $value['operator'] : '';
|
1518 |
+
|
1519 |
+
$choices = '';
|
1520 |
+
if ( isset( $value['choices'] ) && ! empty( $value['choices'] ) ) {
|
1521 |
+
foreach ( $value['choices'] as $choice ) {
|
1522 |
+
$_choice_value = isset( $choice['value'] ) ? str_replace( "'", "\'", $choice['value'] ) : '';
|
1523 |
+
$_choice_label = ot_i18n_string( isset( $choice['label'] ) ? str_replace( "'", "\'", $choice['label'] ) : '' );
|
1524 |
+
$_choice_src = isset( $choice['src'] ) ? str_replace( "'", "\'", $choice['src'] ) : '';
|
1525 |
+
$choices .= "
|
1526 |
+
array(
|
1527 |
+
'value' => '$_choice_value',
|
1528 |
+
'label' => $_choice_label,
|
1529 |
+
'src' => '$_choice_src',
|
1530 |
+
),";
|
1531 |
+
}
|
1532 |
+
$choices = "
|
1533 |
+
'choices' => array($choices
|
1534 |
+
),";
|
1535 |
+
}
|
1536 |
+
|
1537 |
+
$std = "'$_std'";
|
1538 |
+
if ( is_array( $_std ) ) {
|
1539 |
+
$std_array = array();
|
1540 |
+
foreach ( $_std as $_sk => $_sv ) {
|
1541 |
+
$std_array[] = "'$_sk' => '$_sv',";
|
1542 |
+
}
|
1543 |
+
$std = 'array(
|
1544 |
' . implode( ",\n", $std_array ) . '
|
1545 |
+
)';
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
$setting_settings = '';
|
1549 |
+
if ( isset( $value['settings'] ) && ! empty( $value['settings'] ) ) {
|
1550 |
+
foreach ( $value['settings'] as $setting ) {
|
1551 |
+
$_setting_id = isset( $setting['id'] ) ? $setting['id'] : '';
|
1552 |
+
$_setting_label = ot_i18n_string( isset( $setting['label'] ) ? str_replace( "'", "\'", $setting['label'] ) : '' );
|
1553 |
+
$_setting_desc = ot_i18n_string( isset( $setting['desc'] ) ? str_replace( "'", "\'", $setting['desc'] ) : '' );
|
1554 |
+
$_setting_std = isset( $setting['std'] ) ? $setting['std'] : '';
|
1555 |
+
$_setting_type = isset( $setting['type'] ) ? $setting['type'] : '';
|
1556 |
+
$_setting_rows = isset( $setting['rows'] ) ? $setting['rows'] : '';
|
1557 |
+
$_setting_post_type = isset( $setting['post_type'] ) ? $setting['post_type'] : '';
|
1558 |
+
$_setting_taxonomy = isset( $setting['taxonomy'] ) ? $setting['taxonomy'] : '';
|
1559 |
+
$_setting_min_max_step = isset( $setting['min_max_step'] ) ? $setting['min_max_step'] : '';
|
1560 |
+
$_setting_class = isset( $setting['class'] ) ? $setting['class'] : '';
|
1561 |
+
$_setting_condition = isset( $setting['condition'] ) ? $setting['condition'] : '';
|
1562 |
+
$_setting_operator = isset( $setting['operator'] ) ? $setting['operator'] : '';
|
1563 |
+
|
1564 |
+
$setting_choices = '';
|
1565 |
+
if ( isset( $setting['choices'] ) && ! empty( $setting['choices'] ) ) {
|
1566 |
+
foreach ( $setting['choices'] as $setting_choice ) {
|
1567 |
+
$_setting_choice_value = isset( $setting_choice['value'] ) ? $setting_choice['value'] : '';
|
1568 |
+
$_setting_choice_label = ot_i18n_string( isset( $setting_choice['label'] ) ? str_replace( "'", "\'", $setting_choice['label'] ) : '' );
|
1569 |
+
$_setting_choice_src = isset( $setting_choice['src'] ) ? str_replace( "'", "\'", $setting_choice['src'] ) : '';
|
1570 |
+
$setting_choices .= "
|
1571 |
+
array(
|
1572 |
+
'value' => '$_setting_choice_value',
|
1573 |
+
'label' => $_setting_choice_label,
|
1574 |
+
'src' => '$_setting_choice_src',
|
1575 |
+
),";
|
1576 |
+
}
|
1577 |
+
$setting_choices = "
|
1578 |
+
'choices' => array($setting_choices
|
1579 |
+
),";
|
1580 |
+
}
|
1581 |
+
|
1582 |
+
$setting_std = "'$_setting_std'";
|
1583 |
+
if ( is_array( $_setting_std ) ) {
|
1584 |
+
$setting_std_array = array();
|
1585 |
+
foreach ( $_setting_std as $_ssk => $_ssv ) {
|
1586 |
+
$setting_std_array[] = "'$_ssk' => '$_ssv'";
|
1587 |
+
}
|
1588 |
+
$setting_std = 'array(
|
|
|
1589 |
' . implode( ",\n", $setting_std_array ) . '
|
1590 |
+
)';
|
1591 |
+
}
|
1592 |
+
|
1593 |
+
$setting_settings .= "
|
1594 |
+
array(
|
1595 |
+
'id' => '$_setting_id',
|
1596 |
+
'label' => $_setting_label,
|
1597 |
+
'desc' => $_setting_desc,
|
1598 |
+
'std' => $setting_std,
|
1599 |
+
'type' => '$_setting_type',
|
1600 |
+
'rows' => '$_setting_rows',
|
1601 |
+
'post_type' => '$_setting_post_type',
|
1602 |
+
'taxonomy' => '$_setting_taxonomy',
|
1603 |
+
'min_max_step' => '$_setting_min_max_step',
|
1604 |
+
'class' => '$_setting_class',
|
1605 |
+
'condition' => '$_setting_condition',
|
1606 |
+
'operator' => '$_setting_operator',$setting_choices
|
1607 |
+
),";
|
1608 |
+
}
|
1609 |
+
$setting_settings = "
|
1610 |
+
'settings' => array( $setting_settings
|
1611 |
+
),";
|
1612 |
+
}
|
1613 |
+
$settings .= "
|
1614 |
+
array(
|
1615 |
+
'id' => '$_id',
|
1616 |
+
'label' => $_label,
|
1617 |
+
'desc' => $_desc,
|
1618 |
+
'std' => $std,
|
1619 |
+
'type' => '$_type',
|
1620 |
+
'section' => '$_section',
|
1621 |
+
'rows' => '$_rows',
|
1622 |
+
'post_type' => '$_post_type',
|
1623 |
+
'taxonomy' => '$_taxonomy',
|
1624 |
+
'min_max_step' => '$_min_max_step',
|
1625 |
+
'class' => '$_class',
|
1626 |
+
'condition' => '$_condition',
|
1627 |
+
'operator' => '$_operator',$choices$setting_settings
|
1628 |
+
),";
|
1629 |
+
}
|
1630 |
+
}
|
1631 |
+
|
1632 |
+
// Check that $sections has a value and add to $build_settings.
|
1633 |
+
if ( '' !== $settings ) {
|
1634 |
+
$build_settings .= ",
|
1635 |
+
'settings' => array($settings
|
1636 |
+
)";
|
1637 |
+
}
|
1638 |
+
|
1639 |
+
$content .= "<?php
|
|
|
|
|
|
|
1640 |
/**
|
1641 |
* Initialize the custom theme options.
|
1642 |
*/
|
1647 |
*/
|
1648 |
function custom_theme_options() {
|
1649 |
|
1650 |
+
// OptionTree is not loaded yet, or this is not an admin request.
|
1651 |
+
if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() ) {
|
1652 |
+
return false;
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
// Get a copy of the saved settings array.
|
1656 |
+
\$saved_settings = get_option( ot_settings_id(), array() );
|
1657 |
+
|
1658 |
+
// Custom settings array that will eventually be passes to the OptionTree Settings API Class.
|
1659 |
+
\$custom_settings = array($build_settings
|
1660 |
+
);
|
1661 |
+
|
1662 |
+
// Allow settings to be filtered before saving.
|
1663 |
+
\$custom_settings = apply_filters( ot_settings_id() . '_args', \$custom_settings );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1664 |
|
1665 |
+
// Settings are not the same update the DB.
|
1666 |
+
if ( \$saved_settings !== \$custom_settings ) {
|
1667 |
+
update_option( ot_settings_id(), \$custom_settings );
|
1668 |
+
}
|
1669 |
|
1670 |
+
// Lets OptionTree know the UI Builder is being overridden.
|
1671 |
+
global \$ot_has_custom_theme_options;
|
1672 |
+
\$ot_has_custom_theme_options = true;
|
1673 |
+
}
|
1674 |
+
";
|
1675 |
+
|
1676 |
+
echo $content; // phpcs:ignore
|
1677 |
+
die();
|
1678 |
+
}
|
1679 |
}
|
1680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1681 |
if ( ! function_exists( 'ot_save_settings' ) ) {
|
1682 |
|
1683 |
+
/**
|
1684 |
+
* Save settings array before the screen is displayed.
|
1685 |
+
*
|
1686 |
+
* @return bool Redirects on save, false on failure.
|
1687 |
+
*
|
1688 |
+
* @access public
|
1689 |
+
* @since 2.0
|
1690 |
+
*/
|
1691 |
+
function ot_save_settings() {
|
1692 |
+
|
1693 |
+
// Check and verify import settings nonce.
|
1694 |
+
if ( isset( $_POST['option_tree_settings_nonce'] ) && wp_verify_nonce( $_POST['option_tree_settings_nonce'], 'option_tree_settings_form' ) ) { // phpcs:ignore
|
1695 |
+
|
1696 |
+
// Settings value.
|
1697 |
+
$settings = isset( $_POST[ ot_settings_id() ] ) ? wp_unslash( $_POST[ ot_settings_id() ] ) : array(); // phpcs:ignore
|
1698 |
+
|
1699 |
+
$settings_safe = ot_validate_settings( $settings );
|
1700 |
+
|
1701 |
+
// Default message.
|
1702 |
+
$message = 'failed';
|
1703 |
+
|
1704 |
+
// Save & show success message.
|
1705 |
+
if ( ! empty( $settings_safe ) ) {
|
1706 |
+
ot_wpml_unregister( $settings_safe );
|
1707 |
+
|
1708 |
+
update_option( ot_settings_id(), $settings_safe );
|
1709 |
+
$message = 'success';
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
// Redirect.
|
1713 |
+
wp_safe_redirect(
|
1714 |
+
esc_url_raw(
|
1715 |
+
add_query_arg(
|
1716 |
+
array(
|
1717 |
+
'action' => 'save-settings',
|
1718 |
+
'message' => $message,
|
1719 |
+
),
|
1720 |
+
wp_get_referer()
|
1721 |
+
)
|
1722 |
+
)
|
1723 |
+
);
|
1724 |
+
exit;
|
1725 |
+
}
|
1726 |
+
|
1727 |
+
return false;
|
1728 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1729 |
}
|
1730 |
|
1731 |
+
if ( ! function_exists( 'ot_wpml_unregister' ) ) {
|
1732 |
+
|
1733 |
+
/**
|
1734 |
+
* Unregister WPML strings based on settings changing.
|
1735 |
+
*
|
1736 |
+
* @param array $settings The array of settings.
|
1737 |
+
*
|
1738 |
+
* @access public
|
1739 |
+
* @since 2.7.0
|
1740 |
+
*/
|
1741 |
+
function ot_wpml_unregister( $settings = array() ) {
|
1742 |
+
|
1743 |
+
// WPML unregister ID's that have been removed.
|
1744 |
+
if ( function_exists( 'icl_unregister_string' ) ) {
|
1745 |
+
|
1746 |
+
$current = get_option( ot_settings_id() );
|
1747 |
+
$options = get_option( ot_options_id() );
|
1748 |
+
|
1749 |
+
if ( isset( $current['settings'] ) ) {
|
1750 |
+
|
1751 |
+
// Empty ID array.
|
1752 |
+
$new_ids = array();
|
1753 |
+
|
1754 |
+
// Build the WPML IDs array.
|
1755 |
+
foreach ( $settings['settings'] as $setting ) {
|
1756 |
+
if ( $setting['id'] ) {
|
1757 |
+
$new_ids[] = $setting['id'];
|
1758 |
+
}
|
1759 |
+
}
|
1760 |
+
|
1761 |
+
// Remove missing IDs from WPML.
|
1762 |
+
foreach ( $current['settings'] as $current_setting ) {
|
1763 |
+
if ( ! in_array( $current_setting['id'], $new_ids, true ) ) {
|
1764 |
+
if ( ! empty( $options[ $current_setting['id'] ] ) && in_array( $current_setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
1765 |
+
foreach ( $options[ $current_setting['id'] ] as $key => $value ) {
|
1766 |
+
foreach ( $value as $ckey => $cvalue ) {
|
1767 |
+
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
1768 |
+
}
|
1769 |
+
}
|
1770 |
+
} elseif ( ! empty( $options[ $current_setting['id'] ] ) && 'social-icons' === $current_setting['type'] ) {
|
1771 |
+
foreach ( $options[ $current_setting['id'] ] as $key => $value ) {
|
1772 |
+
foreach ( $value as $ckey => $cvalue ) {
|
1773 |
+
ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key );
|
1774 |
+
}
|
1775 |
+
}
|
1776 |
+
} else {
|
1777 |
+
ot_wpml_unregister_string( $current_setting['id'] );
|
1778 |
+
}
|
1779 |
+
}
|
1780 |
+
}
|
1781 |
+
}
|
1782 |
+
}
|
1783 |
+
}
|
1784 |
+
}
|
1785 |
|
1786 |
+
if ( ! function_exists( 'ot_validate_settings' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1787 |
|
1788 |
+
/**
|
1789 |
+
* Helper function to validate all settings.
|
1790 |
+
*
|
1791 |
+
* This includes the `sections`, `settings`, and `contextual_help` arrays.
|
1792 |
+
*
|
1793 |
+
* @param array $settings The array of settings.
|
1794 |
+
*
|
1795 |
+
* @return array
|
1796 |
+
*
|
1797 |
+
* @access public
|
1798 |
+
* @since 2.7.0
|
1799 |
+
*/
|
1800 |
+
function ot_validate_settings( $settings = array() ) {
|
1801 |
|
1802 |
+
// Store the validated settings.
|
1803 |
+
$settings_safe = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1804 |
|
1805 |
+
// Validate sections.
|
1806 |
+
if ( isset( $settings['sections'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1807 |
|
1808 |
+
// Fix numeric keys since drag & drop will change them.
|
1809 |
+
$settings['sections'] = array_values( $settings['sections'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1810 |
|
1811 |
+
// Loop through sections.
|
1812 |
+
foreach ( $settings['sections'] as $k => $section ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1813 |
|
1814 |
+
// Skip if missing values.
|
1815 |
+
if ( ( ! isset( $section['title'] ) && ! isset( $section['id'] ) ) || ( '' === $section['title'] && '' === $section['id'] ) ) {
|
1816 |
+
continue;
|
1817 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1818 |
|
1819 |
+
// Validate label.
|
1820 |
+
if ( '' !== $section['title'] ) {
|
1821 |
+
$settings_safe['sections'][ $k ]['title'] = wp_kses_post( $section['title'] );
|
1822 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1823 |
|
1824 |
+
// Missing title set to unfiltered ID.
|
1825 |
+
if ( ! isset( $section['title'] ) || '' === $section['title'] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1826 |
|
1827 |
+
$settings_safe['sections'][ $k ]['title'] = wp_kses_post( $section['id'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1828 |
|
1829 |
+
// Missing ID set to title.
|
1830 |
+
} elseif ( ! isset( $section['id'] ) || '' === $section['id'] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1831 |
|
1832 |
+
$settings_safe['id'] = wp_kses_post( $section['title'] );
|
1833 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1834 |
|
1835 |
+
// Sanitize ID once everything has been checked first.
|
1836 |
+
$settings_safe['sections'][ $k ]['id'] = ot_sanitize_option_id( wp_kses_post( $section['id'] ) );
|
1837 |
+
}
|
1838 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1839 |
|
1840 |
+
// Validate settings by looping over array as many times as it takes.
|
1841 |
+
if ( isset( $settings['settings'] ) ) {
|
1842 |
+
$settings_safe['settings'] = ot_validate_settings_array( $settings['settings'] );
|
1843 |
+
}
|
1844 |
|
1845 |
+
// Validate contextual_help.
|
1846 |
+
if ( isset( $settings['contextual_help']['content'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1847 |
|
1848 |
+
// Fix numeric keys since drag & drop will change them.
|
1849 |
+
$settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1850 |
|
1851 |
+
// Loop through content.
|
1852 |
+
foreach ( $settings['contextual_help']['content'] as $k => $content ) {
|
1853 |
|
1854 |
+
// Skip if missing values.
|
1855 |
+
if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' === $content['title'] && '' === $content['id'] ) ) {
|
1856 |
+
continue;
|
1857 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1858 |
|
1859 |
+
// Validate label.
|
1860 |
+
if ( '' !== $content['title'] ) {
|
1861 |
+
$settings_safe['contextual_help']['content'][ $k ]['title'] = wp_kses_post( $content['title'] );
|
1862 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1863 |
|
1864 |
+
// Missing title set to unfiltered ID.
|
1865 |
+
if ( ! isset( $content['title'] ) || '' === $content['title'] ) {
|
1866 |
|
1867 |
+
$settings_safe['contextual_help']['content'][ $k ]['title'] = wp_kses_post( $content['id'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1868 |
|
1869 |
+
// Missing ID set to title.
|
1870 |
+
} elseif ( ! isset( $content['id'] ) || '' === $content['id'] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1871 |
|
1872 |
+
$content['id'] = wp_kses_post( $content['title'] );
|
1873 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1874 |
|
1875 |
+
// Sanitize ID once everything has been checked first.
|
1876 |
+
$settings_safe['contextual_help']['content'][ $k ]['id'] = ot_sanitize_option_id( wp_kses_post( $content['id'] ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1877 |
|
1878 |
+
// Validate textarea description.
|
1879 |
+
if ( isset( $content['content'] ) ) {
|
1880 |
+
$settings_safe['contextual_help']['content'][ $k ]['content'] = wp_kses_post( $content['content'] );
|
1881 |
+
}
|
1882 |
+
}
|
1883 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1884 |
|
1885 |
+
// Validate contextual_help sidebar.
|
1886 |
+
if ( isset( $settings['contextual_help']['sidebar'] ) ) {
|
1887 |
+
$settings_safe['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] );
|
1888 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1889 |
|
1890 |
+
return $settings_safe;
|
1891 |
+
}
|
1892 |
}
|
1893 |
|
1894 |
+
if ( ! function_exists( 'ot_validate_settings_array' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1895 |
|
1896 |
+
/**
|
1897 |
+
* Validate a settings array before save.
|
1898 |
+
*
|
1899 |
+
* This function will loop over a settings array as many
|
1900 |
+
* times as it takes to validate every sub setting.
|
1901 |
+
*
|
1902 |
+
* @param array $settings The array of settings.
|
1903 |
+
* @return array
|
1904 |
+
*
|
1905 |
+
* @access public
|
1906 |
+
* @since 2.0
|
1907 |
+
* @updated 2.7.0
|
1908 |
+
*/
|
1909 |
+
function ot_validate_settings_array( $settings = array() ) {
|
1910 |
+
|
1911 |
+
// Field types mapped to their sanitize function.
|
1912 |
+
$field_types = array(
|
1913 |
+
'label' => 'wp_kses_post',
|
1914 |
+
'id' => 'ot_sanitize_option_id',
|
1915 |
+
'type' => 'sanitize_text_field',
|
1916 |
+
'desc' => 'wp_kses_post',
|
1917 |
+
'settings' => 'ot_validate_settings_array',
|
1918 |
+
'choices' => array(
|
1919 |
+
'label' => 'wp_kses_post',
|
1920 |
+
'value' => 'sanitize_text_field',
|
1921 |
+
'src' => 'sanitize_text_field',
|
1922 |
+
),
|
1923 |
+
'std' => 'sanitize_text_field',
|
1924 |
+
'rows' => 'absint',
|
1925 |
+
'post_type' => 'sanitize_text_field',
|
1926 |
+
'taxonomy' => 'sanitize_text_field',
|
1927 |
+
'min_max_step' => 'sanitize_text_field',
|
1928 |
+
'class' => 'sanitize_text_field',
|
1929 |
+
'condition' => 'sanitize_text_field',
|
1930 |
+
'operator' => 'sanitize_text_field',
|
1931 |
+
'section' => 'sanitize_text_field',
|
1932 |
+
);
|
1933 |
+
|
1934 |
+
// Store the validated settings.
|
1935 |
+
$settings_safe = array();
|
1936 |
+
|
1937 |
+
// Validate settings.
|
1938 |
+
if ( 0 < count( $settings ) ) {
|
1939 |
+
|
1940 |
+
// Fix numeric keys since drag & drop will change them.
|
1941 |
+
$settings = array_values( $settings );
|
1942 |
+
|
1943 |
+
// Loop through settings.
|
1944 |
+
foreach ( $settings as $sk => $setting ) {
|
1945 |
+
foreach ( $setting as $fk => $field ) {
|
1946 |
+
if ( isset( $field_types[ $fk ] ) ) {
|
1947 |
+
if ( 'choices' === $fk ) {
|
1948 |
+
foreach ( $field as $ck => $choice ) {
|
1949 |
+
foreach ( $choice as $vk => $value ) {
|
1950 |
+
$settings_safe[ $sk ][ $fk ][ $ck ][ $vk ] = call_user_func( $field_types[ $fk ][ $vk ], $value );
|
1951 |
+
}
|
1952 |
+
}
|
1953 |
+
} elseif ( 'std' === $fk && is_array( $field ) ) {
|
1954 |
+
$callback = $field_types[ $fk ];
|
1955 |
+
$array_map = function( $item ) use ( $array_map, $callback ) {
|
1956 |
+
return is_array( $item ) ? array_map( $array_map, $item ) : call_user_func( $callback, $item );
|
1957 |
+
};
|
1958 |
+
|
1959 |
+
$settings_safe[ $sk ][ $fk ] = array_map( $array_map, $field );
|
1960 |
+
} else {
|
1961 |
+
$sanitized = call_user_func( $field_types[ $fk ], $field );
|
1962 |
+
if ( 'rows' === $fk && 0 === $sanitized ) {
|
1963 |
+
$sanitized = '';
|
1964 |
+
}
|
1965 |
+
$settings_safe[ $sk ][ $fk ] = $sanitized;
|
1966 |
+
}
|
1967 |
+
}
|
1968 |
+
}
|
1969 |
+
}
|
1970 |
+
}
|
1971 |
+
|
1972 |
+
return $settings_safe;
|
1973 |
+
}
|
1974 |
}
|
1975 |
|
1976 |
+
if ( ! function_exists( 'ot_modify_layouts' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1977 |
|
1978 |
+
/**
|
1979 |
+
* Save layouts array before the screen is displayed.
|
1980 |
+
*
|
1981 |
+
* @return bool Returns false or redirects.
|
1982 |
+
*
|
1983 |
+
* @access public
|
1984 |
+
* @since 2.0
|
1985 |
+
*/
|
1986 |
+
function ot_modify_layouts() {
|
1987 |
+
|
1988 |
+
// Check and verify modify layouts nonce.
|
1989 |
+
if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) { // phpcs:ignore
|
1990 |
+
|
1991 |
+
// Previous layouts value.
|
1992 |
+
$option_tree_layouts = get_option( ot_layouts_id() );
|
1993 |
+
|
1994 |
+
// New layouts value.
|
1995 |
+
$layouts = isset( $_POST[ ot_layouts_id() ] ) ? $_POST[ ot_layouts_id() ] : ''; // phpcs:ignore
|
1996 |
+
|
1997 |
+
// Rebuild layout array.
|
1998 |
+
$rebuild = array();
|
1999 |
+
|
2000 |
+
// Validate layouts.
|
2001 |
+
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
2002 |
+
|
2003 |
+
// Setup active layout.
|
2004 |
+
if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) {
|
2005 |
+
$rebuild['active_layout'] = $layouts['active_layout'];
|
2006 |
+
}
|
2007 |
+
|
2008 |
+
// Add new and overwrite active layout.
|
2009 |
+
if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) {
|
2010 |
+
$rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] );
|
2011 |
+
$rebuild[ $rebuild['active_layout'] ] = ot_encode( get_option( ot_options_id(), array() ) );
|
2012 |
+
}
|
2013 |
+
|
2014 |
+
$first_layout = '';
|
2015 |
+
|
2016 |
+
// Loop through layouts.
|
2017 |
+
foreach ( $layouts as $key => $layout ) {
|
2018 |
+
|
2019 |
+
// Skip over active layout key.
|
2020 |
+
if ( 'active_layout' === $key ) {
|
2021 |
+
continue;
|
2022 |
+
}
|
2023 |
+
|
2024 |
+
// Check if the key exists then set value.
|
2025 |
+
if ( isset( $option_tree_layouts[ $key ] ) && ! empty( $option_tree_layouts[ $key ] ) ) {
|
2026 |
+
$rebuild[ $key ] = $option_tree_layouts[ $key ];
|
2027 |
+
if ( '' === $first_layout ) {
|
2028 |
+
$first_layout = $key;
|
2029 |
+
}
|
2030 |
+
}
|
2031 |
+
}
|
2032 |
+
|
2033 |
+
if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[ $rebuild['active_layout'] ] ) && ! empty( $first_layout ) ) {
|
2034 |
+
$rebuild['active_layout'] = $first_layout;
|
2035 |
+
}
|
2036 |
+
}
|
2037 |
+
|
2038 |
+
// Default message.
|
2039 |
+
$message = 'failed';
|
2040 |
+
|
2041 |
+
// Save & show success message.
|
2042 |
+
if ( is_array( $rebuild ) && 1 < count( $rebuild ) ) {
|
2043 |
+
|
2044 |
+
$options = ot_decode( $rebuild[ $rebuild['active_layout'] ] );
|
2045 |
+
|
2046 |
+
if ( $options ) {
|
2047 |
+
|
2048 |
+
$options_safe = array();
|
2049 |
+
|
2050 |
+
// Get settings array.
|
2051 |
+
$settings = get_option( ot_settings_id() );
|
2052 |
+
|
2053 |
+
// Has options.
|
2054 |
+
if ( is_array( $options ) ) {
|
2055 |
+
|
2056 |
+
// Validate options.
|
2057 |
+
if ( is_array( $settings ) ) {
|
2058 |
+
foreach ( $settings['settings'] as $setting ) {
|
2059 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
2060 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
2061 |
+
}
|
2062 |
+
}
|
2063 |
+
}
|
2064 |
+
|
2065 |
+
// Execute the action hook and pass the theme options to it.
|
2066 |
+
do_action( 'ot_before_theme_options_save', $options_safe );
|
2067 |
+
|
2068 |
+
update_option( ot_options_id(), $options_safe );
|
2069 |
+
}
|
2070 |
+
}
|
2071 |
+
|
2072 |
+
// Rebuild the layouts.
|
2073 |
+
update_option( ot_layouts_id(), $rebuild );
|
2074 |
+
|
2075 |
+
// Change message.
|
2076 |
+
$message = 'success';
|
2077 |
+
} elseif ( 1 >= count( $rebuild ) ) {
|
2078 |
+
|
2079 |
+
// Delete layouts option.
|
2080 |
+
delete_option( ot_layouts_id() );
|
2081 |
+
|
2082 |
+
// Change message.
|
2083 |
+
$message = 'deleted';
|
2084 |
+
}
|
2085 |
+
|
2086 |
+
// Redirect.
|
2087 |
+
if ( isset( $_REQUEST['page'] ) && apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) === $_REQUEST['page'] ) {
|
2088 |
+
$query_args = esc_url_raw(
|
2089 |
+
add_query_arg(
|
2090 |
+
array(
|
2091 |
+
'settings-updated' => 'layout',
|
2092 |
+
),
|
2093 |
+
remove_query_arg(
|
2094 |
+
array(
|
2095 |
+
'action',
|
2096 |
+
'message',
|
2097 |
+
),
|
2098 |
+
wp_get_referer()
|
2099 |
+
)
|
2100 |
+
)
|
2101 |
+
);
|
2102 |
+
} else {
|
2103 |
+
$query_args = esc_url_raw(
|
2104 |
+
add_query_arg(
|
2105 |
+
array(
|
2106 |
+
'action' => 'save-layouts',
|
2107 |
+
'message' => $message,
|
2108 |
+
),
|
2109 |
+
wp_get_referer()
|
2110 |
+
)
|
2111 |
+
);
|
2112 |
+
}
|
2113 |
+
wp_safe_redirect( $query_args );
|
2114 |
+
exit;
|
2115 |
+
}
|
2116 |
+
|
2117 |
+
return false;
|
2118 |
+
}
|
2119 |
}
|
2120 |
|
2121 |
+
if ( ! function_exists( 'ot_alert_message' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2122 |
|
2123 |
+
/**
|
2124 |
+
* Helper function to display alert messages.
|
2125 |
+
*
|
2126 |
+
* @param array $page Page array.
|
2127 |
+
* @return mixed
|
2128 |
+
*
|
2129 |
+
* @access public
|
2130 |
+
* @since 2.0
|
2131 |
+
*/
|
2132 |
+
function ot_alert_message( $page = array() ) {
|
2133 |
|
2134 |
+
if ( empty( $page ) ) {
|
2135 |
+
return false;
|
2136 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2137 |
|
2138 |
+
$before = apply_filters( 'ot_before_page_messages', '', $page );
|
2139 |
|
2140 |
+
if ( $before ) {
|
2141 |
+
return $before;
|
2142 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2143 |
|
2144 |
+
$action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : ''; // phpcs:ignore
|
2145 |
+
$message = isset( $_REQUEST['message'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['message'] ) ) : ''; // phpcs:ignore
|
2146 |
+
$updated = isset( $_REQUEST['settings-updated'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings-updated'] ) ) : ''; // phpcs:ignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2147 |
|
2148 |
+
if ( 'save-settings' === $action ) {
|
2149 |
|
2150 |
+
if ( 'success' === $message ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2151 |
|
2152 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Settings updated.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2153 |
|
2154 |
+
} elseif ( 'failed' === $message ) {
|
|
|
|
|
|
|
2155 |
|
2156 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Settings could not be saved.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2157 |
|
2158 |
+
}
|
2159 |
+
} elseif ( 'import-xml' === $action || 'import-settings' === $action ) {
|
|
|
|
|
2160 |
|
2161 |
+
if ( 'success' === $message ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
2162 |
|
2163 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Settings Imported.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
2164 |
|
2165 |
+
} elseif ( 'failed' === $message ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
2166 |
|
2167 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Settings could not be imported.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
2168 |
|
2169 |
+
}
|
2170 |
+
} elseif ( 'import-data' === $action ) {
|
|
|
|
|
|
|
|
|
|
|
2171 |
|
2172 |
+
if ( 'success' === $message ) {
|
|
|
|
|
|
|
2173 |
|
2174 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Data Imported.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2175 |
|
2176 |
+
} elseif ( 'failed' === $message ) {
|
|
|
|
|
2177 |
|
2178 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Data could not be imported.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2179 |
|
2180 |
+
}
|
2181 |
+
} elseif ( 'import-layouts' === $action ) {
|
2182 |
|
2183 |
+
if ( 'success' === $message ) {
|
|
|
|
|
|
|
|
|
2184 |
|
2185 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layouts Imported.', 'option-tree' ) . '</p></div>';
|
2186 |
|
2187 |
+
} elseif ( 'failed' === $message ) {
|
2188 |
|
2189 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Layouts could not be imported.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2190 |
|
2191 |
+
}
|
2192 |
+
} elseif ( 'save-layouts' === $action ) {
|
2193 |
|
2194 |
+
if ( 'success' === $message ) {
|
|
|
|
|
|
|
|
|
|
|
2195 |
|
2196 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layouts Updated.', 'option-tree' ) . '</p></div>';
|
|
|
2197 |
|
2198 |
+
} elseif ( 'failed' === $message ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2199 |
|
2200 |
+
return '<div id="message" class="error fade below-h2"><p>' . esc_html__( 'Layouts could not be updated.', 'option-tree' ) . '</p></div>';
|
|
|
2201 |
|
2202 |
+
} elseif ( 'deleted' === $message ) {
|
|
|
2203 |
|
2204 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layouts have been deleted.', 'option-tree' ) . '</p></div>';
|
2205 |
|
2206 |
+
}
|
2207 |
+
} elseif ( 'layout' === $updated ) {
|
2208 |
|
2209 |
+
return '<div id="message" class="updated fade below-h2"><p>' . esc_html__( 'Layout activated.', 'option-tree' ) . '</p></div>';
|
|
|
|
|
2210 |
|
2211 |
+
} elseif ( 'reset' === $action ) {
|
|
|
|
|
2212 |
|
2213 |
+
return '<div id="message" class="updated fade below-h2"><p>' . $page['reset_message'] . '</p></div>';
|
|
|
|
|
|
|
|
|
|
|
2214 |
|
2215 |
+
}
|
|
|
|
|
2216 |
|
2217 |
+
do_action( 'ot_custom_page_messages', $page );
|
|
|
2218 |
|
2219 |
+
if ( 'true' === $updated || true === $updated ) {
|
2220 |
+
return '<div id="message" class="updated fade below-h2"><p>' . $page['updated_message'] . '</p></div>';
|
2221 |
+
}
|
2222 |
|
2223 |
+
return false;
|
2224 |
+
}
|
2225 |
+
}
|
2226 |
+
|
2227 |
+
if ( ! function_exists( 'ot_option_types_array' ) ) {
|
2228 |
|
2229 |
+
/**
|
2230 |
+
* Setup the default option types.
|
2231 |
+
*
|
2232 |
+
* The returned option types are filterable so you can add your own.
|
2233 |
+
* This is not a task for a beginner as you'll need to add the function
|
2234 |
+
* that displays the option to the user and validate the saved data.
|
2235 |
+
*
|
2236 |
+
* @return array
|
2237 |
+
*
|
2238 |
+
* @access public
|
2239 |
+
* @since 2.0
|
2240 |
+
*/
|
2241 |
+
function ot_option_types_array() {
|
2242 |
+
|
2243 |
+
return apply_filters(
|
2244 |
+
'ot_option_types_array',
|
2245 |
+
array(
|
2246 |
+
'background' => esc_html__( 'Background', 'option-tree' ),
|
2247 |
+
'border' => esc_html__( 'Border', 'option-tree' ),
|
2248 |
+
'box-shadow' => esc_html__( 'Box Shadow', 'option-tree' ),
|
2249 |
+
'category-checkbox' => esc_html__( 'Category Checkbox', 'option-tree' ),
|
2250 |
+
'category-select' => esc_html__( 'Category Select', 'option-tree' ),
|
2251 |
+
'checkbox' => esc_html__( 'Checkbox', 'option-tree' ),
|
2252 |
+
'colorpicker' => esc_html__( 'Colorpicker', 'option-tree' ),
|
2253 |
+
'colorpicker-opacity' => esc_html__( 'Colorpicker Opacity', 'option-tree' ),
|
2254 |
+
'css' => esc_html__( 'CSS', 'option-tree' ),
|
2255 |
+
'custom-post-type-checkbox' => esc_html__( 'Custom Post Type Checkbox', 'option-tree' ),
|
2256 |
+
'custom-post-type-select' => esc_html__( 'Custom Post Type Select', 'option-tree' ),
|
2257 |
+
'date-picker' => esc_html__( 'Date Picker', 'option-tree' ),
|
2258 |
+
'date-time-picker' => esc_html__( 'Date Time Picker', 'option-tree' ),
|
2259 |
+
'dimension' => esc_html__( 'Dimension', 'option-tree' ),
|
2260 |
+
'gallery' => esc_html__( 'Gallery', 'option-tree' ),
|
2261 |
+
'google-fonts' => esc_html__( 'Google Fonts', 'option-tree' ),
|
2262 |
+
'javascript' => esc_html__( 'JavaScript', 'option-tree' ),
|
2263 |
+
'link-color' => esc_html__( 'Link Color', 'option-tree' ),
|
2264 |
+
'list-item' => esc_html__( 'List Item', 'option-tree' ),
|
2265 |
+
'measurement' => esc_html__( 'Measurement', 'option-tree' ),
|
2266 |
+
'numeric-slider' => esc_html__( 'Numeric Slider', 'option-tree' ),
|
2267 |
+
'on-off' => esc_html__( 'On/Off', 'option-tree' ),
|
2268 |
+
'page-checkbox' => esc_html__( 'Page Checkbox', 'option-tree' ),
|
2269 |
+
'page-select' => esc_html__( 'Page Select', 'option-tree' ),
|
2270 |
+
'post-checkbox' => esc_html__( 'Post Checkbox', 'option-tree' ),
|
2271 |
+
'post-select' => esc_html__( 'Post Select', 'option-tree' ),
|
2272 |
+
'radio' => esc_html__( 'Radio', 'option-tree' ),
|
2273 |
+
'radio-image' => esc_html__( 'Radio Image', 'option-tree' ),
|
2274 |
+
'select' => esc_html__( 'Select', 'option-tree' ),
|
2275 |
+
'sidebar-select' => esc_html__( 'Sidebar Select', 'option-tree' ),
|
2276 |
+
'slider' => esc_html__( 'Slider', 'option-tree' ),
|
2277 |
+
'social-links' => esc_html__( 'Social Links', 'option-tree' ),
|
2278 |
+
'spacing' => esc_html__( 'Spacing', 'option-tree' ),
|
2279 |
+
'tab' => esc_html__( 'Tab', 'option-tree' ),
|
2280 |
+
'tag-checkbox' => esc_html__( 'Tag Checkbox', 'option-tree' ),
|
2281 |
+
'tag-select' => esc_html__( 'Tag Select', 'option-tree' ),
|
2282 |
+
'taxonomy-checkbox' => esc_html__( 'Taxonomy Checkbox', 'option-tree' ),
|
2283 |
+
'taxonomy-select' => esc_html__( 'Taxonomy Select', 'option-tree' ),
|
2284 |
+
'text' => esc_html__( 'Text', 'option-tree' ),
|
2285 |
+
'textarea' => esc_html__( 'Textarea', 'option-tree' ),
|
2286 |
+
'textarea-simple' => esc_html__( 'Textarea Simple', 'option-tree' ),
|
2287 |
+
'textblock' => esc_html__( 'Textblock', 'option-tree' ),
|
2288 |
+
'textblock-titled' => esc_html__( 'Textblock Titled', 'option-tree' ),
|
2289 |
+
'typography' => esc_html__( 'Typography', 'option-tree' ),
|
2290 |
+
'upload' => esc_html__( 'Upload', 'option-tree' ),
|
2291 |
+
)
|
2292 |
+
);
|
2293 |
+
}
|
2294 |
+
}
|
2295 |
|
2296 |
+
if ( ! function_exists( 'ot_map_old_option_types' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2297 |
|
2298 |
+
/**
|
2299 |
+
* Map old option types for rebuilding XML and Table data.
|
2300 |
+
*
|
2301 |
+
* @param string $type The old option type.
|
2302 |
+
* @return string The new option type
|
2303 |
+
*
|
2304 |
+
* @access public
|
2305 |
+
* @since 2.0
|
2306 |
+
*/
|
2307 |
+
function ot_map_old_option_types( $type = '' ) {
|
2308 |
+
|
2309 |
+
if ( empty( $type ) ) {
|
2310 |
+
return 'text';
|
2311 |
+
}
|
2312 |
+
|
2313 |
+
$types = array(
|
2314 |
+
'background' => 'background',
|
2315 |
+
'category' => 'category-select',
|
2316 |
+
'categories' => 'category-checkbox',
|
2317 |
+
'checkbox' => 'checkbox',
|
2318 |
+
'colorpicker' => 'colorpicker',
|
2319 |
+
'css' => 'css',
|
2320 |
+
'custom_post' => 'custom-post-type-select',
|
2321 |
+
'custom_posts' => 'custom-post-type-checkbox',
|
2322 |
+
'input' => 'text',
|
2323 |
+
'image' => 'upload',
|
2324 |
+
'measurement' => 'measurement',
|
2325 |
+
'page' => 'page-select',
|
2326 |
+
'pages' => 'page-checkbox',
|
2327 |
+
'post' => 'post-select',
|
2328 |
+
'posts' => 'post-checkbox',
|
2329 |
+
'radio' => 'radio',
|
2330 |
+
'select' => 'select',
|
2331 |
+
'slider' => 'slider',
|
2332 |
+
'tag' => 'tag-select',
|
2333 |
+
'tags' => 'tag-checkbox',
|
2334 |
+
'textarea' => 'textarea',
|
2335 |
+
'textblock' => 'textblock',
|
2336 |
+
'typography' => 'typography',
|
2337 |
+
'upload' => 'upload',
|
2338 |
+
);
|
2339 |
+
|
2340 |
+
if ( isset( $types[ $type ] ) ) {
|
2341 |
+
return $types[ $type ];
|
2342 |
+
}
|
2343 |
+
|
2344 |
+
return false;
|
2345 |
+
}
|
2346 |
+
}
|
2347 |
|
2348 |
+
if ( ! function_exists( 'ot_google_font_stack' ) ) {
|
2349 |
+
|
2350 |
+
/**
|
2351 |
+
* Filters the typography font-family to add Google fonts dynamically.
|
2352 |
+
*
|
2353 |
+
* @param array $families An array of all recognized font families.
|
2354 |
+
* @param string $field_id ID of the field being filtered.
|
2355 |
+
*
|
2356 |
+
* @return array
|
2357 |
+
*
|
2358 |
+
* @access public
|
2359 |
+
* @since 2.5.0
|
2360 |
+
*/
|
2361 |
+
function ot_google_font_stack( $families, $field_id ) {
|
2362 |
+
|
2363 |
+
if ( ! is_array( $families ) ) {
|
2364 |
+
return array();
|
2365 |
+
}
|
2366 |
+
|
2367 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
2368 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
2369 |
+
|
2370 |
+
if ( ! empty( $ot_set_google_fonts ) ) {
|
2371 |
+
foreach ( $ot_set_google_fonts as $id => $sets ) {
|
2372 |
+
foreach ( $sets as $value ) {
|
2373 |
+
$family = isset( $value['family'] ) ? $value['family'] : '';
|
2374 |
+
if ( $family && isset( $ot_google_fonts[ $family ] ) ) {
|
2375 |
+
$spaces = explode( ' ', $ot_google_fonts[ $family ]['family'] );
|
2376 |
+
$font_stack = count( $spaces ) > 1 ? '"' . $ot_google_fonts[ $family ]['family'] . '"' : $ot_google_fonts[ $family ]['family'];
|
2377 |
+
$families[ $family ] = apply_filters( 'ot_google_font_stack', $font_stack, $family, $field_id );
|
2378 |
+
}
|
2379 |
+
}
|
2380 |
+
}
|
2381 |
+
}
|
2382 |
+
|
2383 |
+
return $families;
|
2384 |
+
}
|
2385 |
+
|
2386 |
+
add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 );
|
2387 |
+
}
|
2388 |
|
2389 |
+
if ( ! function_exists( 'ot_recognized_font_families' ) ) {
|
2390 |
|
2391 |
+
/**
|
2392 |
+
* Recognized font families
|
2393 |
+
*
|
2394 |
+
* Returns an array of all recognized font families.
|
2395 |
+
* Keys are intended to be stored in the database
|
2396 |
+
* while values are ready for display in html.
|
2397 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2398 |
+
*
|
2399 |
+
* @uses apply_filters()
|
2400 |
+
*
|
2401 |
+
* @param string $field_id ID that's passed to the filter.
|
2402 |
+
*
|
2403 |
+
* @return array
|
2404 |
+
*
|
2405 |
+
* @access public
|
2406 |
+
* @since 1.1.8
|
2407 |
+
* @updated 2.0
|
2408 |
+
*/
|
2409 |
+
function ot_recognized_font_families( $field_id ) {
|
2410 |
+
|
2411 |
+
$families = array(
|
2412 |
+
'arial' => 'Arial',
|
2413 |
+
'georgia' => 'Georgia',
|
2414 |
+
'helvetica' => 'Helvetica',
|
2415 |
+
'palatino' => 'Palatino',
|
2416 |
+
'tahoma' => 'Tahoma',
|
2417 |
+
'times' => '"Times New Roman", sans-serif',
|
2418 |
+
'trebuchet' => 'Trebuchet',
|
2419 |
+
'verdana' => 'Verdana',
|
2420 |
+
);
|
2421 |
+
|
2422 |
+
return apply_filters( 'ot_recognized_font_families', $families, $field_id );
|
2423 |
+
}
|
2424 |
+
}
|
2425 |
|
2426 |
+
if ( ! function_exists( 'ot_recognized_font_sizes' ) ) {
|
2427 |
|
2428 |
+
/**
|
2429 |
+
* Recognized font sizes
|
2430 |
+
*
|
2431 |
+
* Returns an array of all recognized font sizes.
|
2432 |
+
*
|
2433 |
+
* @uses apply_filters()
|
2434 |
+
*
|
2435 |
+
* @param string $field_id ID that's passed to the filter.
|
2436 |
+
*
|
2437 |
+
* @return array
|
2438 |
+
*
|
2439 |
+
* @access public
|
2440 |
+
* @since 2.0.12
|
2441 |
+
*/
|
2442 |
+
function ot_recognized_font_sizes( $field_id ) {
|
2443 |
+
|
2444 |
+
$range = ot_range(
|
2445 |
+
apply_filters( 'ot_font_size_low_range', 0, $field_id ),
|
2446 |
+
apply_filters( 'ot_font_size_high_range', 150, $field_id ),
|
2447 |
+
apply_filters( 'ot_font_size_range_interval', 1, $field_id )
|
2448 |
+
);
|
2449 |
+
|
2450 |
+
$unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id );
|
2451 |
+
|
2452 |
+
foreach ( $range as $k => $v ) {
|
2453 |
+
$range[ $k ] = $v . $unit;
|
2454 |
+
}
|
2455 |
+
|
2456 |
+
return apply_filters( 'ot_recognized_font_sizes', $range, $field_id );
|
2457 |
+
}
|
2458 |
}
|
2459 |
|
2460 |
+
if ( ! function_exists( 'ot_recognized_font_styles' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2461 |
|
2462 |
+
/**
|
2463 |
+
* Recognized font styles
|
2464 |
+
*
|
2465 |
+
* Returns an array of all recognized font styles.
|
2466 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2467 |
+
*
|
2468 |
+
* @uses apply_filters()
|
2469 |
+
*
|
2470 |
+
* @param string $field_id ID that's passed to the filter.
|
2471 |
+
*
|
2472 |
+
* @return array
|
2473 |
+
*
|
2474 |
+
* @access public
|
2475 |
+
* @since 1.1.8
|
2476 |
+
* @updated 2.0
|
2477 |
+
*/
|
2478 |
+
function ot_recognized_font_styles( $field_id ) {
|
2479 |
+
|
2480 |
+
return apply_filters(
|
2481 |
+
'ot_recognized_font_styles',
|
2482 |
+
array(
|
2483 |
+
'normal' => 'Normal',
|
2484 |
+
'italic' => 'Italic',
|
2485 |
+
'oblique' => 'Oblique',
|
2486 |
+
'inherit' => 'Inherit',
|
2487 |
+
),
|
2488 |
+
$field_id
|
2489 |
+
);
|
2490 |
+
}
|
2491 |
+
}
|
2492 |
|
2493 |
+
if ( ! function_exists( 'ot_recognized_font_variants' ) ) {
|
2494 |
|
2495 |
+
/**
|
2496 |
+
* Recognized font variants
|
2497 |
+
*
|
2498 |
+
* Returns an array of all recognized font variants.
|
2499 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2500 |
+
*
|
2501 |
+
* @uses apply_filters()
|
2502 |
+
*
|
2503 |
+
* @param string $field_id ID that's passed to the filter.
|
2504 |
+
*
|
2505 |
+
* @return array
|
2506 |
+
*
|
2507 |
+
* @access public
|
2508 |
+
* @since 1.1.8
|
2509 |
+
* @updated 2.0
|
2510 |
+
*/
|
2511 |
+
function ot_recognized_font_variants( $field_id ) {
|
2512 |
+
|
2513 |
+
return apply_filters(
|
2514 |
+
'ot_recognized_font_variants',
|
2515 |
+
array(
|
2516 |
+
'normal' => 'Normal',
|
2517 |
+
'small-caps' => 'Small Caps',
|
2518 |
+
'inherit' => 'Inherit',
|
2519 |
+
),
|
2520 |
+
$field_id
|
2521 |
+
);
|
2522 |
+
}
|
2523 |
+
}
|
2524 |
|
2525 |
+
if ( ! function_exists( 'ot_recognized_font_weights' ) ) {
|
2526 |
|
2527 |
+
/**
|
2528 |
+
* Recognized font weights
|
2529 |
+
*
|
2530 |
+
* Returns an array of all recognized font weights.
|
2531 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2532 |
+
*
|
2533 |
+
* @uses apply_filters()
|
2534 |
+
*
|
2535 |
+
* @param string $field_id ID that's passed to the filter.
|
2536 |
+
*
|
2537 |
+
* @return array
|
2538 |
+
*
|
2539 |
+
* @access public
|
2540 |
+
* @since 1.1.8
|
2541 |
+
* @updated 2.0
|
2542 |
+
*/
|
2543 |
+
function ot_recognized_font_weights( $field_id ) {
|
2544 |
+
|
2545 |
+
return apply_filters(
|
2546 |
+
'ot_recognized_font_weights',
|
2547 |
+
array(
|
2548 |
+
'normal' => 'Normal',
|
2549 |
+
'bold' => 'Bold',
|
2550 |
+
'bolder' => 'Bolder',
|
2551 |
+
'lighter' => 'Lighter',
|
2552 |
+
'100' => '100',
|
2553 |
+
'200' => '200',
|
2554 |
+
'300' => '300',
|
2555 |
+
'400' => '400',
|
2556 |
+
'500' => '500',
|
2557 |
+
'600' => '600',
|
2558 |
+
'700' => '700',
|
2559 |
+
'800' => '800',
|
2560 |
+
'900' => '900',
|
2561 |
+
'inherit' => 'Inherit',
|
2562 |
+
),
|
2563 |
+
$field_id
|
2564 |
+
);
|
2565 |
+
}
|
2566 |
+
}
|
2567 |
|
2568 |
+
if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) {
|
|
|
|
|
2569 |
|
2570 |
+
/**
|
2571 |
+
* Recognized letter spacing
|
2572 |
+
*
|
2573 |
+
* Returns an array of all recognized line heights.
|
2574 |
+
*
|
2575 |
+
* @uses apply_filters()
|
2576 |
+
*
|
2577 |
+
* @param string $field_id ID that's passed to the filter.
|
2578 |
+
*
|
2579 |
+
* @return array
|
2580 |
+
*
|
2581 |
+
* @access public
|
2582 |
+
* @since 2.0.12
|
2583 |
+
*/
|
2584 |
+
function ot_recognized_letter_spacing( $field_id ) {
|
2585 |
+
|
2586 |
+
$range = ot_range(
|
2587 |
+
apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ),
|
2588 |
+
apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ),
|
2589 |
+
apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id )
|
2590 |
+
);
|
2591 |
+
|
2592 |
+
$unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id );
|
2593 |
+
|
2594 |
+
foreach ( $range as $k => $v ) {
|
2595 |
+
$range[ $k ] = $v . $unit;
|
2596 |
+
}
|
2597 |
+
|
2598 |
+
return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id );
|
2599 |
+
}
|
2600 |
+
}
|
2601 |
|
2602 |
+
if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
|
2603 |
|
2604 |
+
/**
|
2605 |
+
* Recognized line heights
|
2606 |
+
*
|
2607 |
+
* Returns an array of all recognized line heights.
|
2608 |
+
*
|
2609 |
+
* @uses apply_filters()
|
2610 |
+
*
|
2611 |
+
* @param string $field_id ID that's passed to the filter.
|
2612 |
+
*
|
2613 |
+
* @return array
|
2614 |
+
*
|
2615 |
+
* @access public
|
2616 |
+
* @since 2.0.12
|
2617 |
+
*/
|
2618 |
+
function ot_recognized_line_heights( $field_id ) {
|
2619 |
+
|
2620 |
+
$range = ot_range(
|
2621 |
+
apply_filters( 'ot_line_height_low_range', 0, $field_id ),
|
2622 |
+
apply_filters( 'ot_line_height_high_range', 150, $field_id ),
|
2623 |
+
apply_filters( 'ot_line_height_range_interval', 1, $field_id )
|
2624 |
+
);
|
2625 |
+
|
2626 |
+
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
|
2627 |
+
|
2628 |
+
foreach ( $range as $k => $v ) {
|
2629 |
+
$range[ $k ] = $v . $unit;
|
2630 |
+
}
|
2631 |
+
|
2632 |
+
return apply_filters( 'ot_recognized_line_heights', $range, $field_id );
|
2633 |
+
}
|
2634 |
+
}
|
2635 |
|
2636 |
+
if ( ! function_exists( 'ot_recognized_text_decorations' ) ) {
|
2637 |
|
2638 |
+
/**
|
2639 |
+
* Recognized text decorations
|
2640 |
+
*
|
2641 |
+
* Returns an array of all recognized text decorations.
|
2642 |
+
* Keys are intended to be stored in the database
|
2643 |
+
* while values are ready for display in html.
|
2644 |
+
*
|
2645 |
+
* @uses apply_filters()
|
2646 |
+
*
|
2647 |
+
* @param string $field_id ID that's passed to the filter.
|
2648 |
+
*
|
2649 |
+
* @return array
|
2650 |
+
*
|
2651 |
+
* @access public
|
2652 |
+
* @since 2.0.10
|
2653 |
+
*/
|
2654 |
+
function ot_recognized_text_decorations( $field_id ) {
|
2655 |
+
|
2656 |
+
return apply_filters(
|
2657 |
+
'ot_recognized_text_decorations',
|
2658 |
+
array(
|
2659 |
+
'blink' => 'Blink',
|
2660 |
+
'inherit' => 'Inherit',
|
2661 |
+
'line-through' => 'Line Through',
|
2662 |
+
'none' => 'None',
|
2663 |
+
'overline' => 'Overline',
|
2664 |
+
'underline' => 'Underline',
|
2665 |
+
),
|
2666 |
+
$field_id
|
2667 |
+
);
|
2668 |
+
}
|
2669 |
+
}
|
2670 |
|
2671 |
+
if ( ! function_exists( 'ot_recognized_text_transformations' ) ) {
|
2672 |
|
2673 |
+
/**
|
2674 |
+
* Recognized text transformations
|
2675 |
+
*
|
2676 |
+
* Returns an array of all recognized text transformations.
|
2677 |
+
* Keys are intended to be stored in the database
|
2678 |
+
* while values are ready for display in html.
|
2679 |
+
*
|
2680 |
+
* @uses apply_filters()
|
2681 |
+
*
|
2682 |
+
* @param string $field_id ID that's passed to the filter.
|
2683 |
+
*
|
2684 |
+
* @return array
|
2685 |
+
*
|
2686 |
+
* @access public
|
2687 |
+
* @since 2.0.10
|
2688 |
+
*/
|
2689 |
+
function ot_recognized_text_transformations( $field_id ) {
|
2690 |
+
|
2691 |
+
return apply_filters(
|
2692 |
+
'ot_recognized_text_transformations',
|
2693 |
+
array(
|
2694 |
+
'capitalize' => 'Capitalize',
|
2695 |
+
'inherit' => 'Inherit',
|
2696 |
+
'lowercase' => 'Lowercase',
|
2697 |
+
'none' => 'None',
|
2698 |
+
'uppercase' => 'Uppercase',
|
2699 |
+
),
|
2700 |
+
$field_id
|
2701 |
+
);
|
2702 |
+
}
|
2703 |
+
}
|
2704 |
|
2705 |
+
if ( ! function_exists( 'ot_recognized_background_repeat' ) ) {
|
2706 |
|
2707 |
+
/**
|
2708 |
+
* Recognized background repeat
|
2709 |
+
*
|
2710 |
+
* Returns an array of all recognized background repeat values.
|
2711 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2712 |
+
*
|
2713 |
+
* @uses apply_filters()
|
2714 |
+
*
|
2715 |
+
* @param string $field_id ID that's passed to the filter.
|
2716 |
+
*
|
2717 |
+
* @return array
|
2718 |
+
*
|
2719 |
+
* @access public
|
2720 |
+
* @since 1.1.8
|
2721 |
+
* @updated 2.0
|
2722 |
+
*/
|
2723 |
+
function ot_recognized_background_repeat( $field_id ) {
|
2724 |
+
|
2725 |
+
return apply_filters(
|
2726 |
+
'ot_recognized_background_repeat',
|
2727 |
+
array(
|
2728 |
+
'no-repeat' => 'No Repeat',
|
2729 |
+
'repeat' => 'Repeat All',
|
2730 |
+
'repeat-x' => 'Repeat Horizontally',
|
2731 |
+
'repeat-y' => 'Repeat Vertically',
|
2732 |
+
'inherit' => 'Inherit',
|
2733 |
+
),
|
2734 |
+
$field_id
|
2735 |
+
);
|
2736 |
+
}
|
2737 |
+
}
|
2738 |
|
2739 |
+
if ( ! function_exists( 'ot_recognized_background_attachment' ) ) {
|
2740 |
|
2741 |
+
/**
|
2742 |
+
* Recognized background attachment
|
2743 |
+
*
|
2744 |
+
* Returns an array of all recognized background attachment values.
|
2745 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2746 |
+
*
|
2747 |
+
* @uses apply_filters()
|
2748 |
+
*
|
2749 |
+
* @param string $field_id ID that's passed to the filter.
|
2750 |
+
*
|
2751 |
+
* @return array
|
2752 |
+
*
|
2753 |
+
* @access public
|
2754 |
+
* @since 1.1.8
|
2755 |
+
* @updated 2.0
|
2756 |
+
*/
|
2757 |
+
function ot_recognized_background_attachment( $field_id ) {
|
2758 |
+
|
2759 |
+
return apply_filters(
|
2760 |
+
'ot_recognized_background_attachment',
|
2761 |
+
array(
|
2762 |
+
'fixed' => 'Fixed',
|
2763 |
+
'scroll' => 'Scroll',
|
2764 |
+
'inherit' => 'Inherit',
|
2765 |
+
),
|
2766 |
+
$field_id
|
2767 |
+
);
|
2768 |
+
}
|
2769 |
}
|
2770 |
|
2771 |
+
if ( ! function_exists( 'ot_recognized_background_position' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
2772 |
|
2773 |
+
/**
|
2774 |
+
* Recognized background position
|
2775 |
+
*
|
2776 |
+
* Returns an array of all recognized background position values.
|
2777 |
+
* Renamed in version 2.0 to avoid name collisions.
|
2778 |
+
*
|
2779 |
+
* @uses apply_filters()
|
2780 |
+
*
|
2781 |
+
* @param string $field_id ID that's passed to the filter.
|
2782 |
+
*
|
2783 |
+
* @return array
|
2784 |
+
*
|
2785 |
+
* @access public
|
2786 |
+
* @since 1.1.8
|
2787 |
+
* @updated 2.0
|
2788 |
+
*/
|
2789 |
+
function ot_recognized_background_position( $field_id ) {
|
2790 |
+
|
2791 |
+
return apply_filters(
|
2792 |
+
'ot_recognized_background_position',
|
2793 |
+
array(
|
2794 |
+
'left top' => 'Left Top',
|
2795 |
+
'left center' => 'Left Center',
|
2796 |
+
'left bottom' => 'Left Bottom',
|
2797 |
+
'center top' => 'Center Top',
|
2798 |
+
'center center' => 'Center Center',
|
2799 |
+
'center bottom' => 'Center Bottom',
|
2800 |
+
'right top' => 'Right Top',
|
2801 |
+
'right center' => 'Right Center',
|
2802 |
+
'right bottom' => 'Right Bottom',
|
2803 |
+
),
|
2804 |
+
$field_id
|
2805 |
+
);
|
2806 |
+
|
2807 |
+
}
|
2808 |
}
|
2809 |
|
2810 |
+
if ( ! function_exists( 'ot_recognized_border_style_types' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
2811 |
|
2812 |
+
/**
|
2813 |
+
* Returns an array of all available border style types.
|
2814 |
+
*
|
2815 |
+
* @uses apply_filters()
|
2816 |
+
*
|
2817 |
+
* @param string $field_id ID that's passed to the filter.
|
2818 |
+
*
|
2819 |
+
* @return array
|
2820 |
+
*
|
2821 |
+
* @access public
|
2822 |
+
* @since 2.5.0
|
2823 |
+
*/
|
2824 |
+
function ot_recognized_border_style_types( $field_id ) {
|
2825 |
+
|
2826 |
+
return apply_filters(
|
2827 |
+
'ot_recognized_border_style_types',
|
2828 |
+
array(
|
2829 |
+
'hidden' => 'Hidden',
|
2830 |
+
'dashed' => 'Dashed',
|
2831 |
+
'solid' => 'Solid',
|
2832 |
+
'double' => 'Double',
|
2833 |
+
'groove' => 'Groove',
|
2834 |
+
'ridge' => 'Ridge',
|
2835 |
+
'inset' => 'Inset',
|
2836 |
+
'outset' => 'Outset',
|
2837 |
+
),
|
2838 |
+
$field_id
|
2839 |
+
);
|
2840 |
+
|
2841 |
+
}
|
2842 |
}
|
2843 |
|
2844 |
+
if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2845 |
|
2846 |
+
/**
|
2847 |
+
* Returns an array of all available border unit types.
|
2848 |
+
*
|
2849 |
+
* @uses apply_filters()
|
2850 |
+
*
|
2851 |
+
* @param string $field_id ID that's passed to the filter.
|
2852 |
+
*
|
2853 |
+
* @return array
|
2854 |
+
*
|
2855 |
+
* @access public
|
2856 |
+
* @since 2.5.0
|
2857 |
+
*/
|
2858 |
+
function ot_recognized_border_unit_types( $field_id ) {
|
2859 |
+
|
2860 |
+
return apply_filters(
|
2861 |
+
'ot_recognized_border_unit_types',
|
2862 |
+
array(
|
2863 |
+
'px' => 'px',
|
2864 |
+
'%' => '%',
|
2865 |
+
'em' => 'em',
|
2866 |
+
'pt' => 'pt',
|
2867 |
+
),
|
2868 |
+
$field_id
|
2869 |
+
);
|
2870 |
+
}
|
2871 |
}
|
2872 |
|
2873 |
+
if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2874 |
|
2875 |
+
/**
|
2876 |
+
* Returns an array of all available dimension unit types.
|
2877 |
+
*
|
2878 |
+
* @uses apply_filters()
|
2879 |
+
*
|
2880 |
+
* @param string $field_id ID that's passed to the filter.
|
2881 |
+
*
|
2882 |
+
* @return array
|
2883 |
+
*
|
2884 |
+
* @access public
|
2885 |
+
* @since 2.5.0
|
2886 |
+
*/
|
2887 |
+
function ot_recognized_dimension_unit_types( $field_id = '' ) {
|
2888 |
+
|
2889 |
+
return apply_filters(
|
2890 |
+
'ot_recognized_dimension_unit_types',
|
2891 |
+
array(
|
2892 |
+
'px' => 'px',
|
2893 |
+
'%' => '%',
|
2894 |
+
'em' => 'em',
|
2895 |
+
'pt' => 'pt',
|
2896 |
+
),
|
2897 |
+
$field_id
|
2898 |
+
);
|
2899 |
+
}
|
2900 |
}
|
2901 |
|
2902 |
+
if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) {
|
2903 |
+
|
2904 |
+
/**
|
2905 |
+
* Returns an array of all available spacing unit types.
|
2906 |
+
*
|
2907 |
+
* @uses apply_filters()
|
2908 |
+
*
|
2909 |
+
* @param string $field_id ID that's passed to the filter.
|
2910 |
+
*
|
2911 |
+
* @return array
|
2912 |
+
*
|
2913 |
+
* @access public
|
2914 |
+
* @since 2.5.0
|
2915 |
+
*/
|
2916 |
+
function ot_recognized_spacing_unit_types( $field_id ) {
|
2917 |
+
|
2918 |
+
return apply_filters(
|
2919 |
+
'ot_recognized_spacing_unit_types',
|
2920 |
+
array(
|
2921 |
+
'px' => 'px',
|
2922 |
+
'%' => '%',
|
2923 |
+
'em' => 'em',
|
2924 |
+
'pt' => 'pt',
|
2925 |
+
),
|
2926 |
+
$field_id
|
2927 |
+
);
|
2928 |
+
|
2929 |
+
}
|
2930 |
+
}
|
2931 |
|
2932 |
+
if ( ! function_exists( 'ot_recognized_google_font_families' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2933 |
|
2934 |
+
/**
|
2935 |
+
* Recognized Google font families
|
2936 |
+
*
|
2937 |
+
* @uses apply_filters()
|
2938 |
+
*
|
2939 |
+
* @param string $field_id ID that's passed to the filter.
|
2940 |
+
*
|
2941 |
+
* @return array
|
2942 |
+
*
|
2943 |
+
* @access public
|
2944 |
+
* @since 2.5.0
|
2945 |
+
*/
|
2946 |
+
function ot_recognized_google_font_families( $field_id ) {
|
2947 |
+
|
2948 |
+
$families = array();
|
2949 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
2950 |
+
|
2951 |
+
// Forces an array rebuild when we switch themes.
|
2952 |
+
if ( empty( $ot_google_fonts ) ) {
|
2953 |
+
$ot_google_fonts = ot_fetch_google_fonts( true, true );
|
2954 |
+
}
|
2955 |
+
|
2956 |
+
foreach ( (array) $ot_google_fonts as $key => $item ) {
|
2957 |
+
|
2958 |
+
if ( isset( $item['family'] ) ) {
|
2959 |
+
$families[ $key ] = $item['family'];
|
2960 |
+
}
|
2961 |
+
}
|
2962 |
+
|
2963 |
+
return apply_filters( 'ot_recognized_google_font_families', $families, $field_id );
|
2964 |
+
}
|
2965 |
}
|
2966 |
|
2967 |
+
if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2968 |
|
2969 |
+
/**
|
2970 |
+
* Recognized Google font variants
|
2971 |
+
*
|
2972 |
+
* @uses apply_filters()
|
2973 |
+
*
|
2974 |
+
* @param string $field_id ID that's passed to the filter.
|
2975 |
+
* @param string $family The font family.
|
2976 |
+
*
|
2977 |
+
* @return array
|
2978 |
+
*
|
2979 |
+
* @access public
|
2980 |
+
* @since 2.5.0
|
2981 |
+
*/
|
2982 |
+
function ot_recognized_google_font_variants( $field_id, $family ) {
|
2983 |
+
|
2984 |
+
$variants = array();
|
2985 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
2986 |
+
|
2987 |
+
if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) {
|
2988 |
+
$variants = $ot_google_fonts[ $family ]['variants'];
|
2989 |
+
}
|
2990 |
+
|
2991 |
+
return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family );
|
2992 |
+
}
|
2993 |
+
}
|
2994 |
+
|
2995 |
+
if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) {
|
2996 |
|
2997 |
+
/**
|
2998 |
+
* Recognized Google font subsets
|
2999 |
+
*
|
3000 |
+
* @uses apply_filters()
|
3001 |
+
*
|
3002 |
+
* @param string $field_id ID that's passed to the filter.
|
3003 |
+
* @param string $family The font family.
|
3004 |
+
*
|
3005 |
+
* @return array
|
3006 |
+
*
|
3007 |
+
* @access public
|
3008 |
+
* @since 2.5.0
|
3009 |
+
*/
|
3010 |
+
function ot_recognized_google_font_subsets( $field_id, $family ) {
|
3011 |
+
|
3012 |
+
$subsets = array();
|
3013 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
3014 |
+
|
3015 |
+
if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) {
|
3016 |
+
$subsets = $ot_google_fonts[ $family ]['subsets'];
|
3017 |
+
}
|
3018 |
+
|
3019 |
+
return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family );
|
3020 |
+
}
|
3021 |
}
|
3022 |
|
3023 |
+
if ( ! function_exists( 'ot_measurement_unit_types' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3024 |
|
3025 |
+
/**
|
3026 |
+
* Measurement Units
|
3027 |
+
*
|
3028 |
+
* Returns an array of all available unit types.
|
3029 |
+
* Renamed in version 2.0 to avoid name collisions.
|
3030 |
+
*
|
3031 |
+
* @uses apply_filters()
|
3032 |
+
*
|
3033 |
+
* @param string $field_id ID that's passed to the filter.
|
3034 |
+
*
|
3035 |
+
* @return array
|
3036 |
+
*
|
3037 |
+
* @access public
|
3038 |
+
* @since 1.1.8
|
3039 |
+
* @since 2.0
|
3040 |
+
*/
|
3041 |
+
function ot_measurement_unit_types( $field_id = '' ) {
|
3042 |
+
|
3043 |
+
return apply_filters(
|
3044 |
+
'ot_measurement_unit_types',
|
3045 |
+
array(
|
3046 |
+
'px' => 'px',
|
3047 |
+
'%' => '%',
|
3048 |
+
'em' => 'em',
|
3049 |
+
'pt' => 'pt',
|
3050 |
+
),
|
3051 |
+
$field_id
|
3052 |
+
);
|
3053 |
+
|
3054 |
+
}
|
3055 |
}
|
3056 |
|
3057 |
+
if ( ! function_exists( 'ot_radio_images' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3058 |
|
3059 |
+
/**
|
3060 |
+
* Radio Images default array.
|
3061 |
+
*
|
3062 |
+
* Returns an array of all available radio images.
|
3063 |
+
* You can filter this function to change the images
|
3064 |
+
* on a per option basis.
|
3065 |
+
*
|
3066 |
+
* @uses apply_filters()
|
3067 |
+
*
|
3068 |
+
* @param string $field_id ID that's passed to the filter.
|
3069 |
+
*
|
3070 |
+
* @return array
|
3071 |
+
*
|
3072 |
+
* @access public
|
3073 |
+
* @since 2.0
|
3074 |
+
*/
|
3075 |
+
function ot_radio_images( $field_id ) {
|
3076 |
+
|
3077 |
+
return apply_filters(
|
3078 |
+
'ot_radio_images',
|
3079 |
+
array(
|
3080 |
+
array(
|
3081 |
+
'value' => 'left-sidebar',
|
3082 |
+
'label' => esc_html__( 'Left Sidebar', 'option-tree' ),
|
3083 |
+
'src' => OT_URL . 'assets/images/layout/left-sidebar.png',
|
3084 |
+
),
|
3085 |
+
array(
|
3086 |
+
'value' => 'right-sidebar',
|
3087 |
+
'label' => esc_html__( 'Right Sidebar', 'option-tree' ),
|
3088 |
+
'src' => OT_URL . 'assets/images/layout/right-sidebar.png',
|
3089 |
+
),
|
3090 |
+
array(
|
3091 |
+
'value' => 'full-width',
|
3092 |
+
'label' => esc_html__( 'Full Width (no sidebar)', 'option-tree' ),
|
3093 |
+
'src' => OT_URL . 'assets/images/layout/full-width.png',
|
3094 |
+
),
|
3095 |
+
array(
|
3096 |
+
'value' => 'dual-sidebar',
|
3097 |
+
'label' => esc_html__( 'Dual Sidebar', 'option-tree' ),
|
3098 |
+
'src' => OT_URL . 'assets/images/layout/dual-sidebar.png',
|
3099 |
+
),
|
3100 |
+
array(
|
3101 |
+
'value' => 'left-dual-sidebar',
|
3102 |
+
'label' => esc_html__( 'Left Dual Sidebar', 'option-tree' ),
|
3103 |
+
'src' => OT_URL . 'assets/images/layout/left-dual-sidebar.png',
|
3104 |
+
),
|
3105 |
+
array(
|
3106 |
+
'value' => 'right-dual-sidebar',
|
3107 |
+
'label' => esc_html__( 'Right Dual Sidebar', 'option-tree' ),
|
3108 |
+
'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png',
|
3109 |
+
),
|
3110 |
+
),
|
3111 |
+
$field_id
|
3112 |
+
);
|
3113 |
+
|
3114 |
+
}
|
3115 |
}
|
3116 |
|
3117 |
+
if ( ! function_exists( 'ot_list_item_settings' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3118 |
|
3119 |
+
/**
|
3120 |
+
* Default List Item Settings array.
|
3121 |
+
*
|
3122 |
+
* Returns an array of the default list item settings.
|
3123 |
+
* You can filter this function to change the settings
|
3124 |
+
* on a per option basis.
|
3125 |
+
*
|
3126 |
+
* @uses apply_filters()
|
3127 |
+
*
|
3128 |
+
* @param string $field_id ID that's passed to the filter.
|
3129 |
+
*
|
3130 |
+
* @return array
|
3131 |
+
*
|
3132 |
+
* @access public
|
3133 |
+
* @since 2.0
|
3134 |
+
*/
|
3135 |
+
function ot_list_item_settings( $field_id ) {
|
3136 |
+
|
3137 |
+
$settings = apply_filters(
|
3138 |
+
'ot_list_item_settings',
|
3139 |
+
array(
|
3140 |
+
array(
|
3141 |
+
'id' => 'image',
|
3142 |
+
'label' => esc_html__( 'Image', 'option-tree' ),
|
3143 |
+
'desc' => '',
|
3144 |
+
'std' => '',
|
3145 |
+
'type' => 'upload',
|
3146 |
+
'rows' => '',
|
3147 |
+
'class' => '',
|
3148 |
+
'post_type' => '',
|
3149 |
+
'choices' => array(),
|
3150 |
+
),
|
3151 |
+
array(
|
3152 |
+
'id' => 'link',
|
3153 |
+
'label' => esc_html__( 'Link', 'option-tree' ),
|
3154 |
+
'desc' => '',
|
3155 |
+
'std' => '',
|
3156 |
+
'type' => 'text',
|
3157 |
+
'rows' => '',
|
3158 |
+
'class' => '',
|
3159 |
+
'post_type' => '',
|
3160 |
+
'choices' => array(),
|
3161 |
+
),
|
3162 |
+
array(
|
3163 |
+
'id' => 'description',
|
3164 |
+
'label' => esc_html__( 'Description', 'option-tree' ),
|
3165 |
+
'desc' => '',
|
3166 |
+
'std' => '',
|
3167 |
+
'type' => 'textarea-simple',
|
3168 |
+
'rows' => 10,
|
3169 |
+
'class' => '',
|
3170 |
+
'post_type' => '',
|
3171 |
+
'choices' => array(),
|
3172 |
+
),
|
3173 |
+
),
|
3174 |
+
$field_id
|
3175 |
+
);
|
3176 |
+
|
3177 |
+
return $settings;
|
3178 |
+
}
|
3179 |
}
|
3180 |
|
3181 |
+
if ( ! function_exists( 'ot_slider_settings' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3182 |
|
3183 |
+
/**
|
3184 |
+
* Default Slider Settings array.
|
3185 |
+
*
|
3186 |
+
* Returns an array of the default slider settings.
|
3187 |
+
* You can filter this function to change the settings
|
3188 |
+
* on a per option basis.
|
3189 |
+
*
|
3190 |
+
* @uses apply_filters()
|
3191 |
+
*
|
3192 |
+
* @param string $field_id ID that's passed to the filter.
|
3193 |
+
*
|
3194 |
+
* @return array
|
3195 |
+
*
|
3196 |
+
* @access public
|
3197 |
+
* @since 2.0
|
3198 |
+
*/
|
3199 |
+
function ot_slider_settings( $field_id ) {
|
3200 |
+
|
3201 |
+
$settings = apply_filters(
|
3202 |
+
'image_slider_fields',
|
3203 |
+
array(
|
3204 |
+
array(
|
3205 |
+
'name' => 'image',
|
3206 |
+
'type' => 'image',
|
3207 |
+
'label' => esc_html__( 'Image', 'option-tree' ),
|
3208 |
+
'class' => '',
|
3209 |
+
),
|
3210 |
+
array(
|
3211 |
+
'name' => 'link',
|
3212 |
+
'type' => 'text',
|
3213 |
+
'label' => esc_html__( 'Link', 'option-tree' ),
|
3214 |
+
'class' => '',
|
3215 |
+
),
|
3216 |
+
array(
|
3217 |
+
'name' => 'description',
|
3218 |
+
'type' => 'textarea',
|
3219 |
+
'label' => esc_html__( 'Description', 'option-tree' ),
|
3220 |
+
'class' => '',
|
3221 |
+
),
|
3222 |
+
),
|
3223 |
+
$field_id
|
3224 |
+
);
|
3225 |
+
|
3226 |
+
// Fix the array keys, values, and just get it 2.0 ready.
|
3227 |
+
foreach ( $settings as $_k => $setting ) {
|
3228 |
+
|
3229 |
+
foreach ( $setting as $s_key => $s_value ) {
|
3230 |
+
|
3231 |
+
if ( 'name' === $s_key ) {
|
3232 |
+
|
3233 |
+
$settings[ $_k ]['id'] = $s_value;
|
3234 |
+
unset( $settings[ $_k ]['name'] );
|
3235 |
+
} elseif ( 'type' === $s_key ) {
|
3236 |
+
|
3237 |
+
if ( 'input' === $s_value ) {
|
3238 |
+
|
3239 |
+
$settings[ $_k ]['type'] = 'text';
|
3240 |
+
} elseif ( 'textarea' === $s_value ) {
|
3241 |
+
|
3242 |
+
$settings[ $_k ]['type'] = 'textarea-simple';
|
3243 |
+
} elseif ( 'image' === $s_value ) {
|
3244 |
+
|
3245 |
+
$settings[ $_k ]['type'] = 'upload';
|
3246 |
+
}
|
3247 |
+
}
|
3248 |
+
}
|
3249 |
+
}
|
3250 |
+
|
3251 |
+
return $settings;
|
3252 |
+
}
|
3253 |
}
|
3254 |
|
3255 |
+
if ( ! function_exists( 'ot_social_links_settings' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3256 |
|
3257 |
+
/**
|
3258 |
+
* Default Social Links Settings array.
|
3259 |
+
*
|
3260 |
+
* Returns an array of the default social links settings.
|
3261 |
+
* You can filter this function to change the settings
|
3262 |
+
* on a per option basis.
|
3263 |
+
*
|
3264 |
+
* @uses apply_filters()
|
3265 |
+
*
|
3266 |
+
* @param string $field_id ID that's passed to the filter.
|
3267 |
+
*
|
3268 |
+
* @return array
|
3269 |
+
*
|
3270 |
+
* @access public
|
3271 |
+
* @since 2.4.0
|
3272 |
+
*/
|
3273 |
+
function ot_social_links_settings( $field_id ) {
|
3274 |
+
|
3275 |
+
/* translators: %s: the http protocol */
|
3276 |
+
$string = esc_html__( 'Enter a link to the profile or page on the social website. Remember to add the %s part to the front of the link.', 'option-tree' );
|
3277 |
+
$settings = apply_filters(
|
3278 |
+
'ot_social_links_settings',
|
3279 |
+
array(
|
3280 |
+
array(
|
3281 |
+
'id' => 'name',
|
3282 |
+
'label' => esc_html__( 'Name', 'option-tree' ),
|
3283 |
+
'desc' => esc_html__( 'Enter the name of the social website.', 'option-tree' ),
|
3284 |
+
'std' => '',
|
3285 |
+
'type' => 'text',
|
3286 |
+
'class' => 'option-tree-setting-title',
|
3287 |
+
),
|
3288 |
+
array(
|
3289 |
+
'id' => 'title',
|
3290 |
+
'label' => 'Title',
|
3291 |
+
'desc' => esc_html__( 'Enter the text shown in the title attribute of the link.', 'option-tree' ),
|
3292 |
+
'type' => 'text',
|
3293 |
+
),
|
3294 |
+
array(
|
3295 |
+
'id' => 'href',
|
3296 |
+
'label' => 'Link',
|
3297 |
+
'desc' => sprintf( $string, '<code>http:// or https://</code>' ),
|
3298 |
+
'type' => 'text',
|
3299 |
+
),
|
3300 |
+
),
|
3301 |
+
$field_id
|
3302 |
+
);
|
3303 |
+
|
3304 |
+
return $settings;
|
3305 |
+
}
|
3306 |
}
|
3307 |
|
3308 |
+
if ( ! function_exists( 'ot_insert_css_with_markers' ) ) {
|
3309 |
+
|
3310 |
+
/**
|
3311 |
+
* Inserts CSS with field_id markers.
|
3312 |
+
*
|
3313 |
+
* Inserts CSS into a dynamic.css file, placing it between
|
3314 |
+
* BEGIN and END field_id markers. Replaces existing marked info,
|
3315 |
+
* but still retains surrounding data.
|
3316 |
+
*
|
3317 |
+
* @param string $field_id The CSS option field ID.
|
3318 |
+
* @param string $insertion The current option_tree array.
|
3319 |
+
* @param bool $meta Whether or not the value is stored in meta.
|
3320 |
+
* @return bool True on write success, false on failure.
|
3321 |
+
*
|
3322 |
+
* @access public
|
3323 |
+
* @since 1.1.8
|
3324 |
+
* @updated 2.5.3
|
3325 |
+
*/
|
3326 |
+
function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = false ) {
|
3327 |
+
|
3328 |
+
// Missing $field_id or $insertion exit early.
|
3329 |
+
if ( '' === $field_id || '' === $insertion ) {
|
3330 |
+
return;
|
3331 |
+
}
|
3332 |
+
|
3333 |
+
// Path to the dynamic.css file.
|
3334 |
+
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3335 |
+
if ( is_multisite() ) {
|
3336 |
+
$multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css';
|
3337 |
+
if ( file_exists( $multisite_filepath ) ) {
|
3338 |
+
$filepath = $multisite_filepath;
|
3339 |
+
}
|
3340 |
+
}
|
3341 |
+
|
3342 |
+
// Allow filter on path.
|
3343 |
+
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3344 |
+
|
3345 |
+
// Grab a copy of the paths array.
|
3346 |
+
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
3347 |
+
if ( is_multisite() ) {
|
3348 |
+
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3349 |
+
}
|
3350 |
+
|
3351 |
+
// Set the path for this field.
|
3352 |
+
$ot_css_file_paths[ $field_id ] = $filepath;
|
3353 |
+
|
3354 |
+
/* update the paths */
|
3355 |
+
if ( is_multisite() ) {
|
3356 |
+
update_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
3357 |
+
} else {
|
3358 |
+
update_option( 'ot_css_file_paths', $ot_css_file_paths );
|
3359 |
+
}
|
3360 |
+
|
3361 |
+
// Remove CSS from file, but ensure the file is actually CSS first.
|
3362 |
+
$file_parts = explode( '.', basename( $filepath ) );
|
3363 |
+
$file_ext = end( $file_parts );
|
3364 |
+
if ( is_writeable( $filepath ) && 'css' === $file_ext ) {
|
3365 |
+
|
3366 |
+
$insertion = ot_normalize_css( $insertion );
|
3367 |
+
$regex = '/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/';
|
3368 |
+
$marker = $field_id;
|
3369 |
+
|
3370 |
+
// Match custom CSS.
|
3371 |
+
preg_match_all( $regex, $insertion, $matches );
|
3372 |
+
|
3373 |
+
// Loop through CSS.
|
3374 |
+
foreach ( $matches[0] as $option ) {
|
3375 |
+
|
3376 |
+
$value = '';
|
3377 |
+
$option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) );
|
3378 |
+
$option_id = isset( $option_array[0] ) ? $option_array[0] : '';
|
3379 |
+
$option_key = isset( $option_array[1] ) ? $option_array[1] : '';
|
3380 |
+
$option_type = ot_get_option_type_by_id( $option_id );
|
3381 |
+
$fallback = '';
|
3382 |
+
|
3383 |
+
// Get the meta array value.
|
3384 |
+
if ( $meta ) {
|
3385 |
+
global $post;
|
3386 |
+
|
3387 |
+
$value = get_post_meta( $post->ID, $option_id, true );
|
3388 |
+
|
3389 |
+
// Get the options array value.
|
3390 |
+
} else {
|
3391 |
+
$options = get_option( ot_options_id() );
|
3392 |
+
|
3393 |
+
if ( isset( $options[ $option_id ] ) ) {
|
3394 |
+
$value = $options[ $option_id ];
|
3395 |
+
}
|
3396 |
+
}
|
3397 |
+
|
3398 |
+
// This in an array of values.
|
3399 |
+
if ( is_array( $value ) ) {
|
3400 |
+
|
3401 |
+
if ( empty( $option_key ) ) {
|
3402 |
+
|
3403 |
+
// Measurement.
|
3404 |
+
if ( 'measurement' === $option_type ) {
|
3405 |
+
$unit = ! empty( $value[1] ) ? $value[1] : 'px';
|
3406 |
+
|
3407 |
+
// Set $value with measurement properties.
|
3408 |
+
if ( isset( $value[0] ) && strlen( $value[0] ) > 0 ) {
|
3409 |
+
$value = $value[0] . $unit;
|
3410 |
+
}
|
3411 |
+
|
3412 |
+
// Border.
|
3413 |
+
} elseif ( 'border' === $option_type ) {
|
3414 |
+
$border = array();
|
3415 |
+
|
3416 |
+
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3417 |
+
|
3418 |
+
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) {
|
3419 |
+
$border[] = $value['width'] . $unit;
|
3420 |
+
}
|
3421 |
+
|
3422 |
+
if ( ! empty( $value['style'] ) ) {
|
3423 |
+
$border[] = $value['style'];
|
3424 |
+
}
|
3425 |
+
|
3426 |
+
if ( ! empty( $value['color'] ) ) {
|
3427 |
+
$border[] = $value['color'];
|
3428 |
+
}
|
3429 |
+
|
3430 |
+
// Set $value with border properties or empty string.
|
3431 |
+
$value = ! empty( $border ) ? implode( ' ', $border ) : '';
|
3432 |
+
|
3433 |
+
// Box Shadow.
|
3434 |
+
} elseif ( 'box-shadow' === $option_type ) {
|
3435 |
+
|
3436 |
+
$value_safe = array();
|
3437 |
+
foreach ( $value as $val ) {
|
3438 |
+
if ( ! empty( $val ) ) {
|
3439 |
+
$value_safe[] = $val;
|
3440 |
+
}
|
3441 |
+
}
|
3442 |
+
// Set $value with box-shadow properties or empty string.
|
3443 |
+
$value = ! empty( $value_safe ) ? implode( ' ', $value_safe ) : '';
|
3444 |
|
3445 |
+
// Dimension.
|
3446 |
+
} elseif ( 'dimension' === $option_type ) {
|
3447 |
+
$dimension = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3448 |
|
3449 |
+
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3450 |
|
3451 |
+
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) {
|
3452 |
+
$dimension[] = $value['width'] . $unit;
|
3453 |
+
}
|
3454 |
|
3455 |
+
if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 ) {
|
3456 |
+
$dimension[] = $value['height'] . $unit;
|
3457 |
+
}
|
3458 |
|
3459 |
+
// Set $value with dimension properties or empty string.
|
3460 |
+
$value = ! empty( $dimension ) ? implode( ' ', $dimension ) : '';
|
3461 |
|
3462 |
+
// Spacing.
|
3463 |
+
} elseif ( 'spacing' === $option_type ) {
|
3464 |
+
$spacing = array();
|
3465 |
|
3466 |
+
$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';
|
3467 |
|
3468 |
+
if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 ) {
|
3469 |
+
$spacing[] = $value['top'] . $unit;
|
3470 |
+
}
|
3471 |
|
3472 |
+
if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 ) {
|
3473 |
+
$spacing[] = $value['right'] . $unit;
|
3474 |
+
}
|
|
|
|
|
3475 |
|
3476 |
+
if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 ) {
|
3477 |
+
$spacing[] = $value['bottom'] . $unit;
|
3478 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
3479 |
|
3480 |
+
if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 ) {
|
3481 |
+
$spacing[] = $value['left'] . $unit;
|
3482 |
+
}
|
3483 |
|
3484 |
+
// Set $value with spacing properties or empty string.
|
3485 |
+
$value = ! empty( $spacing ) ? implode( ' ', $spacing ) : '';
|
3486 |
|
3487 |
+
// Typography.
|
3488 |
+
} elseif ( 'typography' === $option_type ) {
|
3489 |
+
$font = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3490 |
|
3491 |
+
if ( ! empty( $value['font-color'] ) ) {
|
3492 |
+
$font[] = 'color: ' . $value['font-color'] . ';';
|
3493 |
+
}
|
3494 |
|
3495 |
+
if ( ! empty( $value['font-family'] ) ) {
|
3496 |
+
foreach ( ot_recognized_font_families( $marker ) as $key => $v ) {
|
3497 |
+
if ( $key === $value['font-family'] ) {
|
3498 |
+
$font[] = 'font-family: ' . $v . ';';
|
3499 |
+
}
|
3500 |
+
}
|
3501 |
+
}
|
3502 |
|
3503 |
+
if ( ! empty( $value['font-size'] ) ) {
|
3504 |
+
$font[] = 'font-size: ' . $value['font-size'] . ';';
|
3505 |
+
}
|
3506 |
|
3507 |
+
if ( ! empty( $value['font-style'] ) ) {
|
3508 |
+
$font[] = 'font-style: ' . $value['font-style'] . ';';
|
3509 |
+
}
|
3510 |
|
3511 |
+
if ( ! empty( $value['font-variant'] ) ) {
|
3512 |
+
$font[] = 'font-variant: ' . $value['font-variant'] . ';';
|
3513 |
+
}
|
3514 |
+
|
3515 |
+
if ( ! empty( $value['font-weight'] ) ) {
|
3516 |
+
$font[] = 'font-weight: ' . $value['font-weight'] . ';';
|
3517 |
+
}
|
3518 |
+
|
3519 |
+
if ( ! empty( $value['letter-spacing'] ) ) {
|
3520 |
+
$font[] = 'letter-spacing: ' . $value['letter-spacing'] . ';';
|
3521 |
+
}
|
3522 |
+
|
3523 |
+
if ( ! empty( $value['line-height'] ) ) {
|
3524 |
+
$font[] = 'line-height: ' . $value['line-height'] . ';';
|
3525 |
+
}
|
3526 |
+
|
3527 |
+
if ( ! empty( $value['text-decoration'] ) ) {
|
3528 |
+
$font[] = 'text-decoration: ' . $value['text-decoration'] . ';';
|
3529 |
+
}
|
3530 |
+
|
3531 |
+
if ( ! empty( $value['text-transform'] ) ) {
|
3532 |
+
$font[] = 'text-transform: ' . $value['text-transform'] . ';';
|
3533 |
+
}
|
3534 |
+
|
3535 |
+
// Set $value with font properties or empty string.
|
3536 |
+
$value = ! empty( $font ) ? implode( "\n", $font ) : '';
|
3537 |
+
|
3538 |
+
// Background.
|
3539 |
+
} elseif ( 'background' === $option_type ) {
|
3540 |
+
$bg = array();
|
3541 |
+
|
3542 |
+
if ( ! empty( $value['background-color'] ) ) {
|
3543 |
+
$bg[] = $value['background-color'];
|
3544 |
+
}
|
3545 |
+
|
3546 |
+
if ( ! empty( $value['background-image'] ) ) {
|
3547 |
+
|
3548 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
3549 |
+
if ( wp_attachment_is_image( $value['background-image'] ) ) {
|
3550 |
+
|
3551 |
+
$attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' );
|
3552 |
+
|
3553 |
+
// Check for attachment data.
|
3554 |
+
if ( $attachment_data ) {
|
3555 |
+
$value['background-image'] = $attachment_data[0];
|
3556 |
+
}
|
3557 |
+
}
|
3558 |
+
|
3559 |
+
$bg[] = 'url("' . $value['background-image'] . '")';
|
3560 |
+
}
|
3561 |
+
|
3562 |
+
if ( ! empty( $value['background-repeat'] ) ) {
|
3563 |
+
$bg[] = $value['background-repeat'];
|
3564 |
+
}
|
3565 |
+
|
3566 |
+
if ( ! empty( $value['background-attachment'] ) ) {
|
3567 |
+
$bg[] = $value['background-attachment'];
|
3568 |
+
}
|
3569 |
+
|
3570 |
+
if ( ! empty( $value['background-position'] ) ) {
|
3571 |
+
$bg[] = $value['background-position'];
|
3572 |
+
}
|
3573 |
+
|
3574 |
+
if ( ! empty( $value['background-size'] ) ) {
|
3575 |
+
$size = $value['background-size'];
|
3576 |
+
}
|
3577 |
+
|
3578 |
+
// Set $value with background properties or empty string.
|
3579 |
+
$value = ! empty( $bg ) ? 'background: ' . implode( ' ', $bg ) . ';' : '';
|
3580 |
+
|
3581 |
+
if ( isset( $size ) ) {
|
3582 |
+
if ( ! empty( $bg ) ) {
|
3583 |
+
$value .= apply_filters( 'ot_insert_css_with_markers_bg_size_white_space', "\n\x20\x20", $option_id );
|
3584 |
+
}
|
3585 |
+
$value .= "background-size: $size;";
|
3586 |
+
}
|
3587 |
+
}
|
3588 |
+
} elseif ( ! empty( $value[ $option_key ] ) ) {
|
3589 |
+
$value = $value[ $option_key ];
|
3590 |
+
}
|
3591 |
+
}
|
3592 |
+
|
3593 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
3594 |
+
if ( 'upload' === $option_type && wp_attachment_is_image( $value ) ) {
|
3595 |
+
|
3596 |
+
$attachment_data = wp_get_attachment_image_src( $value, 'original' );
|
3597 |
+
|
3598 |
+
// Check for attachment data.
|
3599 |
+
if ( $attachment_data ) {
|
3600 |
+
$value = $attachment_data[0];
|
3601 |
+
}
|
3602 |
+
}
|
3603 |
+
|
3604 |
+
// Attempt to fallback when `$value` is empty.
|
3605 |
+
if ( empty( $value ) ) {
|
3606 |
+
|
3607 |
+
// We're trying to access a single array key.
|
3608 |
+
if ( ! empty( $option_key ) ) {
|
3609 |
+
|
3610 |
+
// Link Color `inherit`.
|
3611 |
+
if ( 'link-color' === $option_type ) {
|
3612 |
+
$fallback = 'inherit';
|
3613 |
+
}
|
3614 |
+
} else {
|
3615 |
+
|
3616 |
+
// Border.
|
3617 |
+
if ( 'border' === $option_type ) {
|
3618 |
+
$fallback = 'inherit';
|
3619 |
+
}
|
3620 |
+
|
3621 |
+
// Box Shadow.
|
3622 |
+
if ( 'box-shadow' === $option_type ) {
|
3623 |
+
$fallback = 'none';
|
3624 |
+
}
|
3625 |
+
|
3626 |
+
// Colorpicker.
|
3627 |
+
if ( 'colorpicker' === $option_type ) {
|
3628 |
+
$fallback = 'inherit';
|
3629 |
+
}
|
3630 |
+
|
3631 |
+
// Colorpicker Opacity.
|
3632 |
+
if ( 'colorpicker-opacity' === $option_type ) {
|
3633 |
+
$fallback = 'inherit';
|
3634 |
+
}
|
3635 |
+
}
|
3636 |
+
|
3637 |
+
/**
|
3638 |
+
* Filter the `dynamic.css` fallback value.
|
3639 |
+
*
|
3640 |
+
* @since 2.5.3
|
3641 |
+
*
|
3642 |
+
* @param string $fallback The default CSS fallback value.
|
3643 |
+
* @param string $option_id The option ID.
|
3644 |
+
* @param string $option_type The option type.
|
3645 |
+
* @param string $option_key The option array key.
|
3646 |
+
*/
|
3647 |
+
$fallback = apply_filters( 'ot_insert_css_with_markers_fallback', $fallback, $option_id, $option_type, $option_key );
|
3648 |
+
}
|
3649 |
+
|
3650 |
+
// Let's fallback!
|
3651 |
+
if ( ! empty( $fallback ) ) {
|
3652 |
+
$value = $fallback;
|
3653 |
+
}
|
3654 |
+
|
3655 |
+
// Filter the CSS.
|
3656 |
+
$value = apply_filters( 'ot_insert_css_with_markers_value', $value, $option_id );
|
3657 |
+
|
3658 |
+
// Insert CSS, even if the value is empty.
|
3659 |
+
$insertion = stripslashes( str_replace( $option, $value, $insertion ) );
|
3660 |
+
}
|
3661 |
+
|
3662 |
+
// Can't write to the file so we error out.
|
3663 |
+
if ( ! is_writable( $filepath ) ) {
|
3664 |
+
/* translators: %s: file path */
|
3665 |
+
$string = esc_html__( 'Unable to write to file %s.', 'option-tree' );
|
3666 |
+
add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '<code>' . $filepath . '</code>' ), 'error' );
|
3667 |
+
return false;
|
3668 |
+
}
|
3669 |
+
|
3670 |
+
// Open file.
|
3671 |
+
$f = @fopen( $filepath, 'w' ); // phpcs:ignore
|
3672 |
+
|
3673 |
+
// Can't write to the file return false.
|
3674 |
+
if ( ! $f ) {
|
3675 |
+
/* translators: %s: file path */
|
3676 |
+
$string = esc_html__( 'Unable to open the %s file in write mode.', 'option-tree' );
|
3677 |
+
add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '<code>' . $filepath . '</code>' ), 'error' );
|
3678 |
+
return false;
|
3679 |
+
}
|
3680 |
+
|
3681 |
+
// Create array from the lines of code.
|
3682 |
+
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3683 |
+
|
3684 |
+
$searching = true;
|
3685 |
+
$foundit = false;
|
3686 |
+
|
3687 |
+
// Has array of lines.
|
3688 |
+
if ( ! empty( $markerdata ) ) {
|
3689 |
+
|
3690 |
+
// Foreach line of code.
|
3691 |
+
foreach ( $markerdata as $n => $markerline ) {
|
3692 |
+
|
3693 |
+
// Found begining of marker, set $searching to false.
|
3694 |
+
if ( "/* BEGIN {$marker} */" === $markerline ) {
|
3695 |
+
$searching = false;
|
3696 |
+
}
|
3697 |
+
|
3698 |
+
// Keep searching each line of CSS.
|
3699 |
+
if ( true === $searching ) {
|
3700 |
+
if ( $n + 1 < count( $markerdata ) ) {
|
3701 |
+
fwrite( $f, "{$markerline}\n" ); // phpcs:ignore
|
3702 |
+
} else {
|
3703 |
+
fwrite( $f, "{$markerline}" ); // phpcs:ignore
|
3704 |
+
}
|
3705 |
+
}
|
3706 |
+
|
3707 |
+
// Found end marker write code.
|
3708 |
+
if ( "/* END {$marker} */" === $markerline ) {
|
3709 |
+
fwrite( $f, "/* BEGIN {$marker} */\n" ); // phpcs:ignore
|
3710 |
+
fwrite( $f, "{$insertion}\n" ); // phpcs:ignore
|
3711 |
+
fwrite( $f, "/* END {$marker} */\n" ); // phpcs:ignore
|
3712 |
+
$searching = true;
|
3713 |
+
$foundit = true;
|
3714 |
+
}
|
3715 |
+
}
|
3716 |
+
}
|
3717 |
+
|
3718 |
+
// Nothing inserted, write code. DO IT, DO IT!
|
3719 |
+
if ( ! $foundit ) {
|
3720 |
+
fwrite( $f, "/* BEGIN {$marker} */\n" ); // phpcs:ignore
|
3721 |
+
fwrite( $f, "{$insertion}\n" ); // phpcs:ignore
|
3722 |
+
fwrite( $f, "/* END {$marker} */\n" ); // phpcs:ignore
|
3723 |
+
}
|
3724 |
+
|
3725 |
+
// Close file.
|
3726 |
+
fclose( $f ); // phpcs:ignore
|
3727 |
+
return true;
|
3728 |
+
}
|
3729 |
+
|
3730 |
+
return false;
|
3731 |
+
}
|
3732 |
}
|
3733 |
|
3734 |
+
if ( ! function_exists( 'ot_remove_old_css' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3735 |
|
3736 |
+
/**
|
3737 |
+
* Remove old CSS.
|
3738 |
+
*
|
3739 |
+
* Removes CSS when the textarea is empty, but still retains surrounding styles.
|
3740 |
+
*
|
3741 |
+
* @param string $field_id The CSS option field ID.
|
3742 |
+
* @return bool True on write success, false on failure.
|
3743 |
+
*
|
3744 |
+
* @access public
|
3745 |
+
* @since 2.0
|
3746 |
+
*/
|
3747 |
+
function ot_remove_old_css( $field_id = '' ) {
|
3748 |
+
|
3749 |
+
// Missing $field_id string.
|
3750 |
+
if ( '' === $field_id ) {
|
3751 |
+
return false;
|
3752 |
+
}
|
3753 |
+
|
3754 |
+
// Path to the dynamic.css file.
|
3755 |
+
$filepath = get_stylesheet_directory() . '/dynamic.css';
|
3756 |
+
|
3757 |
+
// Allow filter on path.
|
3758 |
+
$filepath = apply_filters( 'css_option_file_path', $filepath, $field_id );
|
3759 |
+
|
3760 |
+
// Remove CSS from file, but ensure the file is actually CSS first.
|
3761 |
+
if ( is_writeable( $filepath ) && 'css' === end( explode( '.', basename( $filepath ) ) ) ) {
|
3762 |
+
|
3763 |
+
// Open the file.
|
3764 |
+
$f = @fopen( $filepath, 'w' ); // phpcs:ignore
|
3765 |
+
|
3766 |
+
// Can't write to the file return false.
|
3767 |
+
if ( ! $f ) {
|
3768 |
+
/* translators: %s: file path */
|
3769 |
+
$string = esc_html__( 'Unable to open the %s file in write mode.', 'option-tree' );
|
3770 |
+
add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '<code>' . $filepath . '</code>' ), 'error' );
|
3771 |
+
return false;
|
3772 |
+
}
|
3773 |
+
|
3774 |
+
// Get each line in the file.
|
3775 |
+
$markerdata = explode( "\n", implode( '', file( $filepath ) ) );
|
3776 |
+
|
3777 |
+
$searching = true;
|
3778 |
+
|
3779 |
+
// Has array of lines.
|
3780 |
+
if ( ! empty( $markerdata ) ) {
|
3781 |
+
|
3782 |
+
// Foreach line of code.
|
3783 |
+
foreach ( $markerdata as $n => $markerline ) {
|
3784 |
+
|
3785 |
+
// Found beginning of marker, set $searching to false.
|
3786 |
+
if ( "/* BEGIN {$field_id} */" === $markerline ) {
|
3787 |
+
$searching = false;
|
3788 |
+
}
|
3789 |
+
|
3790 |
+
// Searching is true, keep writing each line of CSS.
|
3791 |
+
if ( true === $searching ) {
|
3792 |
+
if ( $n + 1 < count( $markerdata ) ) {
|
3793 |
+
fwrite( $f, "{$markerline}\n" ); // phpcs:ignore
|
3794 |
+
} else {
|
3795 |
+
fwrite( $f, "{$markerline}" ); // phpcs:ignore
|
3796 |
+
}
|
3797 |
+
}
|
3798 |
+
|
3799 |
+
// Found end marker delete old CSS.
|
3800 |
+
if ( "/* END {$field_id} */" === $markerline ) {
|
3801 |
+
fwrite( $f, '' ); // phpcs:ignore
|
3802 |
+
$searching = true;
|
3803 |
+
}
|
3804 |
+
}
|
3805 |
+
}
|
3806 |
+
|
3807 |
+
// Close file.
|
3808 |
+
fclose( $f ); // phpcs:ignore
|
3809 |
+
return true;
|
3810 |
+
}
|
3811 |
+
|
3812 |
+
return false;
|
3813 |
+
}
|
3814 |
+
}
|
3815 |
+
|
3816 |
+
if ( ! function_exists( 'ot_normalize_css' ) ) {
|
3817 |
|
3818 |
+
/**
|
3819 |
+
* Normalize CSS
|
3820 |
+
*
|
3821 |
+
* Normalize & Convert all line-endings to UNIX format.
|
3822 |
+
*
|
3823 |
+
* @param string $css The CSS styles.
|
3824 |
+
*
|
3825 |
+
* @return string
|
3826 |
+
*
|
3827 |
+
* @access public
|
3828 |
+
* @since 1.1.8
|
3829 |
+
* @updated 2.0
|
3830 |
+
*/
|
3831 |
+
function ot_normalize_css( $css ) {
|
3832 |
+
|
3833 |
+
// Normalize & Convert.
|
3834 |
+
$css = str_replace( "\r\n", "\n", $css );
|
3835 |
+
$css = str_replace( "\r", "\n", $css );
|
3836 |
+
|
3837 |
+
// Don't allow out-of-control blank lines .
|
3838 |
+
$css = preg_replace( "/\n{2,}/", "\n\n", $css );
|
3839 |
+
|
3840 |
+
return $css;
|
3841 |
+
}
|
3842 |
+
}
|
3843 |
|
3844 |
+
if ( ! function_exists( 'ot_loop_through_option_types' ) ) {
|
3845 |
|
3846 |
+
/**
|
3847 |
+
* Helper function to loop over the option types.
|
3848 |
+
*
|
3849 |
+
* @param string $type The current option type.
|
3850 |
+
* @param bool $child Whether of not there are children elements.
|
3851 |
+
*
|
3852 |
+
* @return string
|
3853 |
+
*
|
3854 |
+
* @access public
|
3855 |
+
* @since 2.0
|
3856 |
+
*/
|
3857 |
+
function ot_loop_through_option_types( $type = '', $child = false ) {
|
3858 |
+
|
3859 |
+
$content = '';
|
3860 |
+
$types = ot_option_types_array();
|
3861 |
+
|
3862 |
+
if ( $child ) {
|
3863 |
+
unset( $types['list-item'] );
|
3864 |
+
}
|
3865 |
+
|
3866 |
+
foreach ( $types as $key => $value ) {
|
3867 |
+
$content .= '<option value="' . esc_attr( $key ) . '" ' . selected( $type, $key, false ) . '>' . esc_html( $value ) . '</option>';
|
3868 |
+
}
|
3869 |
+
|
3870 |
+
return $content;
|
3871 |
+
|
3872 |
+
}
|
3873 |
+
}
|
3874 |
|
3875 |
+
if ( ! function_exists( 'ot_loop_through_choices' ) ) {
|
3876 |
|
3877 |
+
/**
|
3878 |
+
* Helper function to loop over choices.
|
3879 |
+
*
|
3880 |
+
* @param string $name The form element name.
|
3881 |
+
* @param array $choices The array of choices.
|
3882 |
+
*
|
3883 |
+
* @return string
|
3884 |
+
*
|
3885 |
+
* @access public
|
3886 |
+
* @since 2.0
|
3887 |
+
*/
|
3888 |
+
function ot_loop_through_choices( $name, $choices = array() ) {
|
3889 |
+
|
3890 |
+
$content = '';
|
3891 |
+
|
3892 |
+
foreach ( (array) $choices as $key => $choice ) {
|
3893 |
+
if ( is_array( $choice ) ) {
|
3894 |
+
$content .= '<li class="ui-state-default list-choice">' . ot_choices_view( $name, $key, $choice ) . '</li>';
|
3895 |
+
}
|
3896 |
+
}
|
3897 |
+
|
3898 |
+
return $content;
|
3899 |
+
}
|
3900 |
+
}
|
3901 |
|
3902 |
+
if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) {
|
3903 |
|
3904 |
+
/**
|
3905 |
+
* Helper function to loop over sub settings.
|
3906 |
+
*
|
3907 |
+
* @param string $name The form element name.
|
3908 |
+
* @param array $settings The array of settings.
|
3909 |
+
*
|
3910 |
+
* @return string
|
3911 |
+
*
|
3912 |
+
* @access public
|
3913 |
+
* @since 2.0
|
3914 |
+
*/
|
3915 |
+
function ot_loop_through_sub_settings( $name, $settings = array() ) {
|
3916 |
+
|
3917 |
+
$content = '';
|
3918 |
+
|
3919 |
+
foreach ( $settings as $key => $setting ) {
|
3920 |
+
if ( is_array( $setting ) ) {
|
3921 |
+
$content .= '<li class="ui-state-default list-sub-setting">' . ot_settings_view( $name, $key, $setting ) . '</li>';
|
3922 |
+
}
|
3923 |
+
}
|
3924 |
+
|
3925 |
+
return $content;
|
3926 |
+
}
|
3927 |
+
}
|
3928 |
|
3929 |
+
if ( ! function_exists( 'ot_sections_view' ) ) {
|
3930 |
|
3931 |
+
/**
|
3932 |
+
* Helper function to display sections.
|
3933 |
+
*
|
3934 |
+
* This function is used in AJAX to add a new section
|
3935 |
+
* and when section have already been added and saved.
|
3936 |
+
*
|
3937 |
+
* @param string $name The form element name.
|
3938 |
+
* @param int $key The array key for the current element.
|
3939 |
+
* @param array $section An array of values for the current section.
|
3940 |
+
*
|
3941 |
+
* @return string
|
3942 |
+
*
|
3943 |
+
* @access public
|
3944 |
+
* @since 2.0
|
3945 |
+
*/
|
3946 |
+
function ot_sections_view( $name, $key, $section = array() ) {
|
3947 |
+
|
3948 |
+
/* translators: %s: Section Title emphasized */
|
3949 |
+
$str_title = esc_html__( '%s: Displayed as a menu item on the Theme Options page.', 'option-tree' );
|
3950 |
+
|
3951 |
+
/* translators: %s: Section ID emphasized */
|
3952 |
+
$str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' );
|
3953 |
+
|
3954 |
+
return '
|
3955 |
+
<div class="option-tree-setting is-section">
|
3956 |
+
<div class="open">' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( absint( $key ) + 1 ) ) . '</div>
|
3957 |
+
<div class="button-section">
|
3958 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'edit', 'option-tree' ) . '">
|
3959 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
3960 |
+
</a>
|
3961 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
3962 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
3963 |
+
</a>
|
3964 |
+
</div>
|
3965 |
+
<div class="option-tree-setting-body">
|
3966 |
+
<div class="format-settings">
|
3967 |
+
<div class="format-setting type-text">
|
3968 |
+
<div class="description">' . sprintf( $str_title, '<strong>' . esc_html__( 'Section Title', 'option-tree' ) . '</strong>', 'option-tree' ) . '</div>
|
3969 |
+
<div class="format-setting-inner">
|
3970 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title section-title" autocomplete="off" />
|
3971 |
+
</div>
|
3972 |
+
</div>
|
3973 |
+
</div>
|
3974 |
+
<div class="format-settings">
|
3975 |
+
<div class="format-setting type-text">
|
3976 |
+
<div class="description">' . sprintf( $str_id, '<strong>' . esc_html__( 'Section ID', 'option-tree' ) . '</strong>', 'option-tree' ) . '</div>
|
3977 |
+
<div class="format-setting-inner">
|
3978 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $section['id'] ) ? esc_attr( $section['id'] ) : '' ) . '" class="widefat option-tree-ui-input section-id" autocomplete="off" />
|
3979 |
+
</div>
|
3980 |
+
</div>
|
3981 |
+
</div>
|
3982 |
+
</div>
|
3983 |
+
</div>';
|
3984 |
+
}
|
3985 |
+
}
|
3986 |
|
3987 |
+
if ( ! function_exists( 'ot_settings_view' ) ) {
|
3988 |
|
3989 |
+
/**
|
3990 |
+
* Helper function to display settings.
|
3991 |
+
*
|
3992 |
+
* This function is used in AJAX to add a new setting
|
3993 |
+
* and when settings have already been added and saved.
|
3994 |
+
*
|
3995 |
+
* @param string $name The form element name.
|
3996 |
+
* @param int $key The array key for the current element.
|
3997 |
+
* @param array $setting An array of values for the current setting.
|
3998 |
+
*
|
3999 |
+
* @return string
|
4000 |
+
*
|
4001 |
+
* @access public
|
4002 |
+
* @since 2.0
|
4003 |
+
*/
|
4004 |
+
function ot_settings_view( $name, $key, $setting = array() ) {
|
4005 |
+
|
4006 |
+
$child = ( false !== strpos( $name, '][settings]' ) ) ? true : false;
|
4007 |
+
$type = isset( $setting['type'] ) ? $setting['type'] : '';
|
4008 |
+
$std = isset( $setting['std'] ) ? $setting['std'] : '';
|
4009 |
+
$operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and';
|
4010 |
+
|
4011 |
+
// Serialize the standard value just in case.
|
4012 |
+
if ( is_array( $std ) ) {
|
4013 |
+
$std = maybe_serialize( $std );
|
4014 |
+
}
|
4015 |
+
|
4016 |
+
if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ), true ) ) {
|
4017 |
+
$std_form_element = '<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]">' . esc_html( $std ) . '</textarea>';
|
4018 |
+
} else {
|
4019 |
+
$std_form_element = '<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][std]" value="' . esc_attr( $std ) . '" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4020 |
+
}
|
4021 |
+
|
4022 |
+
/* translators: %s: Label emphasized */
|
4023 |
+
$str_label = esc_html__( '%s: Displayed as the label of a form element on the Theme Options page.', 'option-tree' );
|
4024 |
+
|
4025 |
+
/* translators: %s: ID emphasized */
|
4026 |
+
$str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' );
|
4027 |
+
|
4028 |
+
/* translators: %s: Type emphasized */
|
4029 |
+
$str_type = esc_html__( '%s: Choose one of the available option types from the dropdown.', 'option-tree' );
|
4030 |
+
|
4031 |
+
/* translators: %s: Description emphasized */
|
4032 |
+
$str_desc = esc_html__( '%s: Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' );
|
4033 |
+
|
4034 |
+
/* translators: %s: Choices emphasized */
|
4035 |
+
$str_choices = esc_html__( '%s: This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' );
|
4036 |
+
|
4037 |
+
/* translators: %s: Settings emphasized */
|
4038 |
+
$str_settings = esc_html__( '%s: This will only affect the List Item option type.', 'option-tree' );
|
4039 |
+
|
4040 |
+
/* translators: %1$s: Standard emphasized, %2$s: visual path to documentation */
|
4041 |
+
$str_standard = esc_html__( '%1$s: Setting the standard value for your option only works for some option types. Read the %2$s for more information on which ones.', 'option-tree' );
|
4042 |
+
|
4043 |
+
/* translators: %s: Rows emphasized */
|
4044 |
+
$str_rows = esc_html__( '%s: Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' );
|
4045 |
+
|
4046 |
+
/* translators: %s: Post Type emphasized */
|
4047 |
+
$str_post_type = esc_html__( '%s: Add a comma separated list of post type like \'post,page\'. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select.', 'option-tree' );
|
4048 |
+
|
4049 |
+
/* translators: %s: Taxonomy emphasized */
|
4050 |
+
$str_taxonomy = esc_html__( '%s: Add a comma separated list of any registered taxonomy like \'category,post_tag\'. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' );
|
4051 |
+
|
4052 |
+
/* translators: %1$s: Min, Max, & Step emphasized, %2$s: format, %3$s: range, %4$s: minimum interval */
|
4053 |
+
$str_min_max_step = esc_html__( '%1$s: Add a comma separated list of options in the following format %2$s (slide from %3$s in intervals of %4$s). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' );
|
4054 |
+
|
4055 |
+
/* translators: %s: CSS Class emphasized */
|
4056 |
+
$str_css_class = esc_html__( '%s: Add and optional class to this option type.', 'option-tree' );
|
4057 |
+
|
4058 |
+
/* translators: %1$s: Condition emphasized, %2$s: example value, %3$s: list of valid conditions */
|
4059 |
+
$str_condition = esc_html__( '%1$s: Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, %2$s is a placeholder for your condition, which can be in the form of %3$s.', 'option-tree' );
|
4060 |
+
|
4061 |
+
/* translators: %s: Operator emphasized */
|
4062 |
+
$str_operator = esc_html__( '%s: Choose the logical operator to compute the result of the conditions.', 'option-tree' );
|
4063 |
+
|
4064 |
+
return '
|
4065 |
+
<div class="option-tree-setting">
|
4066 |
+
<div class="open">' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( absint( $key ) + 1 ) ) . '</div>
|
4067 |
+
<div class="button-section">
|
4068 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4069 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4070 |
+
</a>
|
4071 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4072 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4073 |
+
</a>
|
4074 |
+
</div>
|
4075 |
+
<div class="option-tree-setting-body">
|
4076 |
+
<div class="format-settings">
|
4077 |
+
<div class="format-setting type-text wide-desc">
|
4078 |
+
<div class="description">' . sprintf( $str_label, '<strong>' . esc_html__( 'Label', 'option-tree' ) . '</strong>' ) . '</div>
|
4079 |
+
<div class="format-setting-inner">
|
4080 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][label]" value="' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4081 |
+
</div>
|
4082 |
+
</div>
|
4083 |
+
</div>
|
4084 |
+
<div class="format-settings">
|
4085 |
+
<div class="format-setting type-text wide-desc">
|
4086 |
+
<div class="description">' . sprintf( $str_id, '<strong>' . esc_html__( 'ID', 'option-tree' ) . '</strong>' ) . '</div>
|
4087 |
+
<div class="format-setting-inner">
|
4088 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $setting['id'] ) ? esc_attr( $setting['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4089 |
+
</div>
|
4090 |
+
</div>
|
4091 |
+
</div>
|
4092 |
+
<div class="format-settings">
|
4093 |
+
<div class="format-setting type-select wide-desc">
|
4094 |
+
<div class="description">' . sprintf( $str_type, '<strong>' . esc_html__( 'Type', 'option-tree' ) . '</strong>' ) . '</div>
|
4095 |
+
<div class="format-setting-inner">
|
4096 |
+
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][type]" value="' . esc_attr( $type ) . '" class="option-tree-ui-select">
|
4097 |
+
' . ot_loop_through_option_types( $type, $child ) . '
|
4098 |
+
</select>
|
4099 |
+
</div>
|
4100 |
+
</div>
|
4101 |
+
</div>
|
4102 |
+
<div class="format-settings">
|
4103 |
+
<div class="format-setting type-textarea wide-desc">
|
4104 |
+
<div class="description">' . sprintf( $str_desc, '<strong>' . esc_html__( 'Description', 'option-tree' ) . '</strong>' ) . '</div>
|
4105 |
+
<div class="format-setting-inner">
|
4106 |
+
<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][desc]">' . ( isset( $setting['desc'] ) ? esc_html( $setting['desc'] ) : '' ) . '</textarea>
|
4107 |
+
</div>
|
4108 |
+
</div>
|
4109 |
+
</div>
|
4110 |
+
<div class="format-settings">
|
4111 |
+
<div class="format-setting type-textblock wide-desc">
|
4112 |
+
<div class="description">' . sprintf( $str_choices, '<strong>' . esc_html__( 'Choices', 'option-tree' ) . '</strong>' ) . '</div>
|
4113 |
+
<div class="format-setting-inner">
|
4114 |
+
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4115 |
+
' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . '
|
4116 |
+
</ul>
|
4117 |
+
<a href="javascript:void(0);" class="option-tree-choice-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Choice', 'option-tree' ) . '</a>
|
4118 |
+
</div>
|
4119 |
+
</div>
|
4120 |
+
</div>
|
4121 |
+
<div class="format-settings">
|
4122 |
+
<div class="format-setting type-textblock wide-desc">
|
4123 |
+
<div class="description">' . sprintf( $str_settings, '<strong>' . esc_html__( 'Settings', 'option-tree' ) . '</strong>' ) . '</div>
|
4124 |
+
<div class="format-setting-inner">
|
4125 |
+
<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . ']">
|
4126 |
+
' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . '
|
4127 |
+
</ul>
|
4128 |
+
<a href="javascript:void(0);" class="option-tree-list-item-setting-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Setting', 'option-tree' ) . '</a>
|
4129 |
+
</div>
|
4130 |
+
</div>
|
4131 |
+
</div>
|
4132 |
+
<div class="format-settings">
|
4133 |
+
<div class="format-setting type-text wide-desc">
|
4134 |
+
<div class="description">' . sprintf( $str_standard, '<strong>' . esc_html__( 'Standard', 'option-tree' ) . '</strong>', '<code>' . esc_html__( 'OptionTree->Documentation', 'option-tree' ) . '</code>' ) . '</div>
|
4135 |
+
<div class="format-setting-inner">
|
4136 |
+
' . $std_form_element . '
|
4137 |
+
</div>
|
4138 |
+
</div>
|
4139 |
+
</div>
|
4140 |
+
<div class="format-settings">
|
4141 |
+
<div class="format-setting type-text wide-desc">
|
4142 |
+
<div class="description">' . sprintf( $str_rows, '<strong>' . esc_html__( 'Rows', 'option-tree' ) . '</strong>' ) . '</div>
|
4143 |
+
<div class="format-setting-inner">
|
4144 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][rows]" value="' . ( isset( $setting['rows'] ) ? esc_attr( $setting['rows'] ) : '' ) . '" class="widefat option-tree-ui-input" />
|
4145 |
+
</div>
|
4146 |
+
</div>
|
4147 |
+
</div>
|
4148 |
+
<div class="format-settings">
|
4149 |
+
<div class="format-setting type-text wide-desc">
|
4150 |
+
<div class="description">' . sprintf( $str_post_type, '<strong>' . esc_html__( 'Post Type', 'option-tree' ) . '</strong>' ) . '</div>
|
4151 |
+
<div class="format-setting-inner">
|
4152 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][post_type]" value="' . ( isset( $setting['post_type'] ) ? esc_attr( $setting['post_type'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4153 |
+
</div>
|
4154 |
+
</div>
|
4155 |
+
</div>
|
4156 |
+
<div class="format-settings">
|
4157 |
+
<div class="format-setting type-text wide-desc">
|
4158 |
+
<div class="description">' . sprintf( $str_taxonomy, '<strong>' . esc_html__( 'Taxonomy', 'option-tree' ) . '</strong>' ) . '</div>
|
4159 |
+
<div class="format-setting-inner">
|
4160 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][taxonomy]" value="' . ( isset( $setting['taxonomy'] ) ? esc_attr( $setting['taxonomy'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4161 |
+
</div>
|
4162 |
+
</div>
|
4163 |
+
</div>
|
4164 |
+
<div class="format-settings">
|
4165 |
+
<div class="format-setting type-text wide-desc">
|
4166 |
+
<div class="description">' . sprintf( $str_min_max_step, '<strong>' . esc_html__( 'Min, Max, & Step', 'option-tree' ) . '</strong>', '<code>0,100,1</code>', '<code>0-100</code>', '<code>1</code>' ) . '</div>
|
4167 |
+
<div class="format-setting-inner">
|
4168 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][min_max_step]" value="' . ( isset( $setting['min_max_step'] ) ? esc_attr( $setting['min_max_step'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4169 |
+
</div>
|
4170 |
+
</div>
|
4171 |
+
</div>
|
4172 |
+
<div class="format-settings">
|
4173 |
+
<div class="format-setting type-text wide-desc">
|
4174 |
+
<div class="description">' . sprintf( $str_css_class, '<strong>' . esc_html__( 'CSS Class', 'option-tree' ) . '</strong>' ) . '</div>
|
4175 |
+
<div class="format-setting-inner">
|
4176 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][class]" value="' . ( isset( $setting['class'] ) ? esc_attr( $setting['class'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4177 |
+
</div>
|
4178 |
+
</div>
|
4179 |
+
</div>
|
4180 |
+
<div class="format-settings">
|
4181 |
+
<div class="format-setting type-text wide-desc">
|
4182 |
+
<div class="description">' . sprintf( $str_condition, '<strong>' . esc_html__( 'Condition', 'option-tree' ) . '</strong>', '<code>value</code>', '<code>field_id:is(value)</code>, <code>field_id:not(value)</code>, <code>field_id:contains(value)</code>, <code>field_id:less_than(value)</code>, <code>field_id:less_than_or_equal_to(value)</code>, <code>field_id:greater_than(value)</code>, or <code>field_id:greater_than_or_equal_to(value)</code>' ) . '</div>
|
4183 |
+
<div class="format-setting-inner">
|
4184 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][condition]" value="' . ( isset( $setting['condition'] ) ? esc_attr( $setting['condition'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4185 |
+
</div>
|
4186 |
+
</div>
|
4187 |
+
</div>
|
4188 |
+
<div class="format-settings">
|
4189 |
+
<div class="format-setting type-select wide-desc">
|
4190 |
+
<div class="description">' . sprintf( $str_operator, '<strong>' . esc_html__( 'Operator', 'option-tree' ) . '</strong>' ) . '</div>
|
4191 |
+
<div class="format-setting-inner">
|
4192 |
+
<select name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][operator]" value="' . esc_attr( $operator ) . '" class="option-tree-ui-select">
|
4193 |
+
<option value="and" ' . selected( $operator, 'and', false ) . '>' . esc_html__( 'and', 'option-tree' ) . '</option>
|
4194 |
+
<option value="or" ' . selected( $operator, 'or', false ) . '>' . esc_html__( 'or', 'option-tree' ) . '</option>
|
4195 |
+
</select>
|
4196 |
+
</div>
|
4197 |
+
</div>
|
4198 |
+
</div>
|
4199 |
+
</div>
|
4200 |
+
</div>
|
4201 |
+
' . ( ! $child ? '<input type="hidden" class="hidden-section" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][section]" value="' . ( isset( $setting['section'] ) ? esc_attr( $setting['section'] ) : '' ) . '" />' : '' );
|
4202 |
+
}
|
4203 |
+
}
|
4204 |
|
4205 |
+
if ( ! function_exists( 'ot_choices_view' ) ) {
|
4206 |
|
4207 |
+
/**
|
4208 |
+
* Helper function to display setting choices.
|
4209 |
+
*
|
4210 |
+
* This function is used in AJAX to add a new choice
|
4211 |
+
* and when choices have already been added and saved.
|
4212 |
+
*
|
4213 |
+
* @param string $name The form element name.
|
4214 |
+
* @param int $key The array key for the current element.
|
4215 |
+
* @param array $choice An array of values for the current choice.
|
4216 |
+
*
|
4217 |
+
* @return string
|
4218 |
+
*
|
4219 |
+
* @access public
|
4220 |
+
* @since 2.0
|
4221 |
+
*/
|
4222 |
+
function ot_choices_view( $name, $key, $choice = array() ) {
|
4223 |
+
|
4224 |
+
return '
|
4225 |
+
<div class="option-tree-setting">
|
4226 |
+
<div class="open">' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( absint( $key ) + 1 ) ) . '</div>
|
4227 |
+
<div class="button-section">
|
4228 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4229 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4230 |
+
</a>
|
4231 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4232 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4233 |
+
</a>
|
4234 |
+
</div>
|
4235 |
+
<div class="option-tree-setting-body">
|
4236 |
+
<div class="format-settings">
|
4237 |
+
<div class="format-setting-label">
|
4238 |
+
<h5>' . esc_html__( 'Label', 'option-tree' ) . '</h5>
|
4239 |
+
</div>
|
4240 |
+
<div class="format-setting type-text wide-desc">
|
4241 |
+
<div class="format-setting-inner">
|
4242 |
+
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][label]" value="' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4243 |
+
</div>
|
4244 |
+
</div>
|
4245 |
+
</div>
|
4246 |
+
<div class="format-settings">
|
4247 |
+
<div class="format-setting-label">
|
4248 |
+
<h5>' . esc_html__( 'Value', 'option-tree' ) . '</h5>
|
4249 |
+
</div>
|
4250 |
+
<div class="format-setting type-text wide-desc">
|
4251 |
+
<div class="format-setting-inner">
|
4252 |
+
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][value]" value="' . ( isset( $choice['value'] ) ? esc_attr( $choice['value'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4253 |
+
</div>
|
4254 |
+
</div>
|
4255 |
+
</div>
|
4256 |
+
<div class="format-settings">
|
4257 |
+
<div class="format-setting-label">
|
4258 |
+
<h5>' . esc_html__( 'Image Source (Radio Image only)', 'option-tree' ) . '</h5>
|
4259 |
+
</div>
|
4260 |
+
<div class="format-setting type-text wide-desc">
|
4261 |
+
<div class="format-setting-inner">
|
4262 |
+
<input type="text" name="' . esc_attr( $name ) . '[choices][' . esc_attr( $key ) . '][src]" value="' . ( isset( $choice['src'] ) ? esc_attr( $choice['src'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4263 |
+
</div>
|
4264 |
+
</div>
|
4265 |
+
</div>
|
4266 |
+
</div>
|
4267 |
+
</div>';
|
4268 |
+
|
4269 |
+
}
|
4270 |
+
}
|
4271 |
|
4272 |
+
if ( ! function_exists( 'ot_contextual_help_view' ) ) {
|
|
|
|
|
|
|
4273 |
|
4274 |
+
/**
|
4275 |
+
* Helper function to display sections.
|
4276 |
+
*
|
4277 |
+
* This function is used in AJAX to add a new section
|
4278 |
+
* and when section have already been added and saved.
|
4279 |
+
*
|
4280 |
+
* @param string $name The name/ID of the help page.
|
4281 |
+
* @param int $key The array key for the current element.
|
4282 |
+
* @param array $content An array of values for the current section.
|
4283 |
+
*
|
4284 |
+
* @return string
|
4285 |
+
*
|
4286 |
+
* @access public
|
4287 |
+
* @since 2.0
|
4288 |
+
*/
|
4289 |
+
function ot_contextual_help_view( $name, $key, $content = array() ) {
|
4290 |
+
|
4291 |
+
/* translators: %s: Title emphasized */
|
4292 |
+
$str_title = esc_html__( '%s: Displayed as a contextual help menu item on the Theme Options page.', 'option-tree' );
|
4293 |
+
|
4294 |
+
/* translators: %s: ID emphasized */
|
4295 |
+
$str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' );
|
4296 |
+
|
4297 |
+
/* translators: %s: Content emphasized */
|
4298 |
+
$str_content = esc_html__( '%s: Enter the HTML content about this contextual help item displayed on the Theme Option page for end users to read.', 'option-tree' );
|
4299 |
+
|
4300 |
+
return '
|
4301 |
+
<div class="option-tree-setting">
|
4302 |
+
<div class="open">' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( absint( $key ) + 1 ) ) . '</div>
|
4303 |
+
<div class="button-section">
|
4304 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4305 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4306 |
+
</a>
|
4307 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4308 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4309 |
+
</a>
|
4310 |
+
</div>
|
4311 |
+
<div class="option-tree-setting-body">
|
4312 |
+
<div class="format-settings">
|
4313 |
+
<div class="format-setting type-text no-desc">
|
4314 |
+
<div class="description">' . sprintf( $str_title, '<strong>' . esc_html__( 'Title', 'option-tree' ) . '</strong>' ) . '</div>
|
4315 |
+
<div class="format-setting-inner">
|
4316 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][title]" value="' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : '' ) . '" class="widefat option-tree-ui-input option-tree-setting-title" autocomplete="off" />
|
4317 |
+
</div>
|
4318 |
+
</div>
|
4319 |
+
</div>
|
4320 |
+
<div class="format-settings">
|
4321 |
+
<div class="format-setting type-text no-desc">
|
4322 |
+
<div class="description">' . sprintf( $str_id, '<strong>' . esc_html__( 'ID', 'option-tree' ) . '</strong>' ) . '</div>
|
4323 |
+
<div class="format-setting-inner">
|
4324 |
+
<input type="text" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][id]" value="' . ( isset( $content['id'] ) ? esc_attr( $content['id'] ) : '' ) . '" class="widefat option-tree-ui-input" autocomplete="off" />
|
4325 |
+
</div>
|
4326 |
+
</div>
|
4327 |
+
</div>
|
4328 |
+
<div class="format-settings">
|
4329 |
+
<div class="format-setting type-textarea no-desc">
|
4330 |
+
<div class="description">' . sprintf( $str_content, '<strong>' . esc_html__( 'Content', 'option-tree' ) . '</strong>' ) . '</div>
|
4331 |
+
<div class="format-setting-inner">
|
4332 |
+
<textarea class="textarea" rows="15" cols="40" name="' . esc_attr( $name ) . '[' . esc_attr( $key ) . '][content]">' . ( isset( $content['content'] ) ? esc_textarea( $content['content'] ) : '' ) . '</textarea>
|
4333 |
+
</div>
|
4334 |
+
</div>
|
4335 |
+
</div>
|
4336 |
+
</div>
|
4337 |
+
</div>';
|
4338 |
+
|
4339 |
+
}
|
4340 |
+
}
|
4341 |
|
4342 |
+
if ( ! function_exists( 'ot_layout_view' ) ) {
|
4343 |
|
4344 |
+
/**
|
4345 |
+
* Helper function to display sections.
|
4346 |
+
*
|
4347 |
+
* @param string $key Layout ID.
|
4348 |
+
* @param string $data Layout encoded value.
|
4349 |
+
* @param string $active_layout Active layout ID.
|
4350 |
+
*
|
4351 |
+
* @return string
|
4352 |
+
*
|
4353 |
+
* @access public
|
4354 |
+
* @since 2.0
|
4355 |
+
*/
|
4356 |
+
function ot_layout_view( $key, $data = '', $active_layout = '' ) {
|
4357 |
+
|
4358 |
+
return '
|
4359 |
+
<div class="option-tree-setting">
|
4360 |
+
<div class="open">' . ( isset( $key ) ? esc_attr( $key ) : esc_html__( 'Layout', 'option-tree' ) ) . '</div>
|
4361 |
+
<div class="button-section">
|
4362 |
+
<a href="javascript:void(0);" class="option-tree-layout-activate option-tree-ui-button button left-item' . ( $active_layout === $key ? ' active' : '' ) . '" title="' . esc_html__( 'Activate', 'option-tree' ) . '">
|
4363 |
+
<span class="icon ot-icon-square-o"></span>' . esc_html__( 'Activate', 'option-tree' ) . '
|
4364 |
+
</a>
|
4365 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4366 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4367 |
+
</a>
|
4368 |
+
</div>
|
4369 |
+
<input type="hidden" name="' . esc_attr( ot_layouts_id() ) . '[' . esc_attr( $key ) . ']" value="' . esc_attr( $data ) . '" />
|
4370 |
+
</div>';
|
4371 |
+
}
|
4372 |
+
}
|
4373 |
|
4374 |
+
if ( ! function_exists( 'ot_list_item_view' ) ) {
|
4375 |
|
4376 |
+
/**
|
4377 |
+
* Helper function to display list items.
|
4378 |
+
*
|
4379 |
+
* This function is used in AJAX to add a new list items
|
4380 |
+
* and when they have already been added and saved.
|
4381 |
+
*
|
4382 |
+
* @param string $name The form field name.
|
4383 |
+
* @param int $key The array key for the current element.
|
4384 |
+
* @param array $list_item An array of values for the current list item.
|
4385 |
+
* @param int $post_id The post ID.
|
4386 |
+
* @param string $get_option The option page ID.
|
4387 |
+
* @param array $settings The settings.
|
4388 |
+
* @param string $type The list type.
|
4389 |
+
*
|
4390 |
+
* @access public
|
4391 |
+
* @since 2.0
|
4392 |
+
*/
|
4393 |
+
function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) {
|
4394 |
+
|
4395 |
+
// Required title setting.
|
4396 |
+
$required_setting = array(
|
4397 |
+
array(
|
4398 |
+
'id' => 'title',
|
4399 |
+
'label' => __( 'Title', 'option-tree' ),
|
4400 |
+
'desc' => '',
|
4401 |
+
'std' => '',
|
4402 |
+
'type' => 'text',
|
4403 |
+
'rows' => '',
|
4404 |
+
'class' => 'option-tree-setting-title',
|
4405 |
+
'post_type' => '',
|
4406 |
+
'choices' => array(),
|
4407 |
+
),
|
4408 |
+
);
|
4409 |
+
|
4410 |
+
// Load the old filterable slider settings.
|
4411 |
+
if ( 'slider' === $type ) {
|
4412 |
+
$settings = ot_slider_settings( $name );
|
4413 |
+
}
|
4414 |
+
|
4415 |
+
// If no settings array load the filterable list item settings.
|
4416 |
+
if ( empty( $settings ) ) {
|
4417 |
+
$settings = ot_list_item_settings( $name );
|
4418 |
+
}
|
4419 |
+
|
4420 |
+
// Merge the two settings array.
|
4421 |
+
$settings = array_merge( $required_setting, $settings );
|
4422 |
+
|
4423 |
+
echo '
|
4424 |
+
<div class="option-tree-setting">
|
4425 |
+
<div class="open">' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '</div>
|
4426 |
+
<div class="button-section">
|
4427 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4428 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4429 |
+
</a>
|
4430 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4431 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4432 |
+
</a>
|
4433 |
+
</div>
|
4434 |
+
<div class="option-tree-setting-body">
|
4435 |
+
';
|
4436 |
+
|
4437 |
+
foreach ( $settings as $field ) {
|
4438 |
+
|
4439 |
+
// Set field value.
|
4440 |
+
$field_value = isset( $list_item[ $field['id'] ] ) ? $list_item[ $field['id'] ] : '';
|
4441 |
+
|
4442 |
+
// Set default to standard value.
|
4443 |
+
if ( isset( $field['std'] ) ) {
|
4444 |
+
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4445 |
+
}
|
4446 |
+
|
4447 |
+
// filter the title label and description.
|
4448 |
+
if ( 'title' === $field['id'] ) {
|
4449 |
+
|
4450 |
+
// filter the label.
|
4451 |
+
$field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name );
|
4452 |
+
|
4453 |
+
// filter the description.
|
4454 |
+
$field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name );
|
4455 |
+
}
|
4456 |
+
|
4457 |
+
// Make life easier.
|
4458 |
+
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4459 |
+
|
4460 |
+
// Build the arguments array.
|
4461 |
+
$_args = array(
|
4462 |
+
'type' => $field['type'],
|
4463 |
+
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4464 |
+
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4465 |
+
'field_value' => $field_value,
|
4466 |
+
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4467 |
+
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4468 |
+
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4469 |
+
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4470 |
+
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4471 |
+
'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4472 |
+
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4473 |
+
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4474 |
+
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4475 |
+
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4476 |
+
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4477 |
+
'post_id' => $post_id,
|
4478 |
+
'get_option' => $get_option,
|
4479 |
+
);
|
4480 |
+
|
4481 |
+
$conditions = '';
|
4482 |
+
|
4483 |
+
// Setup the conditions.
|
4484 |
+
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4485 |
+
|
4486 |
+
/* doing magic on the conditions so they work in a list item */
|
4487 |
+
$conditionals = explode( ',', $field['condition'] );
|
4488 |
+
foreach ( $conditionals as $condition ) {
|
4489 |
+
$parts = explode( ':', $condition );
|
4490 |
+
if ( isset( $parts[0] ) ) {
|
4491 |
+
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4492 |
+
}
|
4493 |
+
}
|
4494 |
+
|
4495 |
+
$conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"';
|
4496 |
+
$conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : '';
|
4497 |
+
}
|
4498 |
+
|
4499 |
+
// Build the setting CSS class.
|
4500 |
+
if ( ! empty( $_args['field_class'] ) ) {
|
4501 |
+
$classes = explode( ' ', $_args['field_class'] );
|
4502 |
+
|
4503 |
+
foreach ( $classes as $_key => $value ) {
|
4504 |
+
$classes[ $_key ] = $value . '-wrap';
|
4505 |
+
}
|
4506 |
+
|
4507 |
+
$class = 'format-settings ' . implode( ' ', $classes );
|
4508 |
+
} else {
|
4509 |
+
$class = 'format-settings';
|
4510 |
+
}
|
4511 |
+
|
4512 |
+
// Option label.
|
4513 |
+
echo '<div id="setting_' . esc_attr( $_args['field_id'] ) . '" class="' . esc_attr( $class ) . '"' . $conditions . '>'; // phpcs:ignore
|
4514 |
+
|
4515 |
+
// Don't show title with textblocks.
|
4516 |
+
if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) {
|
4517 |
+
echo '<div class="format-setting-label">';
|
4518 |
+
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4519 |
+
echo '</div>';
|
4520 |
+
}
|
4521 |
+
|
4522 |
+
// Only allow simple textarea inside a list-item due to known DOM issues with wp_editor().
|
4523 |
+
if ( false === apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) && 'textarea' === $_args['type'] ) {
|
4524 |
+
$_args['type'] = 'textarea-simple';
|
4525 |
+
}
|
4526 |
+
|
4527 |
+
// Option body, list-item is not allowed inside another list-item.
|
4528 |
+
if ( 'list-item' !== $_args['type'] && 'slider' !== $_args['type'] ) {
|
4529 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
4530 |
+
}
|
4531 |
+
|
4532 |
+
echo '</div>';
|
4533 |
+
}
|
4534 |
+
|
4535 |
+
echo '</div>';
|
4536 |
+
|
4537 |
+
echo '</div>';
|
4538 |
+
}
|
4539 |
+
}
|
4540 |
|
4541 |
+
if ( ! function_exists( 'ot_social_links_view' ) ) {
|
4542 |
|
4543 |
+
/**
|
4544 |
+
* Helper function to display social links.
|
4545 |
+
*
|
4546 |
+
* This function is used in AJAX to add a new list items
|
4547 |
+
* and when they have already been added and saved.
|
4548 |
+
*
|
4549 |
+
* @param string $name The form field name.
|
4550 |
+
* @param int $key The array key for the current element.
|
4551 |
+
* @param array $list_item An array of values for the current list item.
|
4552 |
+
* @param int $post_id The post ID.
|
4553 |
+
* @param string $get_option The option page ID.
|
4554 |
+
* @param array $settings The settings.
|
4555 |
+
*
|
4556 |
+
* @access public
|
4557 |
+
* @since 2.4.0
|
4558 |
+
*/
|
4559 |
+
function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array() ) {
|
4560 |
+
|
4561 |
+
// If no settings array load the filterable social links settings.
|
4562 |
+
if ( empty( $settings ) ) {
|
4563 |
+
$settings = ot_social_links_settings( $name );
|
4564 |
+
}
|
4565 |
+
|
4566 |
+
echo '
|
4567 |
+
<div class="option-tree-setting">
|
4568 |
+
<div class="open">' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '</div>
|
4569 |
+
<div class="button-section">
|
4570 |
+
<a href="javascript:void(0);" class="option-tree-setting-edit option-tree-ui-button button left-item" title="' . esc_html__( 'Edit', 'option-tree' ) . '">
|
4571 |
+
<span class="icon ot-icon-pencil"></span>' . esc_html__( 'Edit', 'option-tree' ) . '
|
4572 |
+
</a>
|
4573 |
+
<a href="javascript:void(0);" class="option-tree-setting-remove option-tree-ui-button button button-secondary light right-item" title="' . esc_html__( 'Delete', 'option-tree' ) . '">
|
4574 |
+
<span class="icon ot-icon-trash-o"></span>' . esc_html__( 'Delete', 'option-tree' ) . '
|
4575 |
+
</a>
|
4576 |
+
</div>
|
4577 |
+
<div class="option-tree-setting-body">
|
4578 |
+
';
|
4579 |
+
|
4580 |
+
foreach ( $settings as $field ) {
|
4581 |
+
|
4582 |
+
// Set field value.
|
4583 |
+
$field_value = isset( $list_item[ $field['id'] ] ) ? $list_item[ $field['id'] ] : '';
|
4584 |
+
|
4585 |
+
// Set default to standard value.
|
4586 |
+
if ( isset( $field['std'] ) ) {
|
4587 |
+
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
4588 |
+
}
|
4589 |
+
|
4590 |
+
// Make life easier.
|
4591 |
+
$_field_name = $get_option ? $get_option . '[' . $name . ']' : $name;
|
4592 |
+
|
4593 |
+
// Build the arguments array.
|
4594 |
+
$_args = array(
|
4595 |
+
'type' => $field['type'],
|
4596 |
+
'field_id' => $name . '_' . $field['id'] . '_' . $key,
|
4597 |
+
'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']',
|
4598 |
+
'field_value' => $field_value,
|
4599 |
+
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
4600 |
+
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
4601 |
+
'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10,
|
4602 |
+
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
4603 |
+
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
4604 |
+
'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
4605 |
+
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
4606 |
+
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
4607 |
+
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
4608 |
+
'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(),
|
4609 |
+
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
4610 |
+
'post_id' => $post_id,
|
4611 |
+
'get_option' => $get_option,
|
4612 |
+
);
|
4613 |
+
|
4614 |
+
$conditions = '';
|
4615 |
+
|
4616 |
+
// Setup the conditions.
|
4617 |
+
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
4618 |
+
|
4619 |
+
// Doing magic on the conditions so they work in a list item.
|
4620 |
+
$conditionals = explode( ',', $field['condition'] );
|
4621 |
+
foreach ( $conditionals as $condition ) {
|
4622 |
+
$parts = explode( ':', $condition );
|
4623 |
+
if ( isset( $parts[0] ) ) {
|
4624 |
+
$field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] );
|
4625 |
+
}
|
4626 |
+
}
|
4627 |
+
|
4628 |
+
$conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"';
|
4629 |
+
$conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : '';
|
4630 |
+
}
|
4631 |
+
|
4632 |
+
// Option label.
|
4633 |
+
echo '<div id="setting_' . esc_attr( $_args['field_id'] ) . '" class="format-settings"' . $conditions . '>'; // phpcs:ignore
|
4634 |
+
|
4635 |
+
// Don't show title with textblocks.
|
4636 |
+
if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) {
|
4637 |
+
echo '<div class="format-setting-label">';
|
4638 |
+
echo '<h3 class="label">' . esc_attr( $field['label'] ) . '</h3>';
|
4639 |
+
echo '</div>';
|
4640 |
+
}
|
4641 |
+
|
4642 |
+
// Only allow simple textarea inside a list-item due to known DOM issues with wp_editor().
|
4643 |
+
if ( 'textarea' === $_args['type'] ) {
|
4644 |
+
$_args['type'] = 'textarea-simple';
|
4645 |
+
}
|
4646 |
+
|
4647 |
+
// Option body, list-item is not allowed inside another list-item.
|
4648 |
+
if ( 'list-item' !== $_args['type'] && 'slider' !== $_args['type'] && 'social-links' !== $_args['type'] ) {
|
4649 |
+
echo ot_display_by_type( $_args ); // phpcs:ignore
|
4650 |
+
}
|
4651 |
+
|
4652 |
+
echo '</div>';
|
4653 |
+
}
|
4654 |
+
|
4655 |
+
echo '</div>';
|
4656 |
+
|
4657 |
+
echo '</div>';
|
4658 |
+
}
|
4659 |
}
|
4660 |
|
4661 |
+
if ( ! function_exists( 'ot_theme_options_layouts_form' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4662 |
|
4663 |
+
/**
|
4664 |
+
* Helper function to display Theme Options layouts form.
|
4665 |
+
*
|
4666 |
+
* @access public
|
4667 |
+
* @since 2.0
|
4668 |
+
*/
|
4669 |
+
function ot_theme_options_layouts_form() {
|
4670 |
|
4671 |
+
echo '<form method="post" id="option-tree-options-layouts-form">';
|
|
|
4672 |
|
4673 |
+
// Form nonce.
|
4674 |
+
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
4675 |
|
4676 |
+
// Get the saved layouts.
|
4677 |
+
$layouts = get_option( ot_layouts_id() );
|
|
|
4678 |
|
4679 |
+
// Set active layout.
|
4680 |
+
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
|
|
4681 |
|
4682 |
+
if ( is_array( $layouts ) && 1 < count( $layouts ) ) {
|
|
|
4683 |
|
4684 |
+
$active_layout = $layouts['active_layout'];
|
|
|
4685 |
|
4686 |
+
echo '<input type="hidden" id="the_current_layout" value="' . esc_attr( $active_layout ) . '" />';
|
|
|
4687 |
|
4688 |
+
echo '<div class="option-tree-active-layout">';
|
|
|
4689 |
|
4690 |
+
echo '<select name="' . esc_attr( ot_layouts_id() ) . '[active_layout]" class="option-tree-ui-select">';
|
|
|
4691 |
|
4692 |
+
$hidden = '';
|
4693 |
|
4694 |
+
foreach ( $layouts as $key => $data ) {
|
|
|
4695 |
|
4696 |
+
if ( 'active_layout' === $key ) {
|
4697 |
+
continue;
|
4698 |
+
}
|
4699 |
|
4700 |
+
echo '<option ' . selected( $key, $active_layout, false ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $key ) . '</option>';
|
4701 |
+
$hidden_safe .= '<input type="hidden" name="' . esc_attr( ot_layouts_id() ) . '[' . esc_attr( $key ) . ']" value="' . esc_attr( isset( $data ) ? $data : '' ) . '" />';
|
4702 |
+
}
|
4703 |
|
4704 |
+
echo '</select>';
|
4705 |
|
4706 |
+
echo '</div>';
|
|
|
4707 |
|
4708 |
+
echo $hidden_safe; // phpcs:ignore
|
4709 |
+
}
|
4710 |
|
4711 |
+
/* new layout wrapper */
|
4712 |
+
echo '<div class="option-tree-save-layout' . ( ! empty( $active_layout ) ? ' active-layout' : '' ) . '">';
|
4713 |
|
4714 |
+
/* add new layout */
|
4715 |
+
echo '<input type="text" name="' . esc_attr( ot_layouts_id() ) . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
4716 |
|
4717 |
+
echo '<button type="submit" class="option-tree-ui-button button button-primary save-layout" title="' . esc_html__( 'New Layout', 'option-tree' ) . '">' . esc_html__( 'New Layout', 'option-tree' ) . '</button>';
|
|
|
4718 |
|
4719 |
+
echo '</div>';
|
4720 |
+
|
4721 |
+
echo '</form>';
|
4722 |
+
}
|
4723 |
+
}
|
4724 |
+
|
4725 |
+
if ( ! function_exists( 'ot_sanitize_option_id' ) ) {
|
4726 |
|
4727 |
+
/**
|
4728 |
+
* Helper function to sanitize the option ID's.
|
4729 |
+
*
|
4730 |
+
* @param string $input The string to sanitize.
|
4731 |
+
* @return string
|
4732 |
+
*
|
4733 |
+
* @access public
|
4734 |
+
* @since 2.0
|
4735 |
+
*/
|
4736 |
+
function ot_sanitize_option_id( $input ) {
|
4737 |
+
return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) );
|
4738 |
+
}
|
4739 |
+
}
|
4740 |
|
4741 |
+
if ( ! function_exists( 'ot_sanitize_layout_id' ) ) {
|
|
|
4742 |
|
4743 |
+
/**
|
4744 |
+
* Helper function to sanitize the layout ID's.
|
4745 |
+
*
|
4746 |
+
* @param string $input The string to sanitize.
|
4747 |
+
* @return string
|
4748 |
+
*
|
4749 |
+
* @access public
|
4750 |
+
* @since 2.0
|
4751 |
+
*/
|
4752 |
+
function ot_sanitize_layout_id( $input ) {
|
4753 |
+
return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) );
|
4754 |
+
}
|
4755 |
+
}
|
4756 |
|
4757 |
+
if ( ! function_exists( 'ot_convert_array_to_string' ) ) {
|
4758 |
|
4759 |
+
/**
|
4760 |
+
* Convert choices array to string.
|
4761 |
+
*
|
4762 |
+
* @param array $input The array to convert to a string.
|
4763 |
+
*
|
4764 |
+
* @return bool|string
|
4765 |
+
*
|
4766 |
+
* @access public
|
4767 |
+
* @since 2.0
|
4768 |
+
*/
|
4769 |
+
function ot_convert_array_to_string( $input ) {
|
4770 |
+
|
4771 |
+
if ( is_array( $input ) ) {
|
4772 |
+
|
4773 |
+
foreach ( $input as $k => $choice ) {
|
4774 |
+
$choices[ $k ] = $choice['value'] . '|' . $choice['label'];
|
4775 |
+
|
4776 |
+
if ( isset( $choice['src'] ) ) {
|
4777 |
+
$choices[ $k ] .= '|' . $choice['src'];
|
4778 |
+
}
|
4779 |
+
}
|
4780 |
+
|
4781 |
+
return implode( ',', $choices );
|
4782 |
+
}
|
4783 |
+
|
4784 |
+
return false;
|
4785 |
+
}
|
4786 |
+
}
|
4787 |
|
4788 |
+
if ( ! function_exists( 'ot_convert_string_to_array' ) ) {
|
4789 |
|
4790 |
+
/**
|
4791 |
+
* Convert choices string to array.
|
4792 |
+
*
|
4793 |
+
* @param string $input The string to convert to an array.
|
4794 |
+
*
|
4795 |
+
* @return bool|array
|
4796 |
+
*
|
4797 |
+
* @access public
|
4798 |
+
* @since 2.0
|
4799 |
+
*/
|
4800 |
+
function ot_convert_string_to_array( $input ) {
|
4801 |
+
|
4802 |
+
if ( '' !== $input ) {
|
4803 |
+
|
4804 |
+
// Empty choices array.
|
4805 |
+
$choices = array();
|
4806 |
+
|
4807 |
+
// Exlode the string into an array.
|
4808 |
+
foreach ( explode( ',', $input ) as $k => $choice ) {
|
4809 |
+
|
4810 |
+
// If ":" is splitting the string go deeper.
|
4811 |
+
if ( preg_match( '/\|/', $choice ) ) {
|
4812 |
+
$split = explode( '|', $choice );
|
4813 |
+
|
4814 |
+
if ( 2 > count( $split ) ) {
|
4815 |
+
continue;
|
4816 |
+
}
|
4817 |
+
|
4818 |
+
$choices[ $k ]['value'] = trim( $split[0] );
|
4819 |
+
$choices[ $k ]['label'] = trim( $split[1] );
|
4820 |
+
|
4821 |
+
// If radio image there are three values.
|
4822 |
+
if ( isset( $split[2] ) ) {
|
4823 |
+
$choices[ $k ]['src'] = trim( $split[2] );
|
4824 |
+
}
|
4825 |
+
} else {
|
4826 |
+
$choices[ $k ]['value'] = trim( $choice );
|
4827 |
+
$choices[ $k ]['label'] = trim( $choice );
|
4828 |
+
}
|
4829 |
+
}
|
4830 |
+
|
4831 |
+
// Return a formatted choices array.
|
4832 |
+
return $choices;
|
4833 |
+
}
|
4834 |
+
|
4835 |
+
return false;
|
4836 |
+
}
|
4837 |
+
}
|
4838 |
|
4839 |
+
if ( ! function_exists( 'ot_strpos_array' ) ) {
|
4840 |
|
4841 |
+
/**
|
4842 |
+
* Helper function - strpos() in array recursively.
|
4843 |
+
*
|
4844 |
+
* @param string $haystack The string to search in.
|
4845 |
+
* @param array $needles Keys to search for.
|
4846 |
+
* @return bool
|
4847 |
+
*
|
4848 |
+
* @access public
|
4849 |
+
* @since 2.0
|
4850 |
+
*/
|
4851 |
+
function ot_strpos_array( $haystack, $needles = array() ) {
|
4852 |
+
|
4853 |
+
foreach ( $needles as $needle ) {
|
4854 |
+
if ( false !== strpos( $haystack, $needle ) ) {
|
4855 |
+
return true;
|
4856 |
+
}
|
4857 |
+
}
|
4858 |
+
|
4859 |
+
return false;
|
4860 |
+
}
|
4861 |
+
}
|
4862 |
|
4863 |
+
if ( ! function_exists( 'ot_array_keys_exists' ) ) {
|
4864 |
|
4865 |
+
/**
|
4866 |
+
* Helper function - array_key_exists() recursively.
|
4867 |
+
*
|
4868 |
+
* @param array $haystack The array to search in.
|
4869 |
+
* @param array $needles Keys to search for.
|
4870 |
+
* @return bool
|
4871 |
+
*
|
4872 |
+
* @access public
|
4873 |
+
* @since 2.0
|
4874 |
+
*/
|
4875 |
+
function ot_array_keys_exists( $haystack, $needles = array() ) {
|
4876 |
+
|
4877 |
+
foreach ( $needles as $k ) {
|
4878 |
+
if ( isset( $haystack[ $k ] ) ) {
|
4879 |
+
return true;
|
4880 |
+
}
|
4881 |
+
}
|
4882 |
+
|
4883 |
+
return false;
|
4884 |
+
}
|
4885 |
+
}
|
4886 |
|
4887 |
+
if ( ! function_exists( 'ot_stripslashes' ) ) {
|
|
|
|
|
|
|
4888 |
|
4889 |
+
/**
|
4890 |
+
* Custom stripslashes from single value or array.
|
4891 |
+
*
|
4892 |
+
* @param mixed $input The string or array to stripslashes from.
|
4893 |
+
* @return mixed
|
4894 |
+
*
|
4895 |
+
* @access public
|
4896 |
+
* @since 2.0
|
4897 |
+
*/
|
4898 |
+
function ot_stripslashes( $input ) {
|
4899 |
+
|
4900 |
+
if ( is_array( $input ) ) {
|
4901 |
+
|
4902 |
+
foreach ( $input as &$val ) {
|
4903 |
+
|
4904 |
+
if ( is_array( $val ) ) {
|
4905 |
+
$val = ot_stripslashes( $val );
|
4906 |
+
} else {
|
4907 |
+
$val = stripslashes( trim( $val ) );
|
4908 |
+
}
|
4909 |
+
}
|
4910 |
+
} else {
|
4911 |
+
$input = stripslashes( trim( $input ) );
|
4912 |
+
}
|
4913 |
+
|
4914 |
+
return $input;
|
4915 |
+
}
|
4916 |
+
}
|
4917 |
|
4918 |
+
if ( ! function_exists( 'ot_reverse_wpautop' ) ) {
|
|
|
|
|
|
|
4919 |
|
4920 |
+
/**
|
4921 |
+
* Reverse wpautop.
|
4922 |
+
*
|
4923 |
+
* @param string $string The string to be filtered.
|
4924 |
+
* @return string
|
4925 |
+
*
|
4926 |
+
* @access public
|
4927 |
+
* @since 2.0.9
|
4928 |
+
*/
|
4929 |
+
function ot_reverse_wpautop( $string = '' ) {
|
4930 |
+
|
4931 |
+
// Return if string is empty.
|
4932 |
+
if ( '' === trim( $string ) ) {
|
4933 |
+
return '';
|
4934 |
+
}
|
4935 |
+
|
4936 |
+
// Remove all new lines & <p> tags.
|
4937 |
+
$string = str_replace( array( "\n", '<p>' ), '', $string );
|
4938 |
+
|
4939 |
+
// Replace <br /> with \r.
|
4940 |
+
$string = str_replace( array( '<br />', '<br>', '<br/>' ), "\r", $string );
|
4941 |
+
|
4942 |
+
// Replace </p> with \r\n.
|
4943 |
+
$string = str_replace( '</p>', "\r\n", $string );
|
4944 |
+
|
4945 |
+
// Return clean string.
|
4946 |
+
return trim( $string );
|
4947 |
+
}
|
4948 |
+
}
|
4949 |
|
4950 |
+
if ( ! function_exists( 'ot_range' ) ) {
|
4951 |
+
|
4952 |
+
/**
|
4953 |
+
* Returns an array of elements from start to limit, inclusive.
|
4954 |
+
*
|
4955 |
+
* Occasionally zero will be some impossibly large number to
|
4956 |
+
* the "E" power when creating a range from negative to positive.
|
4957 |
+
* This function attempts to fix that by setting that number back to "0".
|
4958 |
+
*
|
4959 |
+
* @param string $start First value of the sequence.
|
4960 |
+
* @param string $limit The sequence is ended upon reaching the limit value.
|
4961 |
+
* @param int $step If a step value is given, it will be used as the increment
|
4962 |
+
* between elements in the sequence. step should be given as a
|
4963 |
+
* positive number. If not specified, step will default to 1.
|
4964 |
+
*
|
4965 |
+
* @return array
|
4966 |
+
*
|
4967 |
+
* @access public
|
4968 |
+
* @since 2.0.12
|
4969 |
+
*/
|
4970 |
+
function ot_range( $start, $limit, $step = 1 ) {
|
4971 |
+
|
4972 |
+
if ( $step < 0 ) {
|
4973 |
+
$step = 1;
|
4974 |
+
}
|
4975 |
+
|
4976 |
+
$range = range( $start, $limit, $step );
|
4977 |
+
|
4978 |
+
foreach ( $range as $k => $v ) {
|
4979 |
+
if ( strpos( $v, 'E' ) ) {
|
4980 |
+
$range[ $k ] = 0;
|
4981 |
+
}
|
4982 |
+
}
|
4983 |
+
|
4984 |
+
return $range;
|
4985 |
+
}
|
4986 |
+
}
|
4987 |
|
4988 |
+
if ( ! function_exists( 'ot_encode' ) ) {
|
4989 |
+
|
4990 |
+
/**
|
4991 |
+
* Helper function to return encoded strings.
|
4992 |
+
*
|
4993 |
+
* @param array $value The array to encode.
|
4994 |
+
*
|
4995 |
+
* @return string|bool
|
4996 |
+
*
|
4997 |
+
* @access public
|
4998 |
+
* @since 2.0.13
|
4999 |
+
* @updated 2.7.0
|
5000 |
+
*/
|
5001 |
+
function ot_encode( $value ) {
|
5002 |
+
if ( is_array( $value ) ) {
|
5003 |
+
return base64_encode( maybe_serialize( $value ) ); // phpcs:ignore
|
5004 |
+
}
|
5005 |
+
|
5006 |
+
return false;
|
5007 |
+
}
|
5008 |
+
}
|
5009 |
|
5010 |
+
if ( ! function_exists( 'ot_decode' ) ) {
|
5011 |
|
5012 |
+
/**
|
5013 |
+
* Helper function to return decoded arrays.
|
5014 |
+
*
|
5015 |
+
* @param string $value Encoded serialized array.
|
5016 |
+
*
|
5017 |
+
* @return array
|
5018 |
+
*
|
5019 |
+
* @access public
|
5020 |
+
* @since 2.0.13
|
5021 |
+
*/
|
5022 |
+
function ot_decode( $value ) {
|
5023 |
|
5024 |
+
$fallback = array();
|
5025 |
+
$decoded = base64_decode( $value ); // phpcs:ignore
|
5026 |
|
5027 |
+
// Search for an array.
|
5028 |
+
preg_match( '/a:\d+:{.*?}/', $decoded, $array_matches, PREG_OFFSET_CAPTURE, 0 );
|
5029 |
|
5030 |
+
// Search for an object.
|
5031 |
+
preg_match( '/O:\d+:"[a-z0-9_]+":\d+:{.*?}/i', $decoded, $obj_matches, PREG_OFFSET_CAPTURE, 0 );
|
5032 |
|
5033 |
+
// Prevent object injection or non arrays.
|
5034 |
+
if ( $obj_matches || ! $array_matches ) {
|
5035 |
+
return $fallback;
|
5036 |
+
}
|
5037 |
|
5038 |
+
// Convert the options to an array.
|
5039 |
+
$decoded = maybe_unserialize( $decoded );
|
5040 |
|
5041 |
+
if ( is_array( $decoded ) ) {
|
5042 |
+
return $decoded;
|
5043 |
+
}
|
5044 |
|
5045 |
+
return $fallback;
|
5046 |
+
}
|
5047 |
+
}
|
5048 |
|
5049 |
+
if ( ! function_exists( 'ot_filter_std_value' ) ) {
|
5050 |
+
|
5051 |
+
/**
|
5052 |
+
* Helper function to filter standard option values.
|
5053 |
+
*
|
5054 |
+
* @param mixed $value Saved string or array value.
|
5055 |
+
* @param mixed $std Standard string or array value.
|
5056 |
+
*
|
5057 |
+
* @return mixed String or array.
|
5058 |
+
*
|
5059 |
+
* @access public
|
5060 |
+
* @since 2.0.15
|
5061 |
+
*/
|
5062 |
+
function ot_filter_std_value( $value = '', $std = '' ) {
|
5063 |
+
|
5064 |
+
if ( is_string( $std ) && ! empty( $std ) ) {
|
5065 |
+
|
5066 |
+
// Search for an array.
|
5067 |
+
preg_match( '/a:\d+:{.*?}/', $std, $array_matches, PREG_OFFSET_CAPTURE, 0 );
|
5068 |
+
|
5069 |
+
// Search for an object.
|
5070 |
+
preg_match( '/O:\d+:"[a-z0-9_]+":\d+:{.*?}/i', $std, $obj_matches, PREG_OFFSET_CAPTURE, 0 );
|
5071 |
+
|
5072 |
+
// Prevent object injection.
|
5073 |
+
if ( $array_matches && ! $obj_matches ) {
|
5074 |
+
$std = maybe_unserialize( $std );
|
5075 |
+
} elseif ( $obj_matches ) {
|
5076 |
+
$std = '';
|
5077 |
+
}
|
5078 |
+
}
|
5079 |
+
|
5080 |
+
if ( is_array( $value ) && is_array( $std ) ) {
|
5081 |
+
foreach ( $value as $k => $v ) {
|
5082 |
+
if ( '' === $value[ $k ] && isset( $std[ $k ] ) ) {
|
5083 |
+
$value[ $k ] = $std[ $k ];
|
5084 |
+
}
|
5085 |
+
}
|
5086 |
+
} elseif ( '' === $value && ! empty( $std ) ) {
|
5087 |
+
$value = $std;
|
5088 |
+
}
|
5089 |
+
|
5090 |
+
return $value;
|
5091 |
+
}
|
5092 |
+
}
|
5093 |
|
5094 |
+
if ( ! function_exists( 'ot_set_google_fonts' ) ) {
|
5095 |
+
|
5096 |
+
/**
|
5097 |
+
* Helper function to set the Google fonts array.
|
5098 |
+
*
|
5099 |
+
* @param string $id The option ID.
|
5100 |
+
* @param bool $value The option value.
|
5101 |
+
*
|
5102 |
+
* @access public
|
5103 |
+
* @since 2.5.0
|
5104 |
+
*/
|
5105 |
+
function ot_set_google_fonts( $id = '', $value = '' ) {
|
5106 |
+
|
5107 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
5108 |
+
|
5109 |
+
if ( is_array( $value ) && ! empty( $value ) ) {
|
5110 |
+
$ot_set_google_fonts[ $id ] = $value;
|
5111 |
+
} elseif ( isset( $ot_set_google_fonts[ $id ] ) ) {
|
5112 |
+
unset( $ot_set_google_fonts[ $id ] );
|
5113 |
+
}
|
5114 |
+
|
5115 |
+
set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
|
5116 |
+
}
|
5117 |
+
}
|
5118 |
|
5119 |
+
if ( ! function_exists( 'ot_update_google_fonts_after_save' ) ) {
|
5120 |
+
|
5121 |
+
/**
|
5122 |
+
* Helper function to remove unused options from the Google fonts array.
|
5123 |
+
*
|
5124 |
+
* @param array $options The array of saved options.
|
5125 |
+
*
|
5126 |
+
* @access public
|
5127 |
+
* @since 2.5.0
|
5128 |
+
*/
|
5129 |
+
function ot_update_google_fonts_after_save( $options = array() ) {
|
5130 |
+
|
5131 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
5132 |
+
|
5133 |
+
foreach ( $ot_set_google_fonts as $key => $set ) {
|
5134 |
+
if ( ! isset( $options[ $key ] ) ) {
|
5135 |
+
unset( $ot_set_google_fonts[ $key ] );
|
5136 |
+
}
|
5137 |
+
}
|
5138 |
+
set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts );
|
5139 |
+
}
|
5140 |
+
|
5141 |
+
add_action( 'ot_after_theme_options_save', 'ot_update_google_fonts_after_save', 1 );
|
5142 |
+
}
|
5143 |
|
5144 |
+
if ( ! function_exists( 'ot_fetch_google_fonts' ) ) {
|
5145 |
+
|
5146 |
+
/**
|
5147 |
+
* Helper function to fetch the Google fonts array.
|
5148 |
+
*
|
5149 |
+
* @param bool $normalize Whether or not to return a normalized array. Default 'true'.
|
5150 |
+
* @param bool $force_rebuild Whether or not to force the array to be rebuilt. Default 'false'.
|
5151 |
+
*
|
5152 |
+
* @return array
|
5153 |
+
*
|
5154 |
+
* @access public
|
5155 |
+
* @since 2.5.0
|
5156 |
+
*/
|
5157 |
+
function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) {
|
5158 |
+
|
5159 |
+
// Google Fonts cache key.
|
5160 |
+
$ot_google_fonts_cache_key = apply_filters( 'ot_google_fonts_cache_key', 'ot_google_fonts_cache' );
|
5161 |
+
|
5162 |
+
// Get the fonts from cache.
|
5163 |
+
$ot_google_fonts = apply_filters( 'ot_google_fonts_cache', get_transient( $ot_google_fonts_cache_key ) );
|
5164 |
+
|
5165 |
+
if ( $force_rebuild || ! is_array( $ot_google_fonts ) || empty( $ot_google_fonts ) ) {
|
5166 |
+
|
5167 |
+
$ot_google_fonts = array();
|
5168 |
+
|
5169 |
+
// API url and key.
|
5170 |
+
$ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' );
|
5171 |
+
$ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', false );
|
5172 |
+
|
5173 |
+
if ( false === $ot_google_fonts_api_key ) {
|
5174 |
+
return array();
|
5175 |
+
}
|
5176 |
+
|
5177 |
+
// API arguments.
|
5178 |
+
$ot_google_fonts_fields = apply_filters(
|
5179 |
+
'ot_google_fonts_fields',
|
5180 |
+
array(
|
5181 |
+
'family',
|
5182 |
+
'variants',
|
5183 |
+
'subsets',
|
5184 |
+
)
|
5185 |
+
);
|
5186 |
+
$ot_google_fonts_sort = apply_filters( 'ot_google_fonts_sort', 'alpha' );
|
5187 |
+
|
5188 |
+
// Initiate API request.
|
5189 |
+
$ot_google_fonts_query_args = array(
|
5190 |
+
'key' => $ot_google_fonts_api_key,
|
5191 |
+
'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')',
|
5192 |
+
'sort' => $ot_google_fonts_sort,
|
5193 |
+
);
|
5194 |
+
|
5195 |
+
// Build and make the request.
|
5196 |
+
$ot_google_fonts_query = esc_url_raw( add_query_arg( $ot_google_fonts_query_args, $ot_google_fonts_api_url ) );
|
5197 |
+
$ot_google_fonts_response = wp_safe_remote_get(
|
5198 |
+
$ot_google_fonts_query,
|
5199 |
+
array(
|
5200 |
+
'sslverify' => false,
|
5201 |
+
'timeout' => 15,
|
5202 |
+
)
|
5203 |
+
);
|
5204 |
+
|
5205 |
+
// Continue if we got a valid response.
|
5206 |
+
if ( 200 === wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) {
|
5207 |
+
|
5208 |
+
$response_body = wp_remote_retrieve_body( $ot_google_fonts_response );
|
5209 |
+
|
5210 |
+
if ( $response_body ) {
|
5211 |
+
|
5212 |
+
// JSON decode the response body and cache the result.
|
5213 |
+
$ot_google_fonts_data = json_decode( trim( $response_body ), true );
|
5214 |
+
|
5215 |
+
if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) {
|
5216 |
+
|
5217 |
+
$ot_google_fonts = $ot_google_fonts_data['items'];
|
5218 |
+
|
5219 |
+
// Normalize the array key.
|
5220 |
+
$ot_google_fonts_tmp = array();
|
5221 |
+
foreach ( $ot_google_fonts as $key => $value ) {
|
5222 |
+
if ( ! isset( $value['family'] ) ) {
|
5223 |
+
continue;
|
5224 |
+
}
|
5225 |
+
|
5226 |
+
$id = preg_replace( '/[^a-z0-9_\-]/', '', strtolower( remove_accents( $value['family'] ) ) );
|
5227 |
+
|
5228 |
+
if ( $id ) {
|
5229 |
+
$ot_google_fonts_tmp[ $id ] = $value;
|
5230 |
+
}
|
5231 |
+
}
|
5232 |
+
|
5233 |
+
$ot_google_fonts = $ot_google_fonts_tmp;
|
5234 |
+
set_theme_mod( 'ot_google_fonts', $ot_google_fonts );
|
5235 |
+
set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS );
|
5236 |
+
}
|
5237 |
+
}
|
5238 |
+
}
|
5239 |
+
}
|
5240 |
+
|
5241 |
+
return $normalize ? ot_normalize_google_fonts( $ot_google_fonts ) : $ot_google_fonts;
|
5242 |
+
}
|
5243 |
+
}
|
5244 |
|
5245 |
+
if ( ! function_exists( 'ot_normalize_google_fonts' ) ) {
|
5246 |
|
5247 |
+
/**
|
5248 |
+
* Helper function to normalize the Google fonts array.
|
5249 |
+
*
|
5250 |
+
* @param array $google_fonts An array of fonts to normalize.
|
5251 |
+
*
|
5252 |
+
* @return array
|
5253 |
+
*
|
5254 |
+
* @access public
|
5255 |
+
* @since 2.5.0
|
5256 |
+
*/
|
5257 |
+
function ot_normalize_google_fonts( $google_fonts ) {
|
5258 |
|
5259 |
+
$ot_normalized_google_fonts = array();
|
5260 |
|
5261 |
+
if ( is_array( $google_fonts ) && ! empty( $google_fonts ) ) {
|
5262 |
|
5263 |
+
foreach ( $google_fonts as $google_font ) {
|
5264 |
|
5265 |
+
if ( isset( $google_font['family'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
5266 |
|
5267 |
+
$id = str_replace( ' ', '+', $google_font['family'] );
|
5268 |
|
5269 |
+
$ot_normalized_google_fonts[ $id ] = array(
|
5270 |
+
'family' => $google_font['family'],
|
5271 |
+
);
|
5272 |
|
5273 |
+
if ( isset( $google_font['variants'] ) ) {
|
5274 |
+
$ot_normalized_google_fonts[ $id ]['variants'] = $google_font['variants'];
|
5275 |
+
}
|
5276 |
|
5277 |
+
if ( isset( $google_font['subsets'] ) ) {
|
5278 |
+
$ot_normalized_google_fonts[ $id ]['subsets'] = $google_font['subsets'];
|
5279 |
+
}
|
5280 |
+
}
|
5281 |
+
}
|
5282 |
+
}
|
|
|
|
|
|
|
5283 |
|
5284 |
+
return $ot_normalized_google_fonts;
|
5285 |
+
}
|
5286 |
+
}
|
5287 |
+
|
5288 |
+
if ( ! function_exists( 'ot_wpml_register_string' ) ) {
|
5289 |
+
|
5290 |
+
/**
|
5291 |
+
* Helper function to register a WPML string.
|
5292 |
+
*
|
5293 |
+
* @param string $id The string ID.
|
5294 |
+
* @param string $value The string value.
|
5295 |
+
*
|
5296 |
+
* @access public
|
5297 |
+
* @since 2.1
|
5298 |
+
*/
|
5299 |
+
function ot_wpml_register_string( $id, $value ) {
|
5300 |
+
if ( function_exists( 'icl_register_string' ) ) {
|
5301 |
+
icl_register_string( 'Theme Options', $id, $value );
|
5302 |
+
}
|
5303 |
+
}
|
5304 |
+
}
|
5305 |
+
|
5306 |
+
if ( ! function_exists( 'ot_wpml_unregister_string' ) ) {
|
5307 |
+
|
5308 |
+
/**
|
5309 |
+
* Helper function to unregister a WPML string.
|
5310 |
+
*
|
5311 |
+
* @param string $id The string ID.
|
5312 |
+
*
|
5313 |
+
* @access public
|
5314 |
+
* @since 2.1
|
5315 |
+
*/
|
5316 |
+
function ot_wpml_unregister_string( $id ) {
|
5317 |
+
if ( function_exists( 'icl_unregister_string' ) ) {
|
5318 |
+
icl_unregister_string( 'Theme Options', $id );
|
5319 |
+
}
|
5320 |
+
}
|
5321 |
+
}
|
5322 |
+
|
5323 |
+
if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) {
|
5324 |
+
|
5325 |
+
/**
|
5326 |
+
* Maybe migrate Settings.
|
5327 |
+
*
|
5328 |
+
* @access public
|
5329 |
+
* @since 2.3.3
|
5330 |
+
*/
|
5331 |
+
function ot_maybe_migrate_settings() {
|
5332 |
+
|
5333 |
+
// Filter the ID to migrate from.
|
5334 |
+
$settings_id = apply_filters( 'ot_migrate_settings_id', '' );
|
5335 |
+
|
5336 |
+
// Attempt to migrate Settings.
|
5337 |
+
if ( ! empty( $settings_id ) && false === get_option( ot_settings_id() ) && ot_settings_id() !== $settings_id ) {
|
5338 |
+
|
5339 |
+
// Old settings.
|
5340 |
+
$settings = get_option( $settings_id );
|
5341 |
+
|
5342 |
+
// Check for array keys.
|
5343 |
+
if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) {
|
5344 |
+
update_option( ot_settings_id(), $settings );
|
5345 |
+
}
|
5346 |
+
}
|
5347 |
+
}
|
5348 |
+
}
|
5349 |
|
5350 |
+
if ( ! function_exists( 'ot_maybe_migrate_options' ) ) {
|
5351 |
|
5352 |
+
/**
|
5353 |
+
* Maybe migrate Option.
|
5354 |
+
*
|
5355 |
+
* @access public
|
5356 |
+
* @since 2.3.3
|
5357 |
+
*/
|
5358 |
+
function ot_maybe_migrate_options() {
|
5359 |
|
5360 |
+
// Filter the ID to migrate from.
|
5361 |
+
$options_id = apply_filters( 'ot_migrate_options_id', '' );
|
5362 |
|
5363 |
+
// Attempt to migrate Theme Options.
|
5364 |
+
if ( ! empty( $options_id ) && false === get_option( ot_options_id() ) && ot_options_id() !== $options_id ) {
|
5365 |
|
5366 |
+
// Old options.
|
5367 |
+
$options = get_option( $options_id );
|
5368 |
|
5369 |
+
// Migrate to new ID.
|
5370 |
+
update_option( ot_options_id(), $options );
|
5371 |
+
}
|
5372 |
+
}
|
5373 |
+
}
|
5374 |
|
5375 |
+
if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) {
|
|
|
5376 |
|
5377 |
+
/**
|
5378 |
+
* Maybe migrate Layouts.
|
5379 |
+
*
|
5380 |
+
* @access public
|
5381 |
+
* @since 2.3.3
|
5382 |
+
*/
|
5383 |
+
function ot_maybe_migrate_layouts() {
|
5384 |
|
5385 |
+
// Filter the ID to migrate from.
|
5386 |
+
$layouts_id = apply_filters( 'ot_migrate_layouts_id', '' );
|
5387 |
|
5388 |
+
// Attempt to migrate Layouts.
|
5389 |
+
if ( ! empty( $layouts_id ) && false === get_option( ot_layouts_id() ) && ot_layouts_id() !== $layouts_id ) {
|
5390 |
|
5391 |
+
// Old options.
|
5392 |
+
$layouts = get_option( $layouts_id );
|
5393 |
|
5394 |
+
// Migrate to new ID.
|
5395 |
+
update_option( ot_layouts_id(), $layouts );
|
5396 |
+
}
|
5397 |
+
}
|
5398 |
+
}
|
5399 |
|
5400 |
+
if ( ! function_exists( 'ot_meta_box_post_format_gallery' ) ) {
|
5401 |
+
|
5402 |
+
/**
|
5403 |
+
* Returns an array with the post format gallery meta box.
|
5404 |
+
*
|
5405 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5406 |
+
* post_types and is what tells the metabox where to
|
5407 |
+
* display. Default 'post'.
|
5408 |
+
* @return array
|
5409 |
+
*
|
5410 |
+
* @access public
|
5411 |
+
* @since 2.4.0
|
5412 |
+
*/
|
5413 |
+
function ot_meta_box_post_format_gallery( $pages = 'post' ) {
|
5414 |
+
|
5415 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'gallery', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5416 |
+
return false;
|
5417 |
+
}
|
5418 |
+
|
5419 |
+
if ( is_string( $pages ) ) {
|
5420 |
+
$pages = explode( ',', $pages );
|
5421 |
+
}
|
5422 |
+
|
5423 |
+
return apply_filters(
|
5424 |
+
'ot_meta_box_post_format_gallery',
|
5425 |
+
array(
|
5426 |
+
'id' => 'ot-post-format-gallery',
|
5427 |
+
'title' => esc_html__( 'Gallery', 'option-tree' ),
|
5428 |
+
'desc' => '',
|
5429 |
+
'pages' => $pages,
|
5430 |
+
'context' => 'side',
|
5431 |
+
'priority' => 'low',
|
5432 |
+
'fields' => array(
|
5433 |
+
array(
|
5434 |
+
'id' => '_format_gallery',
|
5435 |
+
'label' => '',
|
5436 |
+
'desc' => '',
|
5437 |
+
'std' => '',
|
5438 |
+
'type' => 'gallery',
|
5439 |
+
'class' => 'ot-gallery-shortcode',
|
5440 |
+
),
|
5441 |
+
),
|
5442 |
+
),
|
5443 |
+
$pages
|
5444 |
+
);
|
5445 |
+
}
|
5446 |
+
}
|
5447 |
|
5448 |
+
if ( ! function_exists( 'ot_meta_box_post_format_link' ) ) {
|
5449 |
+
|
5450 |
+
/**
|
5451 |
+
* Returns an array with the post format link metabox.
|
5452 |
+
*
|
5453 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5454 |
+
* post_types and is what tells the metabox where to
|
5455 |
+
* display. Default 'post'.
|
5456 |
+
* @return array
|
5457 |
+
*
|
5458 |
+
* @access public
|
5459 |
+
* @since 2.4.0
|
5460 |
+
*/
|
5461 |
+
function ot_meta_box_post_format_link( $pages = 'post' ) {
|
5462 |
+
|
5463 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5464 |
+
return false;
|
5465 |
+
}
|
5466 |
+
|
5467 |
+
if ( is_string( $pages ) ) {
|
5468 |
+
$pages = explode( ',', $pages );
|
5469 |
+
}
|
5470 |
+
|
5471 |
+
return apply_filters(
|
5472 |
+
'ot_meta_box_post_format_link',
|
5473 |
+
array(
|
5474 |
+
'id' => 'ot-post-format-link',
|
5475 |
+
'title' => esc_html__( 'Link', 'option-tree' ),
|
5476 |
+
'desc' => '',
|
5477 |
+
'pages' => $pages,
|
5478 |
+
'context' => 'side',
|
5479 |
+
'priority' => 'low',
|
5480 |
+
'fields' => array(
|
5481 |
+
array(
|
5482 |
+
'id' => '_format_link_url',
|
5483 |
+
'label' => '',
|
5484 |
+
'desc' => esc_html__( 'Link URL', 'option-tree' ),
|
5485 |
+
'std' => '',
|
5486 |
+
'type' => 'text',
|
5487 |
+
),
|
5488 |
+
array(
|
5489 |
+
'id' => '_format_link_title',
|
5490 |
+
'label' => '',
|
5491 |
+
'desc' => esc_html__( 'Link Title', 'option-tree' ),
|
5492 |
+
'std' => '',
|
5493 |
+
'type' => 'text',
|
5494 |
+
),
|
5495 |
+
),
|
5496 |
+
),
|
5497 |
+
$pages
|
5498 |
+
);
|
5499 |
+
}
|
5500 |
+
}
|
5501 |
+
|
5502 |
+
if ( ! function_exists( 'ot_meta_box_post_format_quote' ) ) {
|
5503 |
+
|
5504 |
+
/**
|
5505 |
+
* Returns an array with the post format quote metabox.
|
5506 |
+
*
|
5507 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5508 |
+
* post_types and is what tells the metabox where to
|
5509 |
+
* display. Default 'post'.
|
5510 |
+
* @return array
|
5511 |
+
*
|
5512 |
+
* @access public
|
5513 |
+
* @since 2.4.0
|
5514 |
+
*/
|
5515 |
+
function ot_meta_box_post_format_quote( $pages = 'post' ) {
|
5516 |
+
|
5517 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5518 |
+
return false;
|
5519 |
+
}
|
5520 |
+
|
5521 |
+
if ( is_string( $pages ) ) {
|
5522 |
+
$pages = explode( ',', $pages );
|
5523 |
+
}
|
5524 |
+
|
5525 |
+
return apply_filters(
|
5526 |
+
'ot_meta_box_post_format_quote',
|
5527 |
+
array(
|
5528 |
+
'id' => 'ot-post-format-quote',
|
5529 |
+
'title' => esc_html__( 'Quote', 'option-tree' ),
|
5530 |
+
'desc' => '',
|
5531 |
+
'pages' => $pages,
|
5532 |
+
'context' => 'side',
|
5533 |
+
'priority' => 'low',
|
5534 |
+
'fields' => array(
|
5535 |
+
array(
|
5536 |
+
'id' => '_format_quote_source_name',
|
5537 |
+
'label' => '',
|
5538 |
+
'desc' => esc_html__( 'Source Name (ex. author, singer, actor)', 'option-tree' ),
|
5539 |
+
'std' => '',
|
5540 |
+
'type' => 'text',
|
5541 |
+
),
|
5542 |
+
array(
|
5543 |
+
'id' => '_format_quote_source_url',
|
5544 |
+
'label' => '',
|
5545 |
+
'desc' => esc_html__( 'Source URL', 'option-tree' ),
|
5546 |
+
'std' => '',
|
5547 |
+
'type' => 'text',
|
5548 |
+
),
|
5549 |
+
array(
|
5550 |
+
'id' => '_format_quote_source_title',
|
5551 |
+
'label' => '',
|
5552 |
+
'desc' => esc_html__( 'Source Title (ex. book, song, movie)', 'option-tree' ),
|
5553 |
+
'std' => '',
|
5554 |
+
'type' => 'text',
|
5555 |
+
),
|
5556 |
+
array(
|
5557 |
+
'id' => '_format_quote_source_date',
|
5558 |
+
'label' => '',
|
5559 |
+
'desc' => esc_html__( 'Source Date', 'option-tree' ),
|
5560 |
+
'std' => '',
|
5561 |
+
'type' => 'text',
|
5562 |
+
),
|
5563 |
+
),
|
5564 |
+
),
|
5565 |
+
$pages
|
5566 |
+
);
|
5567 |
+
|
5568 |
+
}
|
5569 |
+
}
|
5570 |
+
|
5571 |
+
if ( ! function_exists( 'ot_meta_box_post_format_video' ) ) {
|
5572 |
+
|
5573 |
+
/**
|
5574 |
+
* Returns an array with the post format video metabox.
|
5575 |
+
*
|
5576 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5577 |
+
* post_types and is what tells the metabox where to
|
5578 |
+
* display. Default 'post'.
|
5579 |
+
* @return array
|
5580 |
+
*
|
5581 |
+
* @access public
|
5582 |
+
* @since 2.4.0
|
5583 |
+
*/
|
5584 |
+
function ot_meta_box_post_format_video( $pages = 'post' ) {
|
5585 |
+
|
5586 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5587 |
+
return false;
|
5588 |
+
}
|
5589 |
+
|
5590 |
+
if ( is_string( $pages ) ) {
|
5591 |
+
$pages = explode( ',', $pages );
|
5592 |
+
}
|
5593 |
+
|
5594 |
+
/* translators: %1$s: link to WorPress Codex, %2$s: video shortcode */
|
5595 |
+
$string = esc_html__( 'Embed video from services like Youtube, Vimeo, or Hulu. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' );
|
5596 |
+
|
5597 |
+
return apply_filters(
|
5598 |
+
'ot_meta_box_post_format_video',
|
5599 |
+
array(
|
5600 |
+
'id' => 'ot-post-format-video',
|
5601 |
+
'title' => __( 'Video', 'option-tree' ),
|
5602 |
+
'desc' => '',
|
5603 |
+
'pages' => $pages,
|
5604 |
+
'context' => 'side',
|
5605 |
+
'priority' => 'low',
|
5606 |
+
'fields' => array(
|
5607 |
+
array(
|
5608 |
+
'id' => '_format_video_embed',
|
5609 |
+
'label' => '',
|
5610 |
+
'desc' => sprintf( $string, '<a href="https://codex.wordpress.org/Embeds" target="_blank">' . esc_html__( 'WordPress Codex', 'option-tree' ) . '</a>', '<code>[video]</code>' ),
|
5611 |
+
'std' => '',
|
5612 |
+
'type' => 'textarea',
|
5613 |
+
),
|
5614 |
+
),
|
5615 |
+
),
|
5616 |
+
$pages
|
5617 |
+
);
|
5618 |
+
}
|
5619 |
+
}
|
5620 |
+
|
5621 |
+
if ( ! function_exists( 'ot_meta_box_post_format_audio' ) ) {
|
5622 |
+
|
5623 |
+
/**
|
5624 |
+
* Returns an array with the post format audio metabox.
|
5625 |
+
*
|
5626 |
+
* @param mixed $pages Excepts a comma separated string or array of
|
5627 |
+
* post_types and is what tells the metabox where to
|
5628 |
+
* display. Default 'post'.
|
5629 |
+
* @return array
|
5630 |
+
*
|
5631 |
+
* @access public
|
5632 |
+
* @since 2.4.0
|
5633 |
+
*/
|
5634 |
+
function ot_meta_box_post_format_audio( $pages = 'post' ) {
|
5635 |
+
|
5636 |
+
if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ), true ) ) {
|
5637 |
+
return false;
|
5638 |
+
}
|
5639 |
+
|
5640 |
+
if ( is_string( $pages ) ) {
|
5641 |
+
$pages = explode( ',', $pages );
|
5642 |
+
}
|
5643 |
+
|
5644 |
+
/* translators: %1$s: link to WorPress Codex, %2$s: audio shortcode */
|
5645 |
+
$string = esc_html__( 'Embed audio from services like SoundCloud and Radio. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' );
|
5646 |
+
|
5647 |
+
return apply_filters(
|
5648 |
+
'ot_meta_box_post_format_audio',
|
5649 |
+
array(
|
5650 |
+
'id' => 'ot-post-format-audio',
|
5651 |
+
'title' => esc_html__( 'Audio', 'option-tree' ),
|
5652 |
+
'desc' => '',
|
5653 |
+
'pages' => $pages,
|
5654 |
+
'context' => 'side',
|
5655 |
+
'priority' => 'low',
|
5656 |
+
'fields' => array(
|
5657 |
+
array(
|
5658 |
+
'id' => '_format_audio_embed',
|
5659 |
+
'label' => '',
|
5660 |
+
'desc' => sprintf( $string, '<a href="https://codex.wordpress.org/Embeds" target="_blank">' . esc_html__( 'WordPress Codex', 'option-tree' ) . '</a>', '<code>[audio]</code>' ),
|
5661 |
+
'std' => '',
|
5662 |
+
'type' => 'textarea',
|
5663 |
+
),
|
5664 |
+
),
|
5665 |
+
),
|
5666 |
+
$pages
|
5667 |
+
);
|
5668 |
+
|
5669 |
+
}
|
5670 |
+
}
|
5671 |
+
|
5672 |
+
if ( ! function_exists( 'ot_get_option_type_by_id' ) ) {
|
5673 |
+
|
5674 |
+
/**
|
5675 |
+
* Returns the option type by ID.
|
5676 |
+
*
|
5677 |
+
* @param string $option_id The option ID.
|
5678 |
+
* @param string $settings_id The settings array ID.
|
5679 |
+
* @return string The option type.
|
5680 |
+
*
|
5681 |
+
* @access public
|
5682 |
+
* @since 2.4.2
|
5683 |
+
*/
|
5684 |
+
function ot_get_option_type_by_id( $option_id, $settings_id = '' ) {
|
5685 |
+
|
5686 |
+
if ( empty( $settings_id ) ) {
|
5687 |
+
$settings_id = ot_settings_id();
|
5688 |
+
}
|
5689 |
+
|
5690 |
+
$settings = get_option( $settings_id, array() );
|
5691 |
|
5692 |
+
if ( isset( $settings['settings'] ) ) {
|
5693 |
|
5694 |
+
foreach ( $settings['settings'] as $value ) {
|
5695 |
|
5696 |
+
if ( $option_id === $value['id'] && isset( $value['type'] ) ) {
|
5697 |
+
return $value['type'];
|
5698 |
+
}
|
5699 |
+
}
|
5700 |
+
}
|
5701 |
|
5702 |
+
return false;
|
5703 |
+
}
|
5704 |
+
}
|
5705 |
|
5706 |
+
if ( ! function_exists( '_ot_settings_potential_shared_terms' ) ) {
|
5707 |
+
|
5708 |
+
/**
|
5709 |
+
* Build an array of potential Theme Options that could share terms.
|
5710 |
+
*
|
5711 |
+
* @return array
|
5712 |
+
*
|
5713 |
+
* @access private
|
5714 |
+
* @since 2.5.4
|
5715 |
+
*/
|
5716 |
+
function _ot_settings_potential_shared_terms() {
|
5717 |
+
|
5718 |
+
$options = array();
|
5719 |
+
$settings = get_option( ot_settings_id(), array() );
|
5720 |
+
$option_types = array(
|
5721 |
+
'category-checkbox',
|
5722 |
+
'category-select',
|
5723 |
+
'tag-checkbox',
|
5724 |
+
'tag-select',
|
5725 |
+
'taxonomy-checkbox',
|
5726 |
+
'taxonomy-select',
|
5727 |
+
);
|
5728 |
+
|
5729 |
+
if ( isset( $settings['settings'] ) ) {
|
5730 |
+
|
5731 |
+
foreach ( $settings['settings'] as $value ) {
|
5732 |
+
|
5733 |
+
if ( isset( $value['type'] ) ) {
|
5734 |
+
|
5735 |
+
if ( 'list-item' === $value['type'] && isset( $value['settings'] ) ) {
|
5736 |
+
|
5737 |
+
$saved = ot_get_option( $value['id'] );
|
5738 |
+
|
5739 |
+
foreach ( $value['settings'] as $item ) {
|
5740 |
+
|
5741 |
+
if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types, true ) ) {
|
5742 |
+
$sub_options = array();
|
5743 |
+
|
5744 |
+
foreach ( $saved as $sub_key => $sub_value ) {
|
5745 |
+
if ( isset( $sub_value[ $item['id'] ] ) ) {
|
5746 |
+
$sub_options[ $sub_key ] = $sub_value[ $item['id'] ];
|
5747 |
+
}
|
5748 |
+
}
|
5749 |
+
|
5750 |
+
if ( ! empty( $sub_options ) ) {
|
5751 |
+
$options[] = array(
|
5752 |
+
'id' => $item['id'],
|
5753 |
+
'taxonomy' => $value['taxonomy'],
|
5754 |
+
'parent' => $value['id'],
|
5755 |
+
'value' => $sub_options,
|
5756 |
+
);
|
5757 |
+
}
|
5758 |
+
}
|
5759 |
+
}
|
5760 |
+
}
|
5761 |
+
|
5762 |
+
if ( in_array( $value['type'], $option_types, true ) ) {
|
5763 |
+
$saved = ot_get_option( $value['id'] );
|
5764 |
+
if ( ! empty( $saved ) ) {
|
5765 |
+
$options[] = array(
|
5766 |
+
'id' => $value['id'],
|
5767 |
+
'taxonomy' => $value['taxonomy'],
|
5768 |
+
'value' => $saved,
|
5769 |
+
);
|
5770 |
+
}
|
5771 |
+
}
|
5772 |
+
}
|
5773 |
+
}
|
5774 |
+
}
|
5775 |
+
|
5776 |
+
return $options;
|
5777 |
+
}
|
5778 |
+
}
|
5779 |
|
5780 |
+
if ( ! function_exists( '_ot_meta_box_potential_shared_terms' ) ) {
|
5781 |
+
|
5782 |
+
/**
|
5783 |
+
* Build an array of potential Meta Box options that could share terms.
|
5784 |
+
*
|
5785 |
+
* @return array
|
5786 |
+
*
|
5787 |
+
* @access private
|
5788 |
+
* @since 2.5.4
|
5789 |
+
*/
|
5790 |
+
function _ot_meta_box_potential_shared_terms() {
|
5791 |
+
global $ot_meta_boxes;
|
5792 |
+
|
5793 |
+
$options = array();
|
5794 |
+
$settings = $ot_meta_boxes;
|
5795 |
+
$option_types = array(
|
5796 |
+
'category-checkbox',
|
5797 |
+
'category-select',
|
5798 |
+
'tag-checkbox',
|
5799 |
+
'tag-select',
|
5800 |
+
'taxonomy-checkbox',
|
5801 |
+
'taxonomy-select',
|
5802 |
+
);
|
5803 |
+
|
5804 |
+
foreach ( $settings as $setting ) {
|
5805 |
+
|
5806 |
+
if ( isset( $setting['fields'] ) ) {
|
5807 |
+
|
5808 |
+
foreach ( $setting['fields'] as $value ) {
|
5809 |
+
|
5810 |
+
if ( isset( $value['type'] ) ) {
|
5811 |
+
|
5812 |
+
if ( 'list-item' === $value['type'] && isset( $value['settings'] ) ) {
|
5813 |
+
|
5814 |
+
$children = array();
|
5815 |
+
|
5816 |
+
foreach ( $value['settings'] as $item ) {
|
5817 |
+
|
5818 |
+
if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types, true ) ) {
|
5819 |
+
$children[ $value['id'] ][] = $item['id'];
|
5820 |
+
}
|
5821 |
+
}
|
5822 |
+
|
5823 |
+
if ( ! empty( $children[ $value['id'] ] ) ) {
|
5824 |
+
$options[] = array(
|
5825 |
+
'id' => $value['id'],
|
5826 |
+
'children' => $children[ $value['id'] ],
|
5827 |
+
'taxonomy' => $value['taxonomy'],
|
5828 |
+
);
|
5829 |
+
}
|
5830 |
+
}
|
5831 |
+
|
5832 |
+
if ( in_array( $value['type'], $option_types, true ) ) {
|
5833 |
+
$options[] = array(
|
5834 |
+
'id' => $value['id'],
|
5835 |
+
'taxonomy' => $value['taxonomy'],
|
5836 |
+
);
|
5837 |
+
}
|
5838 |
+
}
|
5839 |
+
}
|
5840 |
+
}
|
5841 |
+
}
|
5842 |
+
|
5843 |
+
return $options;
|
5844 |
+
}
|
5845 |
}
|
|
|
5846 |
|
5847 |
+
if ( ! function_exists( 'ot_split_shared_term' ) ) {
|
5848 |
+
|
5849 |
+
/**
|
5850 |
+
* Update terms when a term gets split.
|
5851 |
+
*
|
5852 |
+
* @param int $term_id ID of the formerly shared term.
|
5853 |
+
* @param int $new_term_id ID of the new term created for the $term_taxonomy_id.
|
5854 |
+
* @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split.
|
5855 |
+
* @param string $taxonomy Taxonomy for the split term.
|
5856 |
+
*
|
5857 |
+
* @access public
|
5858 |
+
* @since 2.5.4
|
5859 |
+
*/
|
5860 |
+
function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
|
5861 |
+
unset( $term_taxonomy_id );
|
5862 |
+
|
5863 |
+
// Process the Theme Options.
|
5864 |
+
$settings = _ot_settings_potential_shared_terms();
|
5865 |
+
$old_options = get_option( ot_options_id(), array() );
|
5866 |
+
$new_options = $old_options;
|
5867 |
+
|
5868 |
+
// Process the saved settings.
|
5869 |
+
if ( ! empty( $settings ) && ! empty( $old_options ) ) {
|
5870 |
+
|
5871 |
+
// Loop over the Theme Options.
|
5872 |
+
foreach ( $settings as $option ) {
|
5873 |
+
|
5874 |
+
if ( ! is_array( $option['taxonomy'] ) ) {
|
5875 |
+
$option['taxonomy'] = explode( ',', $option['taxonomy'] );
|
5876 |
+
}
|
5877 |
+
|
5878 |
+
if ( ! in_array( $taxonomy, $option['taxonomy'], true ) ) {
|
5879 |
+
continue;
|
5880 |
+
}
|
5881 |
+
|
5882 |
+
// The option ID was found.
|
5883 |
+
if ( array_key_exists( $option['id'], $old_options ) || ( isset( $option['parent'] ) && array_key_exists( $option['parent'], $old_options ) ) ) {
|
5884 |
+
|
5885 |
+
// This is a list item, we have to go deeper.
|
5886 |
+
if ( isset( $option['parent'] ) ) {
|
5887 |
+
|
5888 |
+
// Loop over the array.
|
5889 |
+
foreach ( $option['value'] as $key => $value ) {
|
5890 |
+
|
5891 |
+
// The value is an array of IDs.
|
5892 |
+
if ( is_array( $value ) ) {
|
5893 |
+
|
5894 |
+
// Loop over the sub array.
|
5895 |
+
foreach ( $value as $sub_key => $sub_value ) {
|
5896 |
+
|
5897 |
+
if ( $sub_value === $term_id ) {
|
5898 |
+
unset( $new_options[ $option['parent'] ][ $key ][ $option['id'] ][ $sub_key ] );
|
5899 |
+
$new_options[ $option['parent'] ][ $key ][ $option['id'] ][ $new_term_id ] = $new_term_id;
|
5900 |
+
}
|
5901 |
+
}
|
5902 |
+
} elseif ( $value === $term_id ) {
|
5903 |
+
unset( $new_options[ $option['parent'] ][ $key ][ $option['id'] ] );
|
5904 |
+
$new_options[ $option['parent'] ][ $key ][ $option['id'] ] = $new_term_id;
|
5905 |
+
}
|
5906 |
+
}
|
5907 |
+
} else {
|
5908 |
+
|
5909 |
+
// The value is an array of IDs.
|
5910 |
+
if ( is_array( $option['value'] ) ) {
|
5911 |
+
|
5912 |
+
// Loop over the array.
|
5913 |
+
foreach ( $option['value'] as $key => $value ) {
|
5914 |
+
|
5915 |
+
// It's a single value, just replace it.
|
5916 |
+
if ( $value === $term_id ) {
|
5917 |
+
unset( $new_options[ $option['id'] ][ $key ] );
|
5918 |
+
$new_options[ $option['id'] ][ $new_term_id ] = $new_term_id;
|
5919 |
+
}
|
5920 |
+
}
|
5921 |
+
|
5922 |
+
// It's a single value, just replace it.
|
5923 |
+
} elseif ( $option['value'] === $term_id ) {
|
5924 |
+
$new_options[ $option['id'] ] = $new_term_id;
|
5925 |
+
}
|
5926 |
+
}
|
5927 |
+
}
|
5928 |
+
}
|
5929 |
+
}
|
5930 |
+
|
5931 |
+
// Options need to be updated.
|
5932 |
+
if ( $old_options !== $new_options ) {
|
5933 |
+
update_option( ot_options_id(), $new_options );
|
5934 |
+
}
|
5935 |
+
|
5936 |
+
// Process the Meta Boxes.
|
5937 |
+
$meta_settings = _ot_meta_box_potential_shared_terms();
|
5938 |
+
|
5939 |
+
if ( ! empty( $meta_settings ) ) {
|
5940 |
+
|
5941 |
+
foreach ( $meta_settings as $option ) {
|
5942 |
+
|
5943 |
+
if ( ! is_array( $option['taxonomy'] ) ) {
|
5944 |
+
$option['taxonomy'] = explode( ',', $option['taxonomy'] );
|
5945 |
+
}
|
5946 |
+
|
5947 |
+
if ( ! in_array( $taxonomy, $option['taxonomy'], true ) ) {
|
5948 |
+
continue;
|
5949 |
+
}
|
5950 |
+
|
5951 |
+
if ( isset( $option['children'] ) ) {
|
5952 |
+
$post_ids = get_posts(
|
5953 |
+
array(
|
5954 |
+
'fields' => 'ids',
|
5955 |
+
'meta_key' => $option['id'], // phpcs:ignore
|
5956 |
+
)
|
5957 |
+
);
|
5958 |
+
|
5959 |
+
if ( $post_ids ) {
|
5960 |
+
|
5961 |
+
foreach ( $post_ids as $post_id ) {
|
5962 |
+
|
5963 |
+
// Get the meta.
|
5964 |
+
$old_meta = get_post_meta( $post_id, $option['id'], true );
|
5965 |
+
$new_meta = $old_meta;
|
5966 |
+
|
5967 |
+
// Has a saved value.
|
5968 |
+
if ( ! empty( $old_meta ) && is_array( $old_meta ) ) {
|
5969 |
+
|
5970 |
+
// Loop over the array.
|
5971 |
+
foreach ( $old_meta as $key => $value ) {
|
5972 |
+
|
5973 |
+
foreach ( $value as $sub_key => $sub_value ) {
|
5974 |
+
|
5975 |
+
if ( in_array( $sub_key, $option['children'], true ) ) {
|
5976 |
+
|
5977 |
+
// The value is an array of IDs.
|
5978 |
+
if ( is_array( $sub_value ) ) {
|
5979 |
+
|
5980 |
+
// Loop over the array.
|
5981 |
+
foreach ( $sub_value as $sub_sub_key => $sub_sub_value ) {
|
5982 |
+
|
5983 |
+
// It's a single value, just replace it.
|
5984 |
+
if ( $sub_sub_value === $term_id ) {
|
5985 |
+
unset( $new_meta[ $key ][ $sub_key ][ $sub_sub_key ] );
|
5986 |
+
$new_meta[ $key ][ $sub_key ][ $new_term_id ] = $new_term_id;
|
5987 |
+
}
|
5988 |
+
}
|
5989 |
+
|
5990 |
+
// It's a single value, just replace it.
|
5991 |
+
} elseif ( $sub_value === $term_id ) {
|
5992 |
+
$new_meta[ $key ][ $sub_key ] = $new_term_id;
|
5993 |
+
}
|
5994 |
+
}
|
5995 |
+
}
|
5996 |
+
}
|
5997 |
+
|
5998 |
+
// Update.
|
5999 |
+
if ( $old_meta !== $new_meta ) {
|
6000 |
+
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
6001 |
+
}
|
6002 |
+
}
|
6003 |
+
}
|
6004 |
+
}
|
6005 |
+
} else {
|
6006 |
+
$post_ids = get_posts(
|
6007 |
+
array(
|
6008 |
+
'fields' => 'ids',
|
6009 |
+
'meta_query' => array( // phpcs:ignore
|
6010 |
+
'key' => $option['id'],
|
6011 |
+
'value' => $term_id,
|
6012 |
+
'compare' => 'IN',
|
6013 |
+
),
|
6014 |
+
)
|
6015 |
+
);
|
6016 |
+
|
6017 |
+
if ( $post_ids ) {
|
6018 |
+
|
6019 |
+
foreach ( $post_ids as $post_id ) {
|
6020 |
+
|
6021 |
+
// Get the meta.
|
6022 |
+
$old_meta = get_post_meta( $post_id, $option['id'], true );
|
6023 |
+
$new_meta = $old_meta;
|
6024 |
+
|
6025 |
+
// Has a saved value.
|
6026 |
+
if ( ! empty( $old_meta ) ) {
|
6027 |
+
|
6028 |
+
// The value is an array of IDs.
|
6029 |
+
if ( is_array( $old_meta ) ) {
|
6030 |
+
|
6031 |
+
// Loop over the array.
|
6032 |
+
foreach ( $old_meta as $key => $value ) {
|
6033 |
+
|
6034 |
+
// It's a single value, just replace it.
|
6035 |
+
if ( $value === $term_id ) {
|
6036 |
+
unset( $new_meta[ $key ] );
|
6037 |
+
$new_meta[ $new_term_id ] = $new_term_id;
|
6038 |
+
}
|
6039 |
+
}
|
6040 |
+
|
6041 |
+
// It's a single value, just replace it.
|
6042 |
+
} elseif ( $old_meta === $term_id ) {
|
6043 |
+
$new_meta = $new_term_id;
|
6044 |
+
}
|
6045 |
+
|
6046 |
+
// Update.
|
6047 |
+
if ( $old_meta !== $new_meta ) {
|
6048 |
+
update_post_meta( $post_id, $option['id'], $new_meta, $old_meta );
|
6049 |
+
}
|
6050 |
+
}
|
6051 |
+
}
|
6052 |
+
}
|
6053 |
+
}
|
6054 |
+
}
|
6055 |
+
}
|
6056 |
+
}
|
6057 |
+
|
6058 |
+
add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 );
|
6059 |
+
}
|
includes/ot-functions-compat.php
CHANGED
@@ -1,364 +1,326 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* Compatibility Functions.
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
add_filter( '
|
18 |
-
add_filter( '
|
19 |
-
add_filter( '
|
20 |
-
add_filter( '
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
/**
|
23 |
-
* Import from the old 1.x files for backwards compatibility.
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*
|
27 |
-
* @access private
|
28 |
-
* @since 2.0.8
|
29 |
-
*/
|
30 |
if ( ! function_exists( 'compat_ot_import_from_files' ) ) {
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
/* auto import Data file */
|
91 |
-
if ( $has_data == true && ! get_option( ot_options_id() ) ) {
|
92 |
-
|
93 |
-
$get_data = wp_remote_get( $data_file );
|
94 |
-
|
95 |
-
if ( is_wp_error( $get_data ) )
|
96 |
-
return false;
|
97 |
-
|
98 |
-
$rawdata = isset( $get_data['body'] ) ? $get_data['body'] : '';
|
99 |
-
$options = unserialize( ot_decode( $rawdata ) );
|
100 |
-
|
101 |
-
/* get settings array */
|
102 |
-
$settings = get_option( ot_settings_id() );
|
103 |
-
|
104 |
-
/* has options */
|
105 |
-
if ( is_array( $options ) ) {
|
106 |
-
|
107 |
-
/* validate options */
|
108 |
-
if ( is_array( $settings ) ) {
|
109 |
-
|
110 |
-
foreach( $settings['settings'] as $setting ) {
|
111 |
-
|
112 |
-
if ( isset( $options[$setting['id']] ) ) {
|
113 |
-
|
114 |
-
$content = ot_stripslashes( $options[$setting['id']] );
|
115 |
-
|
116 |
-
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
/* update the option tree array */
|
125 |
-
update_option( ot_options_id(), $options );
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
}
|
130 |
-
|
131 |
-
/* auto import Layout file */
|
132 |
-
if ( $has_layout == true && ! get_option( ot_layouts_id() ) ) {
|
133 |
-
|
134 |
-
$get_data = wp_remote_get( $layout_file );
|
135 |
-
|
136 |
-
if ( is_wp_error( $get_data ) )
|
137 |
-
return false;
|
138 |
-
|
139 |
-
$rawdata = isset( $get_data['body'] ) ? $get_data['body'] : '';
|
140 |
-
$layouts = unserialize( ot_decode( $rawdata ) );
|
141 |
-
|
142 |
-
/* get settings array */
|
143 |
-
$settings = get_option( ot_settings_id() );
|
144 |
-
|
145 |
-
/* has layouts */
|
146 |
-
if ( is_array( $layouts ) ) {
|
147 |
-
|
148 |
-
/* validate options */
|
149 |
-
if ( is_array( $settings ) ) {
|
150 |
-
|
151 |
-
foreach( $layouts as $key => $value ) {
|
152 |
-
|
153 |
-
if ( $key == 'active_layout' )
|
154 |
-
continue;
|
155 |
-
|
156 |
-
$options = unserialize( ot_decode( $value ) );
|
157 |
-
|
158 |
-
foreach( $settings['settings'] as $setting ) {
|
159 |
-
|
160 |
-
if ( isset( $options[$setting['id']] ) ) {
|
161 |
-
|
162 |
-
$content = ot_stripslashes( $options[$setting['id']] );
|
163 |
-
|
164 |
-
$options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] );
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
}
|
169 |
-
|
170 |
-
$layouts[$key] = ot_encode( serialize( $options ) );
|
171 |
-
|
172 |
-
}
|
173 |
-
|
174 |
-
}
|
175 |
-
|
176 |
-
/* update the option tree array */
|
177 |
-
if ( isset( $layouts['active_layout'] ) ) {
|
178 |
-
|
179 |
-
update_option( ot_options_id(), unserialize( ot_decode( $layouts[$layouts['active_layout']] ) ) );
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
/* update the option tree layouts array */
|
184 |
-
update_option( ot_layouts_id(), $layouts );
|
185 |
-
|
186 |
-
}
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
}
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
}
|
193 |
|
194 |
-
/**
|
195 |
-
* Filters the option types array.
|
196 |
-
*
|
197 |
-
* Allows the old 'option_tree_option_types' filter to
|
198 |
-
* change the new 'ot_option_types_array' return value.
|
199 |
-
*
|
200 |
-
* @return array
|
201 |
-
*
|
202 |
-
* @access public
|
203 |
-
* @since 2.0
|
204 |
-
*/
|
205 |
if ( ! function_exists( 'compat_ot_option_types_array' ) ) {
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
|
|
213 |
}
|
214 |
|
215 |
-
/**
|
216 |
-
* Filters the recognized font styles array.
|
217 |
-
*
|
218 |
-
* Allows the old 'recognized_font_styles' filter to
|
219 |
-
* change the new 'ot_recognized_font_styles' return value.
|
220 |
-
*
|
221 |
-
* @return array
|
222 |
-
*
|
223 |
-
* @access public
|
224 |
-
* @since 2.0
|
225 |
-
*/
|
226 |
if ( ! function_exists( 'compat_ot_recognized_font_styles' ) ) {
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
|
236 |
-
/**
|
237 |
-
* Filters the recognized font weights array.
|
238 |
-
*
|
239 |
-
* Allows the old 'recognized_font_weights' filter to
|
240 |
-
* change the new 'ot_recognized_font_weights' return value.
|
241 |
-
*
|
242 |
-
* @return array
|
243 |
-
*
|
244 |
-
* @access public
|
245 |
-
* @since 2.0
|
246 |
-
*/
|
247 |
if ( ! function_exists( 'compat_ot_recognized_font_weights' ) ) {
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
|
257 |
-
/**
|
258 |
-
* Filters the recognized font variants array.
|
259 |
-
*
|
260 |
-
* Allows the old 'recognized_font_variants' filter to
|
261 |
-
* change the new 'ot_recognized_font_variants' return value.
|
262 |
-
*
|
263 |
-
* @return array
|
264 |
-
*
|
265 |
-
* @access public
|
266 |
-
* @since 2.0
|
267 |
-
*/
|
268 |
if ( ! function_exists( 'compat_ot_recognized_font_variants' ) ) {
|
269 |
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
}
|
277 |
|
278 |
-
/**
|
279 |
-
* Filters the recognized font families array.
|
280 |
-
*
|
281 |
-
* Allows the old 'recognized_font_families' filter to
|
282 |
-
* change the new 'ot_recognized_font_families' return value.
|
283 |
-
*
|
284 |
-
* @return array
|
285 |
-
*
|
286 |
-
* @access public
|
287 |
-
* @since 2.0
|
288 |
-
*/
|
289 |
if ( ! function_exists( 'compat_ot_recognized_font_families' ) ) {
|
290 |
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
}
|
298 |
|
299 |
-
/**
|
300 |
-
* Filters the recognized background repeat array.
|
301 |
-
*
|
302 |
-
* Allows the old 'recognized_background_repeat' filter to
|
303 |
-
* change the new 'ot_recognized_background_repeat' return value.
|
304 |
-
*
|
305 |
-
* @return array
|
306 |
-
*
|
307 |
-
* @access public
|
308 |
-
* @since 2.0
|
309 |
-
*/
|
310 |
if ( ! function_exists( 'compat_ot_recognized_background_repeat' ) ) {
|
311 |
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
}
|
319 |
|
320 |
-
/**
|
321 |
-
* Filters the recognized background position array.
|
322 |
-
*
|
323 |
-
* Allows the old 'recognized_background_position' filter to
|
324 |
-
* change the new 'ot_recognized_background_position' return value.
|
325 |
-
*
|
326 |
-
* @return array
|
327 |
-
*
|
328 |
-
* @access public
|
329 |
-
* @since 2.0
|
330 |
-
*/
|
331 |
if ( ! function_exists( 'compat_ot_recognized_background_position' ) ) {
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
}
|
340 |
|
341 |
-
/**
|
342 |
-
* Filters the measurement unit types array.
|
343 |
-
*
|
344 |
-
* Allows the old 'measurement_unit_types' filter to
|
345 |
-
* change the new 'ot_measurement_unit_types' return value.
|
346 |
-
*
|
347 |
-
* @return array
|
348 |
-
*
|
349 |
-
* @access public
|
350 |
-
* @since 2.0
|
351 |
-
*/
|
352 |
if ( ! function_exists( 'compat_ot_measurement_unit_types' ) ) {
|
353 |
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
|
|
|
362 |
|
363 |
-
|
364 |
-
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Compatibility Functions.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
12 |
+
// Run the actions & filters.
|
13 |
+
add_action( 'admin_init', 'compat_ot_import_from_files', 1 );
|
14 |
+
add_filter( 'ot_option_types_array', 'compat_ot_option_types_array', 10, 1 );
|
15 |
+
add_filter( 'ot_recognized_font_styles', 'compat_ot_recognized_font_styles', 10, 2 );
|
16 |
+
add_filter( 'ot_recognized_font_weights', 'compat_ot_recognized_font_weights', 10, 2 );
|
17 |
+
add_filter( 'ot_recognized_font_variants', 'compat_ot_recognized_font_variants', 10, 2 );
|
18 |
+
add_filter( 'ot_recognized_font_families', 'compat_ot_recognized_font_families', 10, 2 );
|
19 |
+
add_filter( 'ot_recognized_background_repeat', 'compat_ot_recognized_background_repeat', 10, 2 );
|
20 |
+
add_filter( 'ot_recognized_background_position', 'compat_ot_recognized_background_position', 10, 2 );
|
21 |
+
add_filter( 'ot_measurement_unit_types', 'compat_ot_measurement_unit_types', 10, 2 );
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
if ( ! function_exists( 'compat_ot_import_from_files' ) ) {
|
24 |
|
25 |
+
/**
|
26 |
+
* Import from the old 1.x files for backwards compatibility.
|
27 |
+
*
|
28 |
+
* @access private
|
29 |
+
* @since 2.0.8
|
30 |
+
*/
|
31 |
+
function compat_ot_import_from_files() {
|
32 |
+
|
33 |
+
// File path & name.
|
34 |
+
$ot_data = '/option-tree/theme-options.txt';
|
35 |
+
$ot_layout = '/option-tree/layouts.txt';
|
36 |
+
|
37 |
+
// Data file path - child theme first then parent.
|
38 |
+
if ( is_readable( get_stylesheet_directory() . $ot_data ) ) {
|
39 |
+
|
40 |
+
$data_file = get_stylesheet_directory_uri() . $ot_data;
|
41 |
+
|
42 |
+
} elseif ( is_readable( get_template_directory() . $ot_data ) ) {
|
43 |
+
|
44 |
+
$data_file = get_template_directory_uri() . $ot_data;
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
// Layout file path - child theme first then parent.
|
49 |
+
if ( is_readable( get_stylesheet_directory() . $ot_layout ) ) {
|
50 |
+
|
51 |
+
$layout_file = get_stylesheet_directory_uri() . $ot_layout;
|
52 |
+
|
53 |
+
} elseif ( is_readable( get_template_directory() . $ot_layout ) ) {
|
54 |
+
|
55 |
+
$layout_file = get_template_directory_uri() . $ot_layout;
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
// Check for files.
|
60 |
+
$has_data = isset( $data_file ) ? true : false;
|
61 |
+
$has_layout = isset( $layout_file ) ? true : false;
|
62 |
+
|
63 |
+
// Auto import Data file.
|
64 |
+
if ( true === $has_data && ! get_option( ot_options_id() ) ) {
|
65 |
+
|
66 |
+
$get_data = wp_remote_get( $data_file );
|
67 |
+
|
68 |
+
if ( is_wp_error( $get_data ) ) {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
$options = isset( $get_data['body'] ) ? ot_decode( $get_data['body'] ) : array();
|
73 |
+
$options_safe = array();
|
74 |
+
|
75 |
+
// Get settings array.
|
76 |
+
$settings = get_option( ot_settings_id() );
|
77 |
+
|
78 |
+
// Has options.
|
79 |
+
if ( is_array( $options ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
+
// Validate options.
|
82 |
+
if ( is_array( $settings ) ) {
|
83 |
+
|
84 |
+
foreach ( $settings['settings'] as $setting ) {
|
85 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
86 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
// Update the option tree array.
|
92 |
+
update_option( ot_options_id(), $options_safe );
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
// Auto import Layout file.
|
97 |
+
if ( true === $has_layout && ! get_option( ot_layouts_id() ) ) {
|
98 |
+
|
99 |
+
$get_data = wp_remote_get( $layout_file );
|
100 |
+
|
101 |
+
if ( is_wp_error( $get_data ) ) {
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
|
105 |
+
$layouts = isset( $get_data['body'] ) ? ot_decode( $get_data['body'] ) : array();
|
106 |
+
$layouts_safe = array();
|
107 |
+
|
108 |
+
// Get settings array.
|
109 |
+
$settings = get_option( ot_settings_id() );
|
110 |
+
|
111 |
+
// Has layouts.
|
112 |
+
if ( is_array( $layouts ) ) {
|
113 |
+
|
114 |
+
// Validate options.
|
115 |
+
if ( is_array( $settings ) ) {
|
116 |
+
|
117 |
+
foreach ( $layouts as $key => $value ) {
|
118 |
+
|
119 |
+
if ( 'active_layout' === $key ) {
|
120 |
+
$layouts_safe['active_layout'] = $key;
|
121 |
+
continue;
|
122 |
+
}
|
123 |
+
|
124 |
+
$options = ot_decode( $value );
|
125 |
+
$options_safe = array();
|
126 |
+
|
127 |
+
foreach ( $settings['settings'] as $setting ) {
|
128 |
+
if ( isset( $options[ $setting['id'] ] ) ) {
|
129 |
+
$options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] );
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
if ( $key === $layouts['active_layout'] ) {
|
134 |
+
$new_options_safe = $options_safe;
|
135 |
+
}
|
136 |
+
|
137 |
+
$layouts_safe[ $key ] = ot_encode( $options_safe );
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
// Update the option tree array.
|
142 |
+
if ( isset( $new_options_safe ) ) {
|
143 |
+
update_option( ot_options_id(), $new_options_safe );
|
144 |
+
}
|
145 |
+
|
146 |
+
// Update the option tree layouts array.
|
147 |
+
update_option( ot_layouts_id(), $layouts_safe );
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
}
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
if ( ! function_exists( 'compat_ot_option_types_array' ) ) {
|
154 |
|
155 |
+
/**
|
156 |
+
* Filters the option types array.
|
157 |
+
*
|
158 |
+
* Allows the old 'option_tree_option_types' filter to
|
159 |
+
* change the new 'ot_option_types_array' return value.
|
160 |
+
*
|
161 |
+
* @param array $array The option types in key:value format.
|
162 |
+
* @return array
|
163 |
+
*
|
164 |
+
* @access public
|
165 |
+
* @since 2.0
|
166 |
+
*/
|
167 |
+
function compat_ot_option_types_array( $array ) {
|
168 |
+
|
169 |
+
return apply_filters( 'option_tree_option_types', $array );
|
170 |
|
171 |
+
}
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
if ( ! function_exists( 'compat_ot_recognized_font_styles' ) ) {
|
175 |
|
176 |
+
/**
|
177 |
+
* Filters the recognized font styles array.
|
178 |
+
*
|
179 |
+
* Allows the old 'recognized_font_styles' filter to
|
180 |
+
* change the new 'ot_recognized_font_styles' return value.
|
181 |
+
*
|
182 |
+
* @param array $array The option types in key:value format.
|
183 |
+
* @param string $id The field ID.
|
184 |
+
* @return array
|
185 |
+
*
|
186 |
+
* @access public
|
187 |
+
* @since 2.0
|
188 |
+
*/
|
189 |
+
function compat_ot_recognized_font_styles( $array, $id ) {
|
190 |
+
|
191 |
+
return apply_filters( 'recognized_font_styles', $array, $id );
|
192 |
+
|
193 |
+
}
|
194 |
}
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
if ( ! function_exists( 'compat_ot_recognized_font_weights' ) ) {
|
197 |
|
198 |
+
/**
|
199 |
+
* Filters the recognized font weights array.
|
200 |
+
*
|
201 |
+
* Allows the old 'recognized_font_weights' filter to
|
202 |
+
* change the new 'ot_recognized_font_weights' return value.
|
203 |
+
*
|
204 |
+
* @param array $array The option types in key:value format.
|
205 |
+
* @param string $id The field ID.
|
206 |
+
* @return array
|
207 |
+
*
|
208 |
+
* @access public
|
209 |
+
* @since 2.0
|
210 |
+
*/
|
211 |
+
function compat_ot_recognized_font_weights( $array, $id ) {
|
212 |
+
|
213 |
+
return apply_filters( 'recognized_font_weights', $array, $id );
|
214 |
+
|
215 |
+
}
|
216 |
}
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
if ( ! function_exists( 'compat_ot_recognized_font_variants' ) ) {
|
219 |
|
220 |
+
/**
|
221 |
+
* Filters the recognized font variants array.
|
222 |
+
*
|
223 |
+
* Allows the old 'recognized_font_variants' filter to
|
224 |
+
* change the new 'ot_recognized_font_variants' return value.
|
225 |
+
*
|
226 |
+
* @param array $array The option types in key:value format.
|
227 |
+
* @param string $id The field ID.
|
228 |
+
* @return array
|
229 |
+
*
|
230 |
+
* @access public
|
231 |
+
* @since 2.0
|
232 |
+
*/
|
233 |
+
function compat_ot_recognized_font_variants( $array, $id ) {
|
234 |
+
|
235 |
+
return apply_filters( 'recognized_font_variants', $array, $id );
|
236 |
+
|
237 |
+
}
|
238 |
}
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
if ( ! function_exists( 'compat_ot_recognized_font_families' ) ) {
|
241 |
|
242 |
+
/**
|
243 |
+
* Filters the recognized font families array.
|
244 |
+
*
|
245 |
+
* Allows the old 'recognized_font_families' filter to
|
246 |
+
* change the new 'ot_recognized_font_families' return value.
|
247 |
+
*
|
248 |
+
* @param array $array The option types in key:value format.
|
249 |
+
* @param string $id The field ID.
|
250 |
+
* @return array
|
251 |
+
*
|
252 |
+
* @access public
|
253 |
+
* @since 2.0
|
254 |
+
*/
|
255 |
+
function compat_ot_recognized_font_families( $array, $id ) {
|
256 |
+
|
257 |
+
return apply_filters( 'recognized_font_families', $array, $id );
|
258 |
+
|
259 |
+
}
|
260 |
}
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
if ( ! function_exists( 'compat_ot_recognized_background_repeat' ) ) {
|
263 |
|
264 |
+
/**
|
265 |
+
* Filters the recognized background repeat array.
|
266 |
+
*
|
267 |
+
* Allows the old 'recognized_background_repeat' filter to
|
268 |
+
* change the new 'ot_recognized_background_repeat' return value.
|
269 |
+
*
|
270 |
+
* @param array $array The option types in key:value format.
|
271 |
+
* @param string $id The field ID.
|
272 |
+
* @return array
|
273 |
+
*
|
274 |
+
* @access public
|
275 |
+
* @since 2.0
|
276 |
+
*/
|
277 |
+
function compat_ot_recognized_background_repeat( $array, $id ) {
|
278 |
+
|
279 |
+
return apply_filters( 'recognized_background_repeat', $array, $id );
|
280 |
+
|
281 |
+
}
|
282 |
}
|
283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
if ( ! function_exists( 'compat_ot_recognized_background_position' ) ) {
|
285 |
|
286 |
+
/**
|
287 |
+
* Filters the recognized background position array.
|
288 |
+
*
|
289 |
+
* Allows the old 'recognized_background_position' filter to
|
290 |
+
* change the new 'ot_recognized_background_position' return value.
|
291 |
+
*
|
292 |
+
* @param array $array The option types in key:value format.
|
293 |
+
* @param string $id The field ID.
|
294 |
+
* @return array
|
295 |
+
*
|
296 |
+
* @access public
|
297 |
+
* @since 2.0
|
298 |
+
*/
|
299 |
+
function compat_ot_recognized_background_position( $array, $id ) {
|
300 |
+
|
301 |
+
return apply_filters( 'recognized_background_position', $array, $id );
|
302 |
+
|
303 |
+
}
|
304 |
}
|
305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
if ( ! function_exists( 'compat_ot_measurement_unit_types' ) ) {
|
307 |
|
308 |
+
/**
|
309 |
+
* Filters the measurement unit types array.
|
310 |
+
*
|
311 |
+
* Allows the old 'measurement_unit_types' filter to
|
312 |
+
* change the new 'ot_measurement_unit_types' return value.
|
313 |
+
*
|
314 |
+
* @param array $array The option types in key:value format.
|
315 |
+
* @param string $id The field ID.
|
316 |
+
* @return array
|
317 |
+
*
|
318 |
+
* @access public
|
319 |
+
* @since 2.0
|
320 |
+
*/
|
321 |
+
function compat_ot_measurement_unit_types( $array, $id ) {
|
322 |
|
323 |
+
return apply_filters( 'measurement_unit_types', $array, $id );
|
324 |
|
325 |
+
}
|
326 |
+
}
|
includes/ot-functions-deprecated.php
CHANGED
@@ -1,99 +1,94 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* OptionTree
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
* @param array $options
|
16 |
-
* @param bool $echo
|
17 |
-
* @param bool $is_array
|
18 |
-
* @param int $offset
|
19 |
-
* @return mixed array or comma seperated lists of values
|
20 |
-
*
|
21 |
-
* @access public
|
22 |
-
* @since 1.0.0
|
23 |
-
* @updated 2.0
|
24 |
-
* @deprecated 2.0
|
25 |
-
*/
|
26 |
if ( ! function_exists( 'get_option_tree' ) ) {
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
$content = explode( ',', $content );
|
45 |
-
|
46 |
-
/* get an array value using an offset */
|
47 |
-
if ( is_numeric( $offset ) && $offset >= 0 ) {
|
48 |
-
$content = $content[$offset];
|
49 |
-
} else if ( ! is_numeric( $offset ) && isset( $content[$offset] ) ) {
|
50 |
-
$content = $content[$offset];
|
51 |
-
}
|
52 |
-
|
53 |
-
/* not an array */
|
54 |
-
} else if ( $is_array == false ) {
|
55 |
-
/* saved as array, implode and return a comma seperated lists of values */
|
56 |
-
if ( is_array( $content ) )
|
57 |
-
$content = implode( ',', $content ); /* This is fucked */
|
58 |
-
}
|
59 |
-
|
60 |
-
/* echo content */
|
61 |
-
if ( $echo )
|
62 |
-
echo $content;
|
63 |
-
|
64 |
-
return $content;
|
65 |
-
}
|
66 |
|
67 |
-
|
|
|
|
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$input = stripslashes( $input );
|
92 |
-
}
|
93 |
-
return $input;
|
94 |
-
}
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Deprecated Functions.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
if ( ! function_exists( 'get_option_tree' ) ) {
|
13 |
|
14 |
+
/**
|
15 |
+
* Displays or returns a value from the 'option_tree' array.
|
16 |
+
*
|
17 |
+
* @param string $item_id The item ID.
|
18 |
+
* @param array $options Options array.
|
19 |
+
* @param bool $echo Whether to echo or return value.
|
20 |
+
* @param bool $is_array Whether the value option is an array or string.
|
21 |
+
* @param int $offset The array key.
|
22 |
+
* @return mixed Array or comma separated lists of values.
|
23 |
+
*
|
24 |
+
* @access public
|
25 |
+
* @since 1.0.0
|
26 |
+
* @updated 2.0
|
27 |
+
* @deprecated 2.0
|
28 |
+
*/
|
29 |
+
function get_option_tree( $item_id = '', $options = array(), $echo = false, $is_array = false, $offset = -1 ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
// Load saved options.
|
32 |
+
if ( ! $options ) {
|
33 |
+
$options = get_option( ot_options_id() );
|
34 |
+
}
|
35 |
|
36 |
+
// No value return.
|
37 |
+
if ( ! isset( $options[ $item_id ] ) || empty( $options[ $item_id ] ) ) {
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
|
41 |
+
// Set content value & strip slashes.
|
42 |
+
$content = option_tree_stripslashes( $options[ $item_id ] );
|
43 |
+
|
44 |
+
if ( true === $is_array ) {
|
45 |
+
if ( ! is_array( $content ) ) {
|
46 |
+
$content = explode( ',', $content );
|
47 |
+
}
|
48 |
|
49 |
+
if ( is_numeric( $offset ) && 0 <= $offset ) {
|
50 |
+
$content = $content[ $offset ];
|
51 |
+
} elseif ( ! is_numeric( $offset ) && isset( $content[ $offset ] ) ) {
|
52 |
+
$content = $content[ $offset ];
|
53 |
+
}
|
54 |
+
} else {
|
55 |
+
if ( is_array( $content ) ) {
|
56 |
+
$content = implode( ',', $content );
|
57 |
+
}
|
58 |
+
}
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
if ( $echo ) {
|
61 |
+
echo $content; // phpcs:ignore
|
62 |
+
}
|
63 |
+
|
64 |
+
return $content;
|
65 |
+
}
|
66 |
}
|
67 |
|
68 |
+
if ( ! function_exists( 'option_tree_stripslashes' ) ) {
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Custom stripslashes from single value or array.
|
72 |
+
*
|
73 |
+
* @param mixed $input Input string or array.
|
74 |
+
* @return mixed
|
75 |
+
*
|
76 |
+
* @access public
|
77 |
+
* @since 1.1.3
|
78 |
+
* @deprecated 2.0
|
79 |
+
*/
|
80 |
+
function option_tree_stripslashes( $input ) {
|
81 |
+
if ( is_array( $input ) ) {
|
82 |
+
foreach ( $input as &$val ) {
|
83 |
+
if ( is_array( $val ) ) {
|
84 |
+
$val = option_tree_stripslashes( $val );
|
85 |
+
} else {
|
86 |
+
$val = stripslashes( $val );
|
87 |
+
}
|
88 |
+
}
|
89 |
+
} else {
|
90 |
+
$input = stripslashes( $input );
|
91 |
+
}
|
92 |
+
return $input;
|
93 |
+
}
|
94 |
+
}
|
includes/ot-functions-docs-page.php
CHANGED
@@ -1,190 +1,242 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* OptionTree
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
*
|
16 |
-
* @access public
|
17 |
-
* @since 2.0
|
18 |
-
*/
|
19 |
if ( ! function_exists( 'ot_type_creating_options' ) ) {
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
|
90 |
-
/**
|
91 |
-
* ot_get_option() option type.
|
92 |
-
*
|
93 |
-
* This is a callback function to display text about ot_get_option().
|
94 |
-
*
|
95 |
-
* @return string
|
96 |
-
*
|
97 |
-
* @access public
|
98 |
-
* @since 2.0
|
99 |
-
*/
|
100 |
if ( ! function_exists( 'ot_type_option_types' ) ) {
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
{{demo_background}}
|
142 |
background-color: {{demo_background|background-color}};
|
143 |
}</code></pre>';
|
144 |
|
145 |
-
|
146 |
-
|
147 |
body {
|
148 |
background: color image repeat attachment position;
|
149 |
background-color: color;
|
150 |
}
|
151 |
/* END demo_background */</code></pre>';
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
/* only run the filter on measurement with a field ID of my_measurement */
|
190 |
if ( $field_id == \'my_measurement\' ) {
|
@@ -196,8 +248,11 @@ body {
|
|
196 |
}
|
197 |
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
|
198 |
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
201 |
|
202 |
/* only run the filter on measurement with a field ID of my_measurement */
|
203 |
if ( $field_id == \'my_measurement\' ) {
|
@@ -210,33 +265,42 @@ add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10
|
|
210 |
return $array;
|
211 |
}
|
212 |
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
/* only run the filter where the field ID is my_radio_images */
|
242 |
if ( $field_id == \'my_radio_images\' ) {
|
@@ -258,48 +322,68 @@ add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10
|
|
258 |
|
259 |
}
|
260 |
add_filter( \'ot_radio_images\', \'filter_radio_images\', 10, 2 );</code></pre>';
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
305 |
if ( $field_id == \'my_textarea\' ) {
|
@@ -311,8 +395,11 @@ add_filter( \'ot_radio_images\', \'filter_radio_images\', 10, 2 );</code></pre>'
|
|
311 |
}
|
312 |
add_filter( \'ot_wpautop\', \'filter_textarea_wpautop\', 10, 2 );</code></pre>';
|
313 |
|
314 |
-
|
315 |
-
|
|
|
|
|
|
|
316 |
|
317 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
318 |
if ( $field_id == \'my_textarea\' ) {
|
@@ -323,9 +410,12 @@ add_filter( \'ot_wpautop\', \'filter_textarea_wpautop\', 10, 2 );</code></pre>';
|
|
323 |
|
324 |
}
|
325 |
add_filter( \'ot_media_buttons\', \'filter_textarea_media_buttons\', 10, 2 );</code></pre>';
|
326 |
-
|
327 |
-
|
328 |
-
|
|
|
|
|
|
|
329 |
|
330 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
331 |
if ( $field_id == \'my_textarea\' ) {
|
@@ -337,8 +427,10 @@ add_filter( \'ot_media_buttons\', \'filter_textarea_media_buttons\', 10, 2 );</c
|
|
337 |
}
|
338 |
add_filter( \'ot_tinymce\', \'filter_textarea_tinymce\', 10, 2 );</code></pre>';
|
339 |
|
340 |
-
|
341 |
-
|
|
|
|
|
342 |
|
343 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
344 |
if ( $field_id == \'my_textarea\' ) {
|
@@ -352,11 +444,13 @@ add_filter( \'ot_tinymce\', \'filter_textarea_tinymce\', 10, 2 );</code></pre>';
|
|
352 |
}
|
353 |
add_filter( \'ot_quicktags\', \'filter_textarea_quicktags\', 10, 1 );</code></pre>';
|
354 |
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
|
|
|
|
360 |
|
361 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
362 |
if ( $field_id == \'my_textarea\' ) {
|
@@ -367,18 +461,21 @@ add_filter( \'ot_quicktags\', \'filter_textarea_quicktags\', 10, 1 );</code></pr
|
|
367 |
|
368 |
}
|
369 |
add_filter( \'ot_wpautop\', \'filter_textarea_simple_wpautop\', 10, 2 );</code></pre>';
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
|
|
|
|
|
|
382 |
|
383 |
/* only run the filter when the field ID is my_google_fonts_headings */
|
384 |
if ( $field_id == \'my_google_fonts_headings\' ) {
|
@@ -394,164 +491,163 @@ add_filter( \'ot_wpautop\', \'filter_textarea_simple_wpautop\', 10, 2 );</code><
|
|
394 |
}
|
395 |
add_filter( \'ot_recognized_font_families\', \'filter_ot_recognized_font_families\', 10, 2 );</code></pre>';
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
|
|
406 |
}
|
407 |
|
408 |
-
/**
|
409 |
-
* ot_get_option() option type.
|
410 |
-
*
|
411 |
-
* This is a callback function to display text about ot_get_option().
|
412 |
-
*
|
413 |
-
* @return string
|
414 |
-
*
|
415 |
-
* @access public
|
416 |
-
* @since 2.0
|
417 |
-
*/
|
418 |
if ( ! function_exists( 'ot_type_ot_get_option' ) ) {
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
}
|
453 |
|
454 |
-
/**
|
455 |
-
* get_option_tree() option type.
|
456 |
-
*
|
457 |
-
* This is a callback function to display text about get_option_tree().
|
458 |
-
*
|
459 |
-
* @return string
|
460 |
-
*
|
461 |
-
* @access public
|
462 |
-
* @since 2.0
|
463 |
-
*/
|
464 |
if ( ! function_exists( 'ot_type_get_option_tree' ) ) {
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
}
|
515 |
|
516 |
-
/**
|
517 |
-
* Examples option type.
|
518 |
-
*
|
519 |
-
* @return string
|
520 |
-
*
|
521 |
-
* @access public
|
522 |
-
* @since 2.0
|
523 |
-
*/
|
524 |
if ( ! function_exists( 'ot_type_examples' ) ) {
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
$test_input = ot_get_option( \'test_input\' );
|
542 |
}</code></pre>';
|
543 |
|
544 |
-
|
545 |
-
|
546 |
-
|
|
|
|
|
547 |
$test_input = ot_get_option( \'test_input\', \'default input value goes here.\' );
|
548 |
}</code></pre>';
|
549 |
-
|
550 |
-
echo '<h4>' . __( 'Array Examples', 'option-tree' ) . ':</h4>';
|
551 |
-
|
552 |
-
echo '<p>' . __( 'Assigns the value of <code>navigation_ids</code> to the variable <code>$ids</code>. It then echos an unordered list of links (navigation) using <code>wp_list_pages()</code>.', 'option-tree' ) . '</p>';
|
553 |
|
554 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
/* get an array of page id\'s */
|
556 |
$ids = ot_get_option( \'navigation_ids\', array() );
|
557 |
|
@@ -567,11 +663,13 @@ if ( ! function_exists( 'ot_type_examples' ) ) {
|
|
567 |
echo \'</ul>\';
|
568 |
}
|
569 |
|
570 |
-
}</code></pre>';
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
|
|
|
|
575 |
/* get the array */
|
576 |
$measurement = ot_get_option( \'measurement_option_type_id\' );
|
577 |
|
@@ -584,7 +682,7 @@ if ( ! function_exists( 'ot_type_examples' ) ) {
|
|
584 |
|
585 |
}</code></pre>';
|
586 |
|
587 |
-
|
588 |
/* get the array, and have a default just incase */
|
589 |
$measurement = ot_get_option( \'measurement_option_type_id\', array( \'10\', \'px\' ) );
|
590 |
|
@@ -593,11 +691,11 @@ if ( ! function_exists( 'ot_type_examples' ) ) {
|
|
593 |
echo implode( \'\', $measurement );
|
594 |
}
|
595 |
|
596 |
-
}</code></pre>';
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
|
602 |
/* get the slider array */
|
603 |
$slides = ot_get_option( \'my_slider\', array() );
|
@@ -613,149 +711,178 @@ if ( ! function_exists( 'ot_type_examples' ) ) {
|
|
613 |
}
|
614 |
|
615 |
}</code></pre>';
|
616 |
-
|
617 |
-
echo '</div>';
|
618 |
-
|
619 |
-
echo '</div>';
|
620 |
-
|
621 |
-
}
|
622 |
-
|
623 |
-
}
|
624 |
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
* @access public
|
631 |
-
* @since 2.0
|
632 |
-
*/
|
633 |
if ( ! function_exists( 'ot_type_layouts_overview' ) ) {
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
713 |
}
|
714 |
|
715 |
-
/**
|
716 |
-
* Meta Boxes option type.
|
717 |
-
*
|
718 |
-
* @return string
|
719 |
-
*
|
720 |
-
* @access public
|
721 |
-
* @since 2.0
|
722 |
-
*/
|
723 |
if ( ! function_exists( 'ot_type_meta_boxes' ) ) {
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
749 |
* Meta Boxes
|
750 |
*/
|
751 |
require( trailingslashit( get_template_directory() ) . \'includes/meta-boxes.php\' );
|
752 |
</code></pre>';
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
|
|
|
|
|
|
|
|
759 |
* Initialize the meta boxes.
|
760 |
*/
|
761 |
add_action( 'admin_init', 'custom_meta_boxes' );
|
@@ -784,46 +911,55 @@ function custom_meta_boxes() {
|
|
784 |
|
785 |
ot_register_meta_box( $my_meta_box );
|
786 |
|
787 |
-
}</code></pre>";
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
}
|
794 |
-
|
795 |
}
|
796 |
|
797 |
-
/**
|
798 |
-
* Theme Mode option type.
|
799 |
-
*
|
800 |
-
* @return string
|
801 |
-
*
|
802 |
-
* @access public
|
803 |
-
* @since 2.0
|
804 |
-
*/
|
805 |
if ( ! function_exists( 'ot_type_theme_mode' ) ) {
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
* Required: set \'ot_theme_mode\' filter to true.
|
828 |
*/
|
829 |
add_filter( \'ot_theme_mode\', \'__return_true\' );
|
@@ -833,31 +969,47 @@ add_filter( \'ot_theme_mode\', \'__return_true\' );
|
|
833 |
*/
|
834 |
require( trailingslashit( get_template_directory() ) . \'option-tree/ot-loader.php\' );
|
835 |
</code></pre>';
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
849 |
* Theme Options
|
850 |
*/
|
851 |
require( trailingslashit( get_template_directory() ) . \'includes/theme-options.php\' );
|
852 |
</code></pre>';
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
|
|
|
|
|
|
|
|
861 |
* Initialize the options before anything else.
|
862 |
*/
|
863 |
add_action( 'init', 'custom_theme_options', 1 );
|
@@ -1007,14 +1159,9 @@ function custom_theme_options() {
|
|
1007 |
|
1008 |
}
|
1009 |
</code></pre>";
|
1010 |
-
|
1011 |
-
echo '</div>';
|
1012 |
-
|
1013 |
-
echo '</div>';
|
1014 |
-
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
}
|
1018 |
|
1019 |
-
|
1020 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Documentation Page Functions.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
|
|
|
|
|
|
|
|
12 |
if ( ! function_exists( 'ot_type_creating_options' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Creating Options option type.
|
16 |
+
*
|
17 |
+
* @access public
|
18 |
+
* @since 2.0
|
19 |
+
*/
|
20 |
+
function ot_type_creating_options() {
|
21 |
+
|
22 |
+
// Format setting outer wrapper.
|
23 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
24 |
+
|
25 |
+
// Description.
|
26 |
+
echo '<div class="description">';
|
27 |
+
|
28 |
+
echo '<h4>' . esc_html__( 'Label', 'option-tree' ) . ':</h4>';
|
29 |
+
echo '<p>' . esc_html__( 'The Label field should be a short but descriptive block of text 100 characters or less with no HTML.', 'option-tree' ) . '</p>';
|
30 |
+
|
31 |
+
echo '<h4>' . esc_html__( 'ID', 'option-tree' ) . ':</h4>';
|
32 |
+
echo '<p>' . esc_html__( 'The ID field is a unique alphanumeric key used to differentiate each theme option (underscores are acceptable). Also, the plugin will change all text you write in this field to lowercase and replace spaces and special characters with an underscore automatically.', 'option-tree' ) . '</p>';
|
33 |
+
|
34 |
+
echo '<h4>' . esc_html__( 'Type', 'option-tree' ) . ':</h4>';
|
35 |
+
|
36 |
+
/* translators: %s: option type tab */
|
37 |
+
$string = esc_html__( 'You are required to choose one of the supported option types when creating a new option. Here is a list of the available option types. For more information about each type click the %s tab to the left.', 'option-tree' );
|
38 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'Option Types', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
39 |
+
|
40 |
+
echo '<ul class="docs-ul">';
|
41 |
+
foreach ( ot_option_types_array() as $key => $value ) {
|
42 |
+
echo '<li>' . $value . '</li>'; // phpcs:ignore
|
43 |
+
}
|
44 |
+
echo '</ul>';
|
45 |
+
|
46 |
+
echo '<h4>' . esc_html__( 'Description', 'option-tree' ) . ':</h4>';
|
47 |
+
echo '<p>' . esc_html__( 'Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '</p>';
|
48 |
+
|
49 |
+
echo '<h4>' . esc_html__( 'Choices', 'option-tree' ) . ':</h4>';
|
50 |
+
echo '<p>' . esc_html__( 'Click the "Add Choice" button to add an item to the choices array. This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '</p>';
|
51 |
+
|
52 |
+
echo '<h4>' . esc_html__( 'Settings', 'option-tree' ) . ':</h4>';
|
53 |
+
echo '<p>' . esc_html__( 'Click the "Add Setting" button found inside a newly created setting to add an item to the settings array. This will only affect the List Item type.', 'option-tree' ) . '</p>';
|
54 |
+
|
55 |
+
echo '<h4>' . esc_html__( 'Standard', 'option-tree' ) . ':</h4>';
|
56 |
+
echo '<p>' . esc_html__( 'Setting the standard value for your option only works for some option types. Those types are one that have a single string value saved to them and not an array of values.', 'option-tree' ) . '</p>';
|
57 |
+
|
58 |
+
echo '<h4>' . esc_html__( 'Rows', 'option-tree' ) . ':</h4>';
|
59 |
+
echo '<p>' . esc_html__( 'Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '</p>';
|
60 |
+
|
61 |
+
echo '<h4>' . esc_html__( 'Post Type', 'option-tree' ) . ':</h4>';
|
62 |
+
|
63 |
+
/* translators: %1$s: example value, %2$s: post_type, %3$s: using any as a value */
|
64 |
+
$string = esc_html__( 'Add a comma separated list of post type like %1$s. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select. Below are the default post types available with WordPress and that are also compatible with OptionTree. You can also add your own custom %2$s. At this time %3$s does not seem to return results properly and is something I plan on looking into.', 'option-tree' );
|
65 |
+
echo '<p>' . sprintf( $string, '<code>post,page</code>', '<code>post_type</code>', '<code>any</code>' ) . '</p>'; // phpcs:ignore
|
66 |
+
|
67 |
+
echo '<ul class="docs-ul">';
|
68 |
+
echo '<li><code>post</code></li>';
|
69 |
+
echo '<li><code>page</code></li>';
|
70 |
+
echo '<li><code>attachment</code></li>';
|
71 |
+
echo '</ul>';
|
72 |
+
|
73 |
+
echo '<h4>' . esc_html__( 'Taxonomy', 'option-tree' ) . ':</h4>';
|
74 |
+
|
75 |
+
/* translators: %s: example value */
|
76 |
+
$string = esc_html__( 'Add a comma separated list of any registered taxonomy like %s. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' );
|
77 |
+
echo '<p>' . sprintf( $string, '<code>category,post_tag</code>' ) . '</p>'; // phpcs:ignore
|
78 |
+
|
79 |
+
echo '<h4>' . esc_html__( 'Min, Max, & Step', 'option-tree' ) . ':</h4>';
|
80 |
+
|
81 |
+
/* translators: %1$s: format, %2$s: range, %3$s: interval minimum */
|
82 |
+
$string = esc_html__( 'Add a comma separated list of options in the following format %1$s (slide from %2$s in intervals of %3$s). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' );
|
83 |
+
echo '<p>' . sprintf( $string, '<code>0,100,1</code>', '<code>0-100</code>', '<code>1</code>' ) . '</p>'; // phpcs:ignore
|
84 |
+
|
85 |
+
echo '<h4>' . esc_html__( 'CSS Class', 'option-tree' ) . ':</h4>';
|
86 |
+
echo '<p>' . esc_html__( 'Add and optional class to any option type.', 'option-tree' ) . '</p>';
|
87 |
+
|
88 |
+
echo '<h4>' . esc_html__( 'Condition', 'option-tree' ) . ':</h4>';
|
89 |
+
|
90 |
+
/* translators: %1$s: example (value) placeholder, %2$s: list of condition examples */
|
91 |
+
$string = esc_html__( 'Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, %1$s is a placeholder for your condition, which can be in the form of %2$s.', 'option-tree' );
|
92 |
+
echo '<p>' . sprintf( $string, '<code>value</code>', '<code>field_id:is(value)</code>, <code>field_id:not(value)</code>, <code>field_id:contains(value)</code>, <code>field_id:less_than(value)</code>, <code>field_id:less_than_or_equal_to(value)</code>, <code>field_id:greater_than(value)</code>, or <code>field_id:greater_than_or_equal_to(value)</code>' ) . '</p>'; // phpcs:ignore
|
93 |
+
|
94 |
+
echo '<h4>' . esc_html__( 'Operator', 'option-tree' ) . ':</h4>';
|
95 |
+
|
96 |
+
/* translators: %1$s: and value, %2$s: or value */
|
97 |
+
$string = esc_html__( 'Choose the logical operator to compute the result of the conditions. Your options are %1$s and %2$s.', 'option-tree' );
|
98 |
+
echo '<p>' . sprintf( $string, '<code>and</code>', '<code>or</code>' ) . '</p>'; // phpcs:ignore
|
99 |
+
|
100 |
+
echo '</div>';
|
101 |
+
|
102 |
+
echo '</div>';
|
103 |
+
}
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
if ( ! function_exists( 'ot_type_option_types' ) ) {
|
107 |
+
|
108 |
+
/**
|
109 |
+
* The ot_get_option() option type.
|
110 |
+
*
|
111 |
+
* This is a callback function to display text about ot_get_option().
|
112 |
+
*
|
113 |
+
* @access public
|
114 |
+
* @since 2.0
|
115 |
+
*/
|
116 |
+
function ot_type_option_types() {
|
117 |
+
|
118 |
+
// Format setting outer wrapper.
|
119 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
120 |
+
|
121 |
+
// Description.
|
122 |
+
echo '<div class="description">';
|
123 |
+
|
124 |
+
echo '<h4>' . esc_html__( 'Background', 'option-tree' ) . ':</h4>';
|
125 |
+
|
126 |
+
/* translators: %1$s: function name, %2$s: filter name, %3$s: filter name list */
|
127 |
+
$string = esc_html__( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with %1$s. The Background option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'option-tree' );
|
128 |
+
echo '<p>' . sprintf( $string, '<code>ot_get_option()</code>', '<code>ot_recognized_background_fields</code>', '<code>ot_recognized_background_repeat</code>, <code>ot_recognized_background_attachment</code>, <code>ot_recognized_background_position</code>, ' . __( 'and', 'option-tree' ) . ' <code>ot_type_background_size_choices</code>' ) . '</p>'; // phpcs:ignore
|
129 |
+
|
130 |
+
echo '<h4>' . esc_html__( 'Border', 'option-tree' ) . ':</h4>';
|
131 |
+
|
132 |
+
/* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name, %6$s: hidden, %7$s: dashed, %8$s: solid, %9$s: double, %10$s: groove, %11$s: ridge, %12$s: inset, %13$s: outset, %14$s: filter name */
|
133 |
+
$string = esc_html__( 'The Border option type is used to set width, unit, style, and color values. The text input excepts a numerical value and the unit select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter. The style select lets you choose the border style. The default styles are %6$s, %7$s, %8$s, %9$s, %10$s, %11$s, %12$s, and %13$s. However, you can change them with the %14$s filter. The colorpicker saves a hexadecimal color code.', 'option-tree' );
|
134 |
+
echo '<p>' . sprintf( $string, '<code>px</code>', '<code>%</code>', '<code>em</code>', '<code>pt</code>', '<code>ot_recognized_border_unit_types</code>', '<code>hidden</code>', '<code>dashed</code>', '<code>solid</code>', '<code>double</code>', '<code>groove</code>', '<code>ridge</code>', '<code>inset</code>', '<code>outset</code>', '<code>ot_recognized_border_style_types</code>' ) . '</p>'; // phpcs:ignore
|
135 |
+
|
136 |
+
echo '<h4>' . esc_html__( 'Box Shadow', 'option-tree' ) . ':</h4>';
|
137 |
+
|
138 |
+
/* translators: %1$s: inset, %2$s: offset-x, %3$s: offset-y, %4$s: blur-radius, %5$s: spread-radius, %6$s: color */
|
139 |
+
$string = esc_html__( 'The Box Shadow option type is used to set %1$s, %2$s, %3$s, %4$s, %5$s, and %6$s values.', 'option-tree' );
|
140 |
+
echo '<p>' . sprintf( $string, '<code>inset</code>', '<code>offset-x</code>', '<code>offset-y</code>', '<code>blur-radius</code>', '<code>spread-radius</code>', '<code>color</code>' ) . '</p>'; // phpcs:ignore
|
141 |
+
|
142 |
+
echo '<h4>' . esc_html__( 'Category Checkbox', 'option-tree' ) . ':</h4>';
|
143 |
+
echo '<p>' . esc_html__( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
144 |
+
|
145 |
+
echo '<h4>' . esc_html__( 'Category Select', 'option-tree' ) . ':</h4>';
|
146 |
+
echo '<p>' . esc_html__( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
147 |
+
|
148 |
+
echo '<h4>' . esc_html__( 'Checkbox', 'option-tree' ) . ':</h4>';
|
149 |
+
echo '<p>' . esc_html__( 'The Checkbox option type displays a group of choices. It allows the user to check multiple choices and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
150 |
+
|
151 |
+
echo '<h4>' . esc_html__( 'Colorpicker', 'option-tree' ) . ':</h4>';
|
152 |
+
echo '<p>' . esc_html__( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'option-tree' ) . '</p>';
|
153 |
+
|
154 |
+
echo '<h4>' . esc_html__( 'Colorpicker Opacity', 'option-tree' ) . ':</h4>';
|
155 |
+
|
156 |
+
/* translators: %1$s: range minimum, %2$s: range maximum, %3$s: minimum increment */
|
157 |
+
$string = esc_html__( 'The Colorpicker Opacity option type saves a hexadecimal color code with an opacity value from %1$s to %2$s in increments of %3$s. Though the value is saved as hexadecimal, if used within the CSS option type the color and opacity values will be converted into a valid RGBA CSS value.', 'option-tree' );
|
158 |
+
echo '<p>' . sprintf( $string, '<code>0</code>', '<code>1</code>', '<code>0.01</code>' ) . '</p>'; // phpcs:ignore
|
159 |
+
|
160 |
+
echo '<h4>' . esc_html__( 'CSS', 'option-tree' ) . ':</h4>';
|
161 |
+
|
162 |
+
/* translators: %1$s: file name, %2$s: command name, %3$s: permission mode, %4$s: permission mode */
|
163 |
+
$string = esc_html__( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named %1$s at the root level of your theme and change permissions using %2$s so the server can write to the file. I have had the most success setting this single file to %3$s but feel free to play around with permissions until everything is working. A good starting point is %4$s. When the server can save to the file, CSS will automatically be updated when you save your Theme Options.', 'option-tree' );
|
164 |
+
echo '<p>' . sprintf( $string, '<code>dynamic.css</code>', '<code>chmod</code>', '<code>0777</code>', '<code>0666</code>' ) . '</p>'; // phpcs:ignore
|
165 |
+
|
166 |
+
/* translators: option ID: pixel unit, %2$s: file name */
|
167 |
+
$string = esc_html__( 'This example assumes you have an option with the ID of %1$s. Which means this option will automatically insert the value of %1$s into the %2$s when the Theme Options are saved.', 'option-tree' );
|
168 |
+
echo '<p class="aside">' . sprintf( $string, '<code>demo_background</code>', '<code>dynamic.css</code>' ) . '</p>'; // phpcs:ignore
|
169 |
+
|
170 |
+
echo '<p>' . esc_html__( 'Input', 'option-tree' ) . ':</p>';
|
171 |
+
echo '<pre><code>body {
|
172 |
{{demo_background}}
|
173 |
background-color: {{demo_background|background-color}};
|
174 |
}</code></pre>';
|
175 |
|
176 |
+
echo '<p>' . esc_html__( 'Output', 'option-tree' ) . ':</p>';
|
177 |
+
echo '<pre><code>/* BEGIN demo_background */
|
178 |
body {
|
179 |
background: color image repeat attachment position;
|
180 |
background-color: color;
|
181 |
}
|
182 |
/* END demo_background */</code></pre>';
|
183 |
+
|
184 |
+
echo '<h4>' . esc_html__( 'Custom Post Type Checkbox', 'option-tree' ) . ':</h4>';
|
185 |
+
|
186 |
+
/* translators: %1$s: post_type */
|
187 |
+
$string = esc_html__( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'option-tree' );
|
188 |
+
echo '<p>' . sprintf( $string, '<code>post_type</code>' ) . '</p>'; // phpcs:ignore
|
189 |
+
|
190 |
+
echo '<h4>' . esc_html__( 'Custom Post Type Select', 'option-tree' ) . ':</h4>';
|
191 |
+
|
192 |
+
/* translators: %s: post_type */
|
193 |
+
$string = esc_html__( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'option-tree' );
|
194 |
+
echo '<p>' . sprintf( $string, '<code>post_type</code>' ) . '</p>'; // phpcs:ignore
|
195 |
+
|
196 |
+
echo '<h4>' . esc_html__( 'Date Picker', 'option-tree' ) . ':</h4>';
|
197 |
+
echo '<p>' . esc_html__( 'The Date Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date when focus is given to the input field. The returned value is a date formatted string.', 'option-tree' ) . '</p>';
|
198 |
+
|
199 |
+
echo '<h4>' . esc_html__( 'Date Time Picker', 'option-tree' ) . ':</h4>';
|
200 |
+
echo '<p>' . esc_html__( 'The Date Time Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date and time when focus is given to the input field. The returned value is a date and time formatted string.', 'option-tree' ) . '</p>';
|
201 |
+
|
202 |
+
echo '<h4>' . esc_html__( 'Dimension', 'option-tree' ) . ':</h4>';
|
203 |
+
|
204 |
+
/* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name */
|
205 |
+
$string = esc_html__( 'The Dimension option type is used to set width and height values. The text inputs except numerical values and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'option-tree' );
|
206 |
+
echo '<p>' . sprintf( $string, '<code>px</code>', '<code>%</code>', '<code>em</code>', '<code>pt</code>', '<code>ot_recognized_dimension_unit_types</code>' ) . '</p>'; // phpcs:ignore
|
207 |
+
|
208 |
+
echo '<h4>' . esc_html__( 'Gallery', 'option-tree' ) . ':</h4>';
|
209 |
+
echo '<p>' . esc_html__( 'The Gallery option type saves a comma separated list of image attachment IDs. You will need to create a front-end function to display the images in your theme.', 'option-tree' ) . '</p>';
|
210 |
+
|
211 |
+
echo '<h4>' . esc_html__( 'Google Fonts', 'option-tree' ) . ':</h4>';
|
212 |
+
|
213 |
+
/* translators: %1$s: HTML Document HEAD, %2$s: array key, %3$s: filter name, %4$s: parameter name, %5$s: parameter name, %6$s: parameter name, %7$s: function name*/
|
214 |
+
$string = esc_html__( 'The Google Fonts option type will dynamically enqueue any number of Google Web Fonts into the document %1$s. As well, once the option has been saved each font family will automatically be inserted into the %2$s array for the Typography option type. You can further modify the font stack by using the %3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s parameter is being passed from %7$s, so it will be the ID of a Typography option type. This will allow you to add additional web safe fonts to individual font families on an as-need basis.', 'option-tree' );
|
215 |
+
echo '<p>' . sprintf( $string, '<code>HEAD</code>', '<code>font-family</code>', '<code>ot_google_font_stack</code>', '<code>$font_stack</code>', '<code>$family</code>', '<code>$field_id</code>', '<code>ot_recognized_font_families</code>' ) . '</p>'; // phpcs:ignore
|
216 |
+
|
217 |
+
echo '<h4>' . esc_html__( 'JavaScript', 'option-tree' ) . ':</h4>';
|
218 |
+
|
219 |
+
/* translators: %s: file name */
|
220 |
+
$string = esc_html__( 'The JavaScript option type is a textarea that uses the %s code editor to highlight your JavaScript and display errors as you type.', 'option-tree' );
|
221 |
+
echo '<p>' . sprintf( $string, '<code>ace.js</code>' ) . '</p>'; // phpcs:ignore
|
222 |
+
|
223 |
+
echo '<h4>' . esc_html__( 'Link Color', 'option-tree' ) . ':</h4>';
|
224 |
+
echo '<p>' . esc_html__( 'The Link Color option type is used to set all link color states.', 'option-tree' ) . '</p>';
|
225 |
+
|
226 |
+
echo '<h4>' . esc_html__( 'List Item', 'option-tree' ) . ':</h4>';
|
227 |
+
echo '<p>' . esc_html__( 'The List Item option type replaced the Slider option type and allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'option-tree' ) . '</p>';
|
228 |
+
|
229 |
+
echo '<h4>' . esc_html__( 'Measurement', 'option-tree' ) . ':</h4>';
|
230 |
+
|
231 |
+
/* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name */
|
232 |
+
$string = esc_html__( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'option-tree' );
|
233 |
+
echo '<p>' . sprintf( $string, '<code>px</code>', '<code>%</code>', '<code>em</code>', '<code>pt</code>', '<code>ot_measurement_unit_types</code>' ) . '</p>'; // phpcs:ignore
|
234 |
+
|
235 |
+
/* translators: %s: file name */
|
236 |
+
$string = esc_html__( 'Example filter to add new units to the Measurement option type. Added to %s.', 'option-tree' );
|
237 |
+
echo '<p>' . sprintf( $string, '<code>functions.php</code>' ) . '</p>'; // phpcs:ignore
|
238 |
+
|
239 |
+
echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) {
|
240 |
|
241 |
/* only run the filter on measurement with a field ID of my_measurement */
|
242 |
if ( $field_id == \'my_measurement\' ) {
|
248 |
}
|
249 |
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
|
250 |
|
251 |
+
/* translators: %s: file name */
|
252 |
+
$string = esc_html__( 'Example filter to completely change the units in the Measurement option type. Added to %s.', 'option-tree' );
|
253 |
+
echo '<p>' . sprintf( $string, '<code>functions.php</code>' ) . '</p>'; // phpcs:ignore
|
254 |
+
|
255 |
+
echo '<pre><code>function filter_measurement_unit_types( $array, $field_id ) {
|
256 |
|
257 |
/* only run the filter on measurement with a field ID of my_measurement */
|
258 |
if ( $field_id == \'my_measurement\' ) {
|
265 |
return $array;
|
266 |
}
|
267 |
add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );</code></pre>';
|
268 |
+
|
269 |
+
echo '<h4>' . esc_html__( 'Numeric Slider', 'option-tree' ) . ':</h4>';
|
270 |
+
echo '<p>' . esc_html__( 'The Numeric Slider option type displays a jQuery UI slider. It will return a single numerical value for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
271 |
+
|
272 |
+
echo '<h4>' . esc_html__( 'On/Off', 'option-tree' ) . ':</h4>';
|
273 |
+
|
274 |
+
/* translators: %1$s: on value, %2$s: off value */
|
275 |
+
$string = esc_html__( 'The On/Off option type displays a simple switch that can be used to turn things on or off. The saved return value is either %1$s or %2$s.', 'option-tree' );
|
276 |
+
echo '<p>' . sprintf( $string, '<code>on</code>', '<code>off</code>' ) . '</p>'; // phpcs:ignore
|
277 |
+
|
278 |
+
echo '<h4>' . esc_html__( 'Page Checkbox', 'option-tree' ) . ':</h4>';
|
279 |
+
echo '<p>' . esc_html__( 'The Page Checkbox option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
280 |
+
|
281 |
+
echo '<h4>' . esc_html__( 'Page Select', 'option-tree' ) . ':</h4>';
|
282 |
+
echo '<p>' . esc_html__( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
283 |
+
|
284 |
+
echo '<h4>' . esc_html__( 'Post Checkbox', 'option-tree' ) . ':</h4>';
|
285 |
+
echo '<p>' . esc_html__( 'The Post Checkbox option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
286 |
+
|
287 |
+
echo '<h4>' . esc_html__( 'Post Select', 'option-tree' ) . ':</h4>';
|
288 |
+
echo '<p>' . esc_html__( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
289 |
+
|
290 |
+
echo '<h4>' . esc_html__( 'Radio', 'option-tree' ) . ':</h4>';
|
291 |
+
echo '<p>' . esc_html__( 'The Radio option type displays a group of choices. It allows the user to choose one and will return that value as a string for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
292 |
+
|
293 |
+
echo '<h4>' . esc_html__( 'Radio Image', 'option-tree' ) . ':</h4>';
|
294 |
+
|
295 |
+
/* translators: %s: filter name */
|
296 |
+
$string = esc_html__( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using %s. As well, you can add your own custom images using the choices array.', 'option-tree' );
|
297 |
+
echo '<p>' . sprintf( $string, '<code>ot_radio_images</code>' ) . '</p>'; // phpcs:ignore
|
298 |
+
|
299 |
+
/* translators: %1$s: filter name, %2$s: field name, %3$s: file name */
|
300 |
+
$string = esc_html__( 'This example executes the %1$s filter on layout images attached to the %2$s field. Added to %3$s.', 'option-tree' );
|
301 |
+
echo '<p>' . sprintf( $string, '<code>ot_radio_images</code>', '<code>my_radio_images</code>', '<code>functions.php</code>' ) . '</p>'; // phpcs:ignore
|
302 |
+
|
303 |
+
echo '<pre><code>function filter_radio_images( $array, $field_id ) {
|
304 |
|
305 |
/* only run the filter where the field ID is my_radio_images */
|
306 |
if ( $field_id == \'my_radio_images\' ) {
|
322 |
|
323 |
}
|
324 |
add_filter( \'ot_radio_images\', \'filter_radio_images\', 10, 2 );</code></pre>';
|
325 |
+
|
326 |
+
echo '<h4>' . esc_html__( 'Select', 'option-tree' ) . ':</h4>';
|
327 |
+
echo '<p>' . esc_html__( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'option-tree' ) . '</p>';
|
328 |
+
|
329 |
+
echo '<h4>' . esc_html__( 'Sidebar Select', 'option-tree' ) . ':</h4>';
|
330 |
+
|
331 |
+
/* translators: %1$s: filter name, %2$s: dynamic filter name with field_id */
|
332 |
+
$string = esc_html__( 'This option type makes it possible for users to select a WordPress registered sidebar to use on a specific area. By using the two provided filters, %1$s, and %2$s we can be selective about which sidebars are available on a specific content area.', 'option-tree' );
|
333 |
+
echo '<p>' . sprintf( $string, '<code>ot_recognized_sidebars</code>', '<code>ot_recognized_sidebars_{$field_id}</code>' ) . '</p>'; // phpcs:ignore
|
334 |
+
|
335 |
+
/* translators: %s: dynamic sidebar name */
|
336 |
+
$string = esc_html__( 'For example, if we create a WordPress theme that provides the ability to change the Blog Sidebar and we don\'t want to have the footer sidebars available on this area, we can unset those sidebars either manually or by using a regular expression if we have a common name like %s.', 'option-tree' );
|
337 |
+
echo '<p>' . sprintf( $string, '<code>footer-sidebar-$i</code>' ) . '</p>'; // phpcs:ignore
|
338 |
+
|
339 |
+
echo '<h4>' . esc_html__( 'Slider', 'option-tree' ) . ':</h4>';
|
340 |
+
echo '<p>' . esc_html__( 'The Slider option type is technically deprecated. Use the List Item option type instead, as it\'s infinitely more customizable. Typical use is for creating sliding image content.', 'option-tree' ) . '</p>';
|
341 |
+
|
342 |
+
echo '<h4>' . esc_html__( 'Social Links', 'option-tree' ) . ':</h4>';
|
343 |
+
|
344 |
+
/* translators: %1$s: filter name, %2$s: boolean value, %3$s: filter name, %4$s: filter name */
|
345 |
+
$string = esc_html__( 'The Social Links option type utilizes a drag & drop interface to create a list of social links. There are a few filters that make extending this option type easy. You can set the %1$s filter to %2$s and turn off loading default values. Use the %3$s filter to change the default values that are loaded. To filter the settings array use the %4$s filter.', 'option-tree' );
|
346 |
+
echo '<p>' . sprintf( $string, '<code>ot_type_social_links_load_defaults</code>', '<code>false</code>', '<code>ot_type_social_links_defaults</code>', '<code>ot_social_links_settings</code>' ) . '</p>'; // phpcs:ignore
|
347 |
+
|
348 |
+
echo '<h4>' . esc_html__( 'Spacing', 'option-tree' ) . ':</h4>';
|
349 |
+
|
350 |
+
/* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name */
|
351 |
+
$string = esc_html__( 'The Spacing option type is used to set spacing values such as padding or margin in the form of top, right, bottom, and left. The text inputs except numerical values and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'option-tree' );
|
352 |
+
echo '<p>' . sprintf( $string, '<code>px</code>', '<code>%</code>', '<code>em</code>', '<code>pt</code>', '<code>ot_recognized_spacing_unit_types</code>' ) . '</p>'; // phpcs:ignore
|
353 |
+
|
354 |
+
echo '<h4>' . esc_html__( 'Tab', 'option-tree' ) . ':</h4>';
|
355 |
+
echo '<p>' . esc_html__( 'The Tab option type will break a section or metabox into tabbed content.', 'option-tree' ) . '</p>';
|
356 |
+
|
357 |
+
echo '<h4>' . esc_html__( 'Tag Checkbox', 'option-tree' ) . ':</h4>';
|
358 |
+
echo '<p>' . esc_html__( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
359 |
+
|
360 |
+
echo '<h4>' . esc_html__( 'Tag Select', 'option-tree' ) . ':</h4>';
|
361 |
+
echo '<p>' . esc_html__( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
362 |
+
|
363 |
+
echo '<h4>' . esc_html__( 'Taxonomy Checkbox', 'option-tree' ) . ':</h4>';
|
364 |
+
echo '<p>' . esc_html__( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
365 |
+
|
366 |
+
echo '<h4>' . esc_html__( 'Taxonomy Select', 'option-tree' ) . ':</h4>';
|
367 |
+
echo '<p>' . esc_html__( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '</p>';
|
368 |
+
|
369 |
+
echo '<h4>' . esc_html__( 'Text', 'option-tree' ) . ':</h4>';
|
370 |
+
echo '<p>' . esc_html__( 'The Text option type is used to save string values. For example, any optional or required text that is of reasonably short character length.', 'option-tree' ) . '</p>';
|
371 |
+
|
372 |
+
echo '<h4>' . esc_html__( 'Textarea', 'option-tree' ) . ':</h4>';
|
373 |
+
|
374 |
+
/* translators: %1$s: filter name, %2$s: filter name, %3$s: filter name, %4$s: filter name */
|
375 |
+
$string = esc_html__( 'The Textarea option type is a large string value used for custom code or text in the theme and has a WYSIWYG editor that can be filtered to change the how it is displayed. For example, you can filter %1$s, %2$s, %3$s, and %4$s.', 'option-tree' );
|
376 |
+
echo '<p>' . sprintf( $string, '<code>wpautop</code>', '<code>media_buttons</code>', '<code>tinymce</code>', '<code>quicktags</code>' ) . '</p>'; // phpcs:ignore
|
377 |
+
|
378 |
+
/* translators: %s: file name */
|
379 |
+
$string = esc_html__( 'Example filters to alter the Textarea option type. Added to %s.', 'option-tree' );
|
380 |
+
echo '<p class="aside">' . sprintf( $string, '<code>functions.php</code>' ) . '</p>'; // phpcs:ignore
|
381 |
+
|
382 |
+
/* translators: %1$s: filter name, %2$s: boolean value, %3$s: paragraph tag */
|
383 |
+
$string = esc_html__( 'This example keeps WordPress from executing the %1$s filter on the line breaks. The default is %2$s which means it wraps line breaks with an HTML %3$s tag.', 'option-tree' );
|
384 |
+
echo '<p>' . sprintf( $string, '<code>wpautop</code>', '<code>true</code>', '<code>p</code>' ) . '</p>'; // phpcs:ignore
|
385 |
+
|
386 |
+
echo '<pre><code>function filter_textarea_wpautop( $content, $field_id ) {
|
387 |
|
388 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
389 |
if ( $field_id == \'my_textarea\' ) {
|
395 |
}
|
396 |
add_filter( \'ot_wpautop\', \'filter_textarea_wpautop\', 10, 2 );</code></pre>';
|
397 |
|
398 |
+
/* translators: %1$s: filter name, %2$s: boolean value */
|
399 |
+
$string = esc_html__( 'This example keeps WordPress from executing the %1$s filter on the textarea WYSIWYG. The default is %2$s which means show the buttons.', 'option-tree' );
|
400 |
+
echo '<p>' . sprintf( $string, '<code>media_buttons</code>', '<code>true</code>' ) . '</p>'; // phpcs:ignore
|
401 |
+
|
402 |
+
echo '<pre><code>function filter_textarea_media_buttons( $content, $field_id ) {
|
403 |
|
404 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
405 |
if ( $field_id == \'my_textarea\' ) {
|
410 |
|
411 |
}
|
412 |
add_filter( \'ot_media_buttons\', \'filter_textarea_media_buttons\', 10, 2 );</code></pre>';
|
413 |
+
|
414 |
+
/* translators: %1$s: filter name, %2$s: boolean value */
|
415 |
+
$string = esc_html__( 'This example keeps WordPress from executing the %1$s filter on the textarea WYSIWYG. The default is %2$s which means show the tinymce.', 'option-tree' );
|
416 |
+
echo '<p>' . sprintf( $string, '<code>tinymce</code>', '<code>true</code>' ) . '</p>'; // phpcs:ignore
|
417 |
+
|
418 |
+
echo '<pre><code>function filter_textarea_tinymce( $content, $field_id ) {
|
419 |
|
420 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
421 |
if ( $field_id == \'my_textarea\' ) {
|
427 |
}
|
428 |
add_filter( \'ot_tinymce\', \'filter_textarea_tinymce\', 10, 2 );</code></pre>';
|
429 |
|
430 |
+
/* translators: %1$s: filter name, %2$s: tags list */
|
431 |
+
$string = esc_html__( 'This example alters the %1$s filter on the textarea WYSIWYG. The default is %2$s which means show those quicktags. It also means you can filter in your own custom quicktags.', 'option-tree' );
|
432 |
+
echo '<p>' . sprintf( $string, '<code>quicktags</code>', '<code>array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close\' )</code>' ) . '</p>'; // phpcs:ignore
|
433 |
+
echo '<pre><code>function filter_textarea_quicktags( $content, $field_id ) {
|
434 |
|
435 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
436 |
if ( $field_id == \'my_textarea\' ) {
|
444 |
}
|
445 |
add_filter( \'ot_quicktags\', \'filter_textarea_quicktags\', 10, 1 );</code></pre>';
|
446 |
|
447 |
+
echo '<h4>' . esc_html__( 'Textarea Simple', 'option-tree' ) . ':</h4>';
|
448 |
+
echo '<p>' . esc_html__( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The Textarea Simple does not have a WYSIWYG editor.', 'option-tree' ) . '</p>';
|
449 |
+
|
450 |
+
/* translators: %1$s: function name, %2$s: boolean value, %3$s: paragraph tag, %4$s: file name */
|
451 |
+
$string = esc_html__( 'This example tells WordPress to execute the %1$s filter on the line breaks. The default is %2$s which means it does not wraps line breaks with an HTML %3$s tag. Added to %4$s.', 'option-tree' );
|
452 |
+
echo '<p class="aside">' . sprintf( $string, '<code>wpautop</code>', '<code>false</code>', '<code>p</code>', '<code>functions.php</code>' ) . '</p>'; // phpcs:ignore
|
453 |
+
echo '<pre><code>function filter_textarea_simple_wpautop( $content, $field_id ) {
|
454 |
|
455 |
/* only run the filter on the textarea with a field ID of my_textarea */
|
456 |
if ( $field_id == \'my_textarea\' ) {
|
461 |
|
462 |
}
|
463 |
add_filter( \'ot_wpautop\', \'filter_textarea_simple_wpautop\', 10, 2 );</code></pre>';
|
464 |
+
|
465 |
+
echo '<h4>' . esc_html__( 'Textblock', 'option-tree' ) . ':</h4>';
|
466 |
+
echo '<p>' . esc_html__( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML, but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'option-tree' ) . '</p>';
|
467 |
+
|
468 |
+
echo '<h4>' . esc_html__( 'Textblock Titled', 'option-tree' ) . ':</h4>';
|
469 |
+
echo '<p>' . esc_html__( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML, and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'option-tree' ) . '</p>';
|
470 |
+
|
471 |
+
echo '<h4>' . esc_html__( 'Typography', 'option-tree' ) . ':</h4>';
|
472 |
+
|
473 |
+
/* translators: %1$s: function name, %2$s: filter name, %3$s: filter name list */
|
474 |
+
$string = esc_html__( 'The Typography option type is for adding typography styles to your theme either dynamically via the CSS option type above or manually with %1$s. The Typography option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'option-tree' );
|
475 |
+
echo '<p>' . sprintf( $string, '<code>ot_get_option()</code>', '<code>ot_recognized_typography_fields</code>', '<code>ot_recognized_font_families</code>, <code>ot_recognized_font_sizes</code>, <code>ot_recognized_font_styles</code>, <code>ot_recognized_font_variants</code>, <code>ot_recognized_font_weights</code>, <code>ot_recognized_letter_spacing</code>, <code>ot_recognized_line_heights</code>, <code>ot_recognized_text_decorations</code> ' . esc_html__( 'and', 'option-tree' ) . ' <code>ot_recognized_text_transformations</code>' ) . '</p>'; // phpcs:ignore
|
476 |
+
|
477 |
+
echo '<p class="aside">' . esc_html__( 'This example would filter <code>ot_recognized_font_families</code> to build your own font stack. Added to <code>functions.php</code>.', 'option-tree' ) . '</p>';
|
478 |
+
echo '<pre><code>function filter_ot_recognized_font_families( $array, $field_id ) {
|
479 |
|
480 |
/* only run the filter when the field ID is my_google_fonts_headings */
|
481 |
if ( $field_id == \'my_google_fonts_headings\' ) {
|
491 |
}
|
492 |
add_filter( \'ot_recognized_font_families\', \'filter_ot_recognized_font_families\', 10, 2 );</code></pre>';
|
493 |
|
494 |
+
echo '<h4>' . esc_html__( 'Upload', 'option-tree' ) . ':</h4>';
|
495 |
+
|
496 |
+
/* translators: %1$s: button text, %2$s: the FTP protocol */
|
497 |
+
$string = esc_html__( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "%1$s" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You will have to re-upload or %2$s any media to your new server and change the URIs if necessary.', 'option-tree' );
|
498 |
+
echo '<p>' . sprintf( $string, esc_html( apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ) ), 'FTP' ) . '</p>'; // phpcs:ignore
|
499 |
+
|
500 |
+
echo '</div>';
|
501 |
+
|
502 |
+
echo '</div>';
|
503 |
+
}
|
504 |
}
|
505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
if ( ! function_exists( 'ot_type_ot_get_option' ) ) {
|
507 |
+
|
508 |
+
/**
|
509 |
+
* The ot_get_option() option type.
|
510 |
+
*
|
511 |
+
* This is a callback function to display text about ot_get_option().
|
512 |
+
*
|
513 |
+
* @access public
|
514 |
+
* @since 2.0
|
515 |
+
*/
|
516 |
+
function ot_type_ot_get_option() {
|
517 |
+
|
518 |
+
// Format setting outer wrapper.
|
519 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
520 |
+
|
521 |
+
// Description.
|
522 |
+
echo '<div class="description">';
|
523 |
+
|
524 |
+
echo '<h4>' . esc_html__( 'Description', 'option-tree' ) . ':</h4>';
|
525 |
+
|
526 |
+
echo '<p>' . esc_html__( 'This function returns a value from the "option_tree" array of saved values or the default value supplied. The returned value would be mixed. Meaning it could be a string, integer, boolean, or array.', 'option-tree' ) . '</p>';
|
527 |
+
|
528 |
+
echo '<h4>' . esc_html__( 'Usage', 'option-tree' ) . ':</h4>';
|
529 |
+
|
530 |
+
echo '<p><code><?php ot_get_option( $option_id, $default ); ?></code></p>';
|
531 |
+
|
532 |
+
echo '<h4>' . esc_html__( 'Parameters', 'option-tree' ) . ':</h4>';
|
533 |
+
|
534 |
+
echo '<code>$option_id</code>';
|
535 |
+
|
536 |
+
echo '<p>(<em>' . esc_html__( 'string', 'option-tree' ) . '</em>) (<em>' . esc_html__( 'required', 'option-tree' ) . '</em>) ' . esc_html__( 'Enter the options unique identifier.', 'option-tree' ) . '<br />' . esc_html__( 'Default:', 'option-tree' ) . ' <em>' . esc_html__( 'None', 'option-tree' ) . '</em></p>';
|
537 |
+
|
538 |
+
echo '<code>$default</code>';
|
539 |
+
|
540 |
+
echo '<p>(<em>' . esc_html__( 'string', 'option-tree' ) . '</em>) (<em>' . esc_html__( 'optional', 'option-tree' ) . '</em>) ' . esc_html__( 'Enter a default return value. This is just incase the request returns null.', 'option-tree' ) . '<br />' . esc_html__( 'Default', 'option-tree' ) . ': <em>' . esc_html__( 'None', 'option-tree' ) . '</em></p>';
|
541 |
+
|
542 |
+
echo '</div>';
|
543 |
+
|
544 |
+
echo '</div>';
|
545 |
+
}
|
546 |
}
|
547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
if ( ! function_exists( 'ot_type_get_option_tree' ) ) {
|
549 |
+
|
550 |
+
/**
|
551 |
+
* The get_option_tree() option type.
|
552 |
+
*
|
553 |
+
* This is a callback function to display text about get_option_tree().
|
554 |
+
*
|
555 |
+
* @access public
|
556 |
+
* @since 2.0
|
557 |
+
*/
|
558 |
+
function ot_type_get_option_tree() {
|
559 |
+
|
560 |
+
// Format setting outer wrapper.
|
561 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
562 |
+
|
563 |
+
// Description.
|
564 |
+
echo '<div class="description">';
|
565 |
+
|
566 |
+
echo '<p class="deprecated">' . esc_html__( 'This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement.', 'option-tree' ) . '</p>';
|
567 |
+
|
568 |
+
echo '<p>' . esc_html__( 'Use', 'option-tree' ) . '<code>ot_get_option()</code>' . esc_html__( 'instead', 'option-tree' ) . '.</p>';
|
569 |
+
|
570 |
+
echo '<h4>' . esc_html__( 'Description', 'option-tree' ) . ':</h4>';
|
571 |
+
|
572 |
+
echo '<p>' . esc_html__( 'This function returns, or echos if asked, a value from the "option_tree" array of saved values.', 'option-tree' ) . '</p>';
|
573 |
+
|
574 |
+
echo '<h4>' . esc_html__( 'Usage', 'option-tree' ) . ':</h4>';
|
575 |
+
|
576 |
+
echo '<p><code><?php get_option_tree( $item_id, $options, $echo, $is_array, $offset ); ?></code></p>';
|
577 |
+
|
578 |
+
echo '<h4>' . esc_html__( 'Parameters', 'option-tree' ) . ':</h4>';
|
579 |
+
|
580 |
+
echo '<code>$item_id</code>';
|
581 |
+
|
582 |
+
echo '<p>(<em>' . esc_html__( 'string', 'option-tree' ) . '</em>) (<em>' . esc_html__( 'required', 'option-tree' ) . '</em>) ' . esc_html__( 'Enter a unique Option Key to get a returned value or array.', 'option-tree' ) . '<br />' . esc_html__( 'Default:', 'option-tree' ) . ' <em>' . esc_html__( 'None', 'option-tree' ) . '</em></p>';
|
583 |
+
|
584 |
+
echo '<code>$options</code>';
|
585 |
+
|
586 |
+
echo '<p>(<em>' . esc_html__( 'array', 'option-tree' ) . '</em>) (<em>' . esc_html__( 'optional', 'option-tree' ) . '</em>) ' . esc_html__( 'Used to cut down on database queries in template files.', 'option-tree' ) . '<br />' . esc_html__( 'Default', 'option-tree' ) . ': <em>' . esc_html__( 'None', 'option-tree' ) . '</em></p>';
|
587 |
+
|
588 |
+
echo '<code>$echo</code>';
|
589 |
+
|
590 |
+
echo '<p>(<em>' . esc_html__( 'boolean', 'option-tree' ) . '</em>) (<em>' . esc_html__( 'optional', 'option-tree' ) . '</em>) ' . esc_html__( 'Echo the output.', 'option-tree' ) . '<br />' . esc_html__( 'Default', 'option-tree' ) . ': FALSE</p>';
|
591 |
+
|
592 |
+
echo '<code>$is_array</code>';
|
593 |
+
|
594 |
+
echo '<p>(<em>' . esc_html__( 'boolean', 'option-tree' ) . '</em>) (<em>' . esc_html__( 'optional', 'option-tree' ) . '</em>) ' . esc_html__( 'Used to indicate the $item_id is an array of values.', 'option-tree' ) . '<br />' . esc_html__( 'Default', 'option-tree' ) . ': FALSE</p>';
|
595 |
+
|
596 |
+
echo '<code>$offset</code>';
|
597 |
+
|
598 |
+
echo '<p>(<em>' . esc_html__( 'integer', 'option-tree' ) . '</em>) (<em>' . esc_html__( 'optional', 'option-tree' ) . '</em>) ' . esc_html__( 'Numeric offset key for the $item_id array, -1 will return all values (an array starts at 0).', 'option-tree' ) . '<br />' . esc_html__( 'Default', 'option-tree' ) . ': -1</p>';
|
599 |
+
|
600 |
+
echo '</div>';
|
601 |
+
|
602 |
+
echo '</div>';
|
603 |
+
}
|
604 |
}
|
605 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
if ( ! function_exists( 'ot_type_examples' ) ) {
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Examples option type.
|
610 |
+
*
|
611 |
+
* @access public
|
612 |
+
* @since 2.0
|
613 |
+
*/
|
614 |
+
function ot_type_examples() {
|
615 |
+
|
616 |
+
// Format setting outer wrapper.
|
617 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
618 |
+
|
619 |
+
// Description.
|
620 |
+
echo '<div class="description">';
|
621 |
+
|
622 |
+
/* translators: %1$s: function name, %2$s: emphasis on not, %3$s: function name, %4$s: function name */
|
623 |
+
$string = esc_html__( 'If you\'re using the plugin version of OptionTree it is highly recommended to include a %1$s check in your code, as described in the examples below. If you\'ve integrated OptionTree directly into your themes root directory, you will %2$s need to wrap your code with %3$s, as you\'re guaranteed to have the %4$s function available.', 'option-tree' );
|
624 |
+
echo '<p class="aside">' . sprintf( $string, '<code>function_exists</code>', '<strong>' . esc_html__( 'not', 'option-tree' ) . '</strong>', '<code>function_exists</code>', '<code>ot_get_option()</code>' ) . '</p>'; // phpcs:ignore
|
625 |
+
|
626 |
+
echo '<h4>' . esc_html__( 'String Examples', 'option-tree' ) . ':</h4>';
|
627 |
+
|
628 |
+
/* translators: %s: option id */
|
629 |
+
$string = esc_html__( 'Returns the value of %s.', 'option-tree' );
|
630 |
+
echo '<p>' . sprintf( $string, '<code>test_input</code>' ) . '</p>'; // phpcs:ignore
|
631 |
+
|
632 |
+
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
633 |
$test_input = ot_get_option( \'test_input\' );
|
634 |
}</code></pre>';
|
635 |
|
636 |
+
/* translators: %s: option id */
|
637 |
+
$string = esc_html__( 'Returns the value of %s, but also has a default value if it returns empty.', 'option-tree' );
|
638 |
+
echo '<p>' . sprintf( $string, '<code>test_input</code>' ) . '</p>'; // phpcs:ignore
|
639 |
+
|
640 |
+
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
641 |
$test_input = ot_get_option( \'test_input\', \'default input value goes here.\' );
|
642 |
}</code></pre>';
|
|
|
|
|
|
|
|
|
643 |
|
644 |
+
echo '<h4>' . esc_html__( 'Array Examples', 'option-tree' ) . ':</h4>';
|
645 |
+
|
646 |
+
/* translators: %1$s: option id, %2$s: variable name, %3$s: function name */
|
647 |
+
$string = esc_html__( 'Assigns the value of %1$s to the variable %2$s. It then echos an unordered list of links (navigation) using %3$s.', 'option-tree' );
|
648 |
+
echo '<p>' . sprintf( $string, '<code>navigation_ids</code>', '<code>$ids</code>', '<code>wp_list_pages()</code>' ) . '</p>'; // phpcs:ignore
|
649 |
+
|
650 |
+
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
651 |
/* get an array of page id\'s */
|
652 |
$ids = ot_get_option( \'navigation_ids\', array() );
|
653 |
|
663 |
echo \'</ul>\';
|
664 |
}
|
665 |
|
666 |
+
}</code></pre>';
|
667 |
+
|
668 |
+
/* translators: %s: option type name */
|
669 |
+
$string = esc_html__( 'The next two examples demonstrate how to use the %s option type. The Measurement option type is an array with two key/value pairs. The first is the value of measurement and the second is the unit of measurement.', 'option-tree' );
|
670 |
+
echo '<p>' . sprintf( $string, '<strong>' . esc_html__( 'Measurement', 'option-tree' ) . '</strong>' ) . '</p>'; // phpcs:ignore
|
671 |
+
|
672 |
+
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
673 |
/* get the array */
|
674 |
$measurement = ot_get_option( \'measurement_option_type_id\' );
|
675 |
|
682 |
|
683 |
}</code></pre>';
|
684 |
|
685 |
+
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
686 |
/* get the array, and have a default just incase */
|
687 |
$measurement = ot_get_option( \'measurement_option_type_id\', array( \'10\', \'px\' ) );
|
688 |
|
691 |
echo implode( \'\', $measurement );
|
692 |
}
|
693 |
|
694 |
+
}</code></pre>';
|
695 |
+
|
696 |
+
echo '<p>' . esc_html__( 'This example displays a very basic slider loop.', 'option-tree' ) . '</p>';
|
697 |
+
|
698 |
+
echo '<pre><code>if ( function_exists( \'ot_get_option\' ) ) {
|
699 |
|
700 |
/* get the slider array */
|
701 |
$slides = ot_get_option( \'my_slider\', array() );
|
711 |
}
|
712 |
|
713 |
}</code></pre>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
714 |
|
715 |
+
echo '</div>';
|
716 |
+
|
717 |
+
echo '</div>';
|
718 |
+
}
|
719 |
+
}
|
|
|
|
|
|
|
720 |
if ( ! function_exists( 'ot_type_layouts_overview' ) ) {
|
721 |
+
|
722 |
+
/**
|
723 |
+
* Layouts Overview option type.
|
724 |
+
*
|
725 |
+
* @access public
|
726 |
+
* @since 2.0
|
727 |
+
*/
|
728 |
+
function ot_type_layouts_overview() {
|
729 |
+
|
730 |
+
// Format setting outer wrapper.
|
731 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
732 |
+
|
733 |
+
// Description.
|
734 |
+
echo '<div class="description">';
|
735 |
+
|
736 |
+
echo '<h4>' . esc_html__( 'It\'s Super Simple', 'option-tree' ) . '</h4>';
|
737 |
+
|
738 |
+
echo '<p>' . esc_html__( 'Layouts make your theme awesome! With theme options data that you can save/import/export you can package themes with different color variations, or make it easy to do A/B testing on text and so much more. Basically, you save a snapshot of your data as a layout.', 'option-tree' ) . '</p>';
|
739 |
+
|
740 |
+
echo '<p>' . esc_html__( 'Once you have created all your different layouts, or theme variations, you can save them to a separate text file for repackaging with your theme. Alternatively, you could just make different variations for yourself and change your theme with the click of a button, all without deleting your previous options data.', 'option-tree' ) . '</p>';
|
741 |
+
|
742 |
+
echo '<p class="aside">' . esc_html__( ' Adding a layout is ridiculously easy, follow these steps and you\'ll be on your way to having a WordPress super theme.', 'option-tree' ) . '</p>';
|
743 |
+
|
744 |
+
echo '<h4>' . esc_html__( 'For Developers', 'option-tree' ) . ':</h4>';
|
745 |
+
|
746 |
+
echo '<h5>' . esc_html__( 'Creating a Layout', 'option-tree' ) . ':</h5>';
|
747 |
+
echo '<ul class="docs-ul">';
|
748 |
+
|
749 |
+
/* translators: %s: visual path to the page */
|
750 |
+
$string = esc_html__( 'Go to the %s tab.', 'option-tree' );
|
751 |
+
echo '<li>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Layouts', 'option-tree' ) . '</code>' ) . '</li>'; // phpcs:ignore
|
752 |
+
echo '<li>' . esc_html__( 'Enter a name for your layout in the text field and hit "Save Layouts", you\'ve created your first layout.', 'option-tree' ) . '</li>';
|
753 |
+
echo '<li>' . esc_html__( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>';
|
754 |
+
echo '</ul>';
|
755 |
+
|
756 |
+
echo '<h5>' . esc_html__( 'Activating a Layout', 'option-tree' ) . ':</h5>';
|
757 |
+
echo '<ul class="docs-ul">';
|
758 |
+
|
759 |
+
/* translators: %s: visual path to the page */
|
760 |
+
$string = esc_html__( 'Go to the %s tab.', 'option-tree' );
|
761 |
+
echo '<li>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Layouts', 'option-tree' ) . '</code>' ) . '</li>'; // phpcs:ignore
|
762 |
+
echo '<li>' . esc_html__( 'Click on the activate layout button in the actions list.', 'option-tree' ) . '</li>';
|
763 |
+
echo '</ul>';
|
764 |
+
|
765 |
+
echo '<h5>' . esc_html__( 'Deleting a Layout', 'option-tree' ) . ':</h5>';
|
766 |
+
echo '<ul class="docs-ul">';
|
767 |
+
|
768 |
+
/* translators: %s: visual path to the page */
|
769 |
+
$string = esc_html__( 'Go to the %s tab.', 'option-tree' );
|
770 |
+
echo '<li>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Layouts', 'option-tree' ) . '</code>' ) . '</li>'; // phpcs:ignore
|
771 |
+
echo '<li>' . esc_html__( 'Click on the delete layout button in the actions list.', 'option-tree' ) . '</li>';
|
772 |
+
echo '</ul>';
|
773 |
+
|
774 |
+
echo '<h5>' . esc_html__( 'Edit Layout Data', 'option-tree' ) . ':</h5>';
|
775 |
+
echo '<ul class="docs-ul">';
|
776 |
+
|
777 |
+
/* translators: %s: visual path to the page */
|
778 |
+
$string = esc_html__( 'Go to the %s page.', 'option-tree' );
|
779 |
+
echo '<li>' . sprintf( $string, '<code>' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '</code>' ) . '</li>'; // phpcs:ignore
|
780 |
+
echo '<li>' . esc_html__( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>';
|
781 |
+
echo '<li>' . esc_html__( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '</li>';
|
782 |
+
echo '<li>' . esc_html__( 'If you want to edit a new layout, first create it then save your theme options.', 'option-tree' ) . '</li>';
|
783 |
+
echo '</ul>';
|
784 |
+
|
785 |
+
echo '<h4>' . esc_html__( 'End-Users Mode', 'option-tree' ) . ':</h4>';
|
786 |
+
|
787 |
+
echo '<h5>' . esc_html__( 'Creating a Layout', 'option-tree' ) . ':</h5>';
|
788 |
+
echo '<ul class="docs-ul">';
|
789 |
+
|
790 |
+
/* translators: %s: visual path to the page */
|
791 |
+
$string = esc_html__( 'Go to the %s page.', 'option-tree' );
|
792 |
+
echo '<li>' . sprintf( $string, '<code>' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '</code>' ) . '</li>'; // phpcs:ignore
|
793 |
+
echo '<li>' . esc_html__( 'Enter a name for your layout in the text field and hit "New Layout", you\'ve created your first layout.', 'option-tree' ) . '</li>';
|
794 |
+
echo '<li>' . esc_html__( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '</li>';
|
795 |
+
echo '</ul>';
|
796 |
+
|
797 |
+
echo '<h5>' . esc_html__( 'Activating a Layout', 'option-tree' ) . ':</h5>';
|
798 |
+
echo '<ul class="docs-ul">';
|
799 |
+
|
800 |
+
/* translators: %s: visual path to the page */
|
801 |
+
$string = esc_html__( 'Go to the %s page.', 'option-tree' );
|
802 |
+
echo '<li>' . sprintf( $string, '<code>' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '</code>' ) . '</li>'; // phpcs:ignore
|
803 |
+
echo '<li>' . esc_html__( 'Choose a layout from the select list and click the "Activate Layout" button.', 'option-tree' ) . '</li>';
|
804 |
+
echo '</ul>';
|
805 |
+
|
806 |
+
echo '<h5>' . esc_html__( 'Deleting a Layout', 'option-tree' ) . ':</h5>';
|
807 |
+
echo '<ul class="docs-ul">';
|
808 |
+
echo '<li>' . esc_html__( 'End-Users mode does not allow deleting layouts.', 'option-tree' ) . '</li>';
|
809 |
+
echo '</ul>';
|
810 |
+
|
811 |
+
echo '<h5>' . esc_html__( 'Edit Layout Data', 'option-tree' ) . ':</h5>';
|
812 |
+
echo '<ul class="docs-ul">';
|
813 |
+
|
814 |
+
/* translators: %s: visual path to the page */
|
815 |
+
$string = esc_html__( 'Go to the %s page.', 'option-tree' );
|
816 |
+
echo '<li>' . sprintf( $string, '<code>' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '</code>' ) . '</li>'; // phpcs:ignore
|
817 |
+
echo '<li>' . esc_html__( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '</li>';
|
818 |
+
echo '<li>' . esc_html__( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '</li>';
|
819 |
+
echo '</ul>';
|
820 |
+
|
821 |
+
echo '</div>';
|
822 |
+
|
823 |
+
echo '</div>';
|
824 |
+
}
|
825 |
}
|
826 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
if ( ! function_exists( 'ot_type_meta_boxes' ) ) {
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Meta Boxes option type.
|
831 |
+
*
|
832 |
+
* @access public
|
833 |
+
* @since 2.0
|
834 |
+
*/
|
835 |
+
function ot_type_meta_boxes() {
|
836 |
+
|
837 |
+
// Format setting outer wrapper.
|
838 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
839 |
+
|
840 |
+
// Description.
|
841 |
+
echo '<div class="description">';
|
842 |
+
|
843 |
+
echo '<h4>' . esc_html__( 'How-to-guide', 'option-tree' ) . '</h4>';
|
844 |
+
|
845 |
+
/* translators: %1$s: directory name, %2$s: directory name, %3$s: file type */
|
846 |
+
$string = esc_html__( 'There are a few simple steps you need to take in order to use OptionTree\'s built in Meta Box API. In the code below I\'ll show you a basic demo of how to create your very own custom meta box using any number of the option types you have at your disposal. If you would like to see some demo code, there is a directory named %1$s inside the %2$s directory that contains a file named %3$s you can reference.', 'option-tree' );
|
847 |
+
echo '<p>' . sprintf( $string, '<code>theme-mode</code>', '<code>assets</code>', '<code>demo-meta-boxes.php</code>' ) . '</p>'; // phpcs:ignore
|
848 |
+
|
849 |
+
echo '<p>' . esc_html__( 'It\'s important to note that Meta Boxes do not support WYSIWYG editors at this time and if you set one of your options to Textarea it will automatically revert to a Textarea Simple until a valid solution is found. WordPress released this statement regarding the wp_editor() function:', 'option-tree' ) . '</p>';
|
850 |
+
|
851 |
+
echo '<blockquote>' . esc_html__( 'Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page.', 'option-tree' ) . '</blockquote>';
|
852 |
+
|
853 |
+
echo '<h5>' . esc_html__( 'Create and include your custom meta boxes file.', 'option-tree' ) . '</h5>';
|
854 |
+
|
855 |
+
echo '<ul class="docs-ul">';
|
856 |
+
|
857 |
+
/* translators: %s: file name */
|
858 |
+
$string = esc_html__( 'Create a file and name it anything you want, maybe %s.', 'option-tree' );
|
859 |
+
echo '<li>' . sprintf( $string, '<code>meta-boxes.php</code>' ) . '</li>'; // phpcs:ignore
|
860 |
+
|
861 |
+
/* translators: %1$s: directory name, %2$s: file name */
|
862 |
+
$string = esc_html__( 'As well, you\'ll probably want to create a directory named %1$s to put your %2$s into which will help keep you file structure nice and tidy.', 'option-tree' );
|
863 |
+
echo '<li>' . sprintf( $string, '<code>includes</code>', '<code>meta-boxes.php</code>' ) . '</li>'; // phpcs:ignore
|
864 |
+
|
865 |
+
/* translators: %s: file name */
|
866 |
+
$string = esc_html__( 'Add the following code to your %s.', 'option-tree' );
|
867 |
+
echo '<li>' . sprintf( $string, '<code>functions.php</code>' ) . '</li>'; // phpcs:ignore
|
868 |
+
|
869 |
+
echo '</ul>';
|
870 |
+
|
871 |
+
echo '<pre><code>/**
|
872 |
* Meta Boxes
|
873 |
*/
|
874 |
require( trailingslashit( get_template_directory() ) . \'includes/meta-boxes.php\' );
|
875 |
</code></pre>';
|
876 |
+
|
877 |
+
echo '<ul class="docs-ul">';
|
878 |
+
|
879 |
+
/* translators: %1$s: file name, %2$s: hook type, %3$s: function name */
|
880 |
+
$string = esc_html__( 'Add a variation of the following code to your %1$s. You\'ll obviously need to fill it in with all your custom array values. It\'s important to note here that we use the %2$s filter because if you were to call the %3$s function before OptionTree was loaded the sky would fall on your head.', 'option-tree' );
|
881 |
+
echo '<li>' . sprintf( $string, '<code>meta-boxes.php</code>', '<code>admin_init</code>', '<code>ot_register_meta_box</code>' ) . '</li>'; // phpcs:ignore
|
882 |
+
|
883 |
+
echo '</ul>';
|
884 |
+
|
885 |
+
echo "<pre><code>/**
|
886 |
* Initialize the meta boxes.
|
887 |
*/
|
888 |
add_action( 'admin_init', 'custom_meta_boxes' );
|
911 |
|
912 |
ot_register_meta_box( $my_meta_box );
|
913 |
|
914 |
+
}</code></pre>";
|
915 |
+
|
916 |
+
echo '</div>';
|
917 |
+
|
918 |
+
echo '</div>';
|
919 |
+
}
|
|
|
|
|
920 |
}
|
921 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
922 |
if ( ! function_exists( 'ot_type_theme_mode' ) ) {
|
923 |
+
|
924 |
+
/**
|
925 |
+
* Theme Mode option type.
|
926 |
+
*
|
927 |
+
* @access public
|
928 |
+
* @since 2.0
|
929 |
+
*/
|
930 |
+
function ot_type_theme_mode() {
|
931 |
+
|
932 |
+
// Format setting outer wrapper.
|
933 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
934 |
+
|
935 |
+
// Description.
|
936 |
+
echo '<div class="description">';
|
937 |
+
|
938 |
+
echo '<h4>' . esc_html__( 'How-to-guide', 'option-tree' ) . '</h4>';
|
939 |
+
|
940 |
+
/* translators: %1$s: directory name, %2$s: directory name, %3$s: file type */
|
941 |
+
$string = esc_html__( 'There are a few simple steps you need to take in order to use OptionTree as a theme included module. In the code below I\'ll show you a basic demo of how to include the entire plugin as a module, which will allow you to have the most up-to-date version of OptionTree without ever needing to hack the core of the plugin. If you would like to see some demo code, there is a directory named %1$s inside the %2$s directory that contains a file named %3$s you can reference.', 'option-tree' );
|
942 |
+
echo '<p>' . sprintf( $string, '<code>theme-mode</code>', '<code>assets</code>', '<code>demo-theme-options.php</code>' ) . '</p>'; // phpcs:ignore
|
943 |
+
|
944 |
+
echo '<h5>' . esc_html__( 'Step 1: Include the plugin & turn on theme mode.', 'option-tree' ) . '</h5>';
|
945 |
+
|
946 |
+
echo '<ul class="docs-ul">';
|
947 |
+
|
948 |
+
/* translators: %1$s: directory name, %2$s: file type */
|
949 |
+
$string = esc_html__( 'Download the latest version of %1$s and unarchive the %2$s directory.', 'option-tree' );
|
950 |
+
echo '<li>' . sprintf( $string, '<a href="https://wordpress.org/plugins/option-tree/" rel="nofollow" target="_blank">' . esc_html__( 'OptionTree', 'option-tree' ) . '</a>', '<code>.zip</code>' ) . '</li>'; // phpcs:ignore
|
951 |
+
|
952 |
+
/* translators: %1$s: directory name, %2$s: directory path */
|
953 |
+
$string = esc_html__( 'Put the %1$s directory in the root of your theme. For example, the server path would be %2$s.', 'option-tree' );
|
954 |
+
echo '<li>' . sprintf( $string, '<code>option-tree</code>', '<code>/wp-content/themes/theme-name/option-tree/</code>' ) . '</li>'; // phpcs:ignore
|
955 |
+
|
956 |
+
/* translators: %s: file name */
|
957 |
+
$string = esc_html__( 'Add the following code to the beginning of your %s.', 'option-tree' );
|
958 |
+
echo '<li>' . sprintf( $string, '<code>functions.php</code>' ) . '</li>'; // phpcs:ignore
|
959 |
+
|
960 |
+
echo '</ul>';
|
961 |
+
|
962 |
+
echo '<pre><code>/**
|
963 |
* Required: set \'ot_theme_mode\' filter to true.
|
964 |
*/
|
965 |
add_filter( \'ot_theme_mode\', \'__return_true\' );
|
969 |
*/
|
970 |
require( trailingslashit( get_template_directory() ) . \'option-tree/ot-loader.php\' );
|
971 |
</code></pre>';
|
972 |
+
|
973 |
+
/* translators: %1$s: file name, %2$s: directory path */
|
974 |
+
$string = esc_html__( 'For a list of all the OptionTree UI display filters refer to the %1$s file found in the %2$s directory of this plugin. This file is the starting point for developing themes with Theme Mode.', 'option-tree' );
|
975 |
+
echo '<p>' . sprintf( $string, '<code>demo-functions.php</code>', '<code>/assets/theme-mode/</code>' ) . '</p>'; // phpcs:ignore
|
976 |
+
|
977 |
+
echo '<p class="aside">' . esc_html__( 'You now have OptionTree built into your theme and anytime an update is available replace the old version with the new one.', 'option-tree' ) . '</p>';
|
978 |
+
|
979 |
+
echo '<h5>' . esc_html__( 'Step 2: Create Theme Options without using the UI Builder.', 'option-tree' ) . '</h5>';
|
980 |
+
echo '<ul class="docs-ul">';
|
981 |
+
|
982 |
+
/* translators: %s: file name */
|
983 |
+
$string = esc_html__( 'Create a file and name it anything you want, maybe %s, or use the built in file export to create it for you. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' );
|
984 |
+
echo '<li>' . sprintf( $string, '<code>theme-options.php</code>' ) . '</li>'; // phpcs:ignore
|
985 |
+
|
986 |
+
/* translators: %1$s: directory name, %2$s: file name */
|
987 |
+
$string = esc_html__( 'As well, you\'ll probably want to create a directory named %1$s to put your %2$s into which will help keep you file structure nice and tidy.', 'option-tree' );
|
988 |
+
echo '<li>' . sprintf( $string, '<code>includes</code>', '<code>theme-options.php</code>' ) . '</li>'; // phpcs:ignore
|
989 |
+
|
990 |
+
/* translators: %s: file name */
|
991 |
+
$string = esc_html__( 'Add the following code to your %s.', 'option-tree' );
|
992 |
+
echo '<li>' . sprintf( $string, '<code>functions.php</code>' ) . '</li>'; // phpcs:ignore
|
993 |
+
|
994 |
+
echo '</ul>';
|
995 |
+
|
996 |
+
echo '<pre><code>/**
|
997 |
* Theme Options
|
998 |
*/
|
999 |
require( trailingslashit( get_template_directory() ) . \'includes/theme-options.php\' );
|
1000 |
</code></pre>';
|
1001 |
+
|
1002 |
+
echo '<ul class="docs-ul">';
|
1003 |
+
|
1004 |
+
/* translators: %s: file name */
|
1005 |
+
$string = esc_html__( 'Add a variation of the following code to your %s. You\'ll obviously need to fill it in with all your custom array values for contextual help (optional), sections (required), and settings (required).', 'option-tree' );
|
1006 |
+
echo '<li>' . sprintf( $string, '<code>theme-options.php</code>' ) . '</li>'; // phpcs:ignore
|
1007 |
+
|
1008 |
+
echo '</ul>';
|
1009 |
+
|
1010 |
+
echo '<p>' . esc_html__( 'The code below is a boilerplate to get your started. For a full list of the available option types click the "Option Types" tab above. Also a quick note, you don\'t need to put OptionTree in theme mode to manually create options but you will want to hide the docs and settings as each time you load the admin area the settings be written over with the code below if they\'ve changed in any way. However, this ensures your settings do not get tampered with by the end-user.', 'option-tree' ) . '</p>';
|
1011 |
+
|
1012 |
+
echo "<pre><code>/**
|
1013 |
* Initialize the options before anything else.
|
1014 |
*/
|
1015 |
add_action( 'init', 'custom_theme_options', 1 );
|
1159 |
|
1160 |
}
|
1161 |
</code></pre>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1162 |
|
1163 |
+
echo '</div>';
|
1164 |
+
|
1165 |
+
echo '</div>';
|
1166 |
+
}
|
1167 |
+
}
|
includes/ot-functions-option-types.php
CHANGED
@@ -1,3233 +1,3168 @@
|
|
1 |
-
<?php
|
2 |
/**
|
|
|
|
|
3 |
* Functions used to build each option type.
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
* All fields are required!
|
16 |
-
*
|
17 |
-
* @param array $args The array of arguments are as follows:
|
18 |
-
* @param string $type Type of option.
|
19 |
-
* @param string $field_id The field ID.
|
20 |
-
* @param string $field_name The field Name.
|
21 |
-
* @param mixed $field_value The field value is a string or an array of values.
|
22 |
-
* @param string $field_desc The field description.
|
23 |
-
* @param string $field_std The standard value.
|
24 |
-
* @param string $field_class Extra CSS classes.
|
25 |
-
* @param array $field_choices The array of option choices.
|
26 |
-
* @param array $field_settings The array of settings for a list item.
|
27 |
-
* @return string
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @since 2.0
|
31 |
-
*/
|
32 |
if ( ! function_exists( 'ot_display_by_type' ) ) {
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
-
/**
|
54 |
-
* Background option type.
|
55 |
-
*
|
56 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
57 |
-
*
|
58 |
-
* @param array An array of arguments.
|
59 |
-
* @return string
|
60 |
-
*
|
61 |
-
* @access public
|
62 |
-
* @since 2.0
|
63 |
-
*/
|
64 |
if ( ! function_exists( 'ot_type_background' ) ) {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
}
|
270 |
-
|
271 |
}
|
272 |
|
273 |
-
/**
|
274 |
-
* Border Option Type
|
275 |
-
*
|
276 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
277 |
-
*
|
278 |
-
* @param array The options arguments
|
279 |
-
* @return string The markup.
|
280 |
-
*
|
281 |
-
* @access public
|
282 |
-
* @since 2.5.0
|
283 |
-
*/
|
284 |
if ( ! function_exists( 'ot_type_border' ) ) {
|
285 |
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
/* build style dropdown */
|
340 |
-
if ( in_array( 'style', $ot_recognized_border_fields ) ) {
|
341 |
-
|
342 |
-
echo '<div class="ot-option-group ot-option-group--one-fourth">';
|
343 |
-
|
344 |
-
echo '<select name="' . esc_attr( $field_name ) . '[style]" id="' . esc_attr( $field_id ) . '-style" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
345 |
-
|
346 |
-
echo '<option value="">' . __( 'style', 'option-tree' ) . '</option>';
|
347 |
-
|
348 |
-
foreach ( ot_recognized_border_style_types( $field_id ) as $key => $style ) {
|
349 |
-
echo '<option value="' . esc_attr( $key ) . '"' . ( isset( $field_value['style'] ) ? selected( $field_value['style'], $key, false ) : '' ) . '>' . esc_attr( $style ) . '</option>';
|
350 |
-
}
|
351 |
-
|
352 |
-
echo '</select>';
|
353 |
-
|
354 |
-
echo '</div>';
|
355 |
-
|
356 |
-
}
|
357 |
-
|
358 |
-
/* build color */
|
359 |
-
if ( in_array( 'color', $ot_recognized_border_fields ) ) {
|
360 |
-
|
361 |
-
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
362 |
-
|
363 |
-
/* colorpicker JS */
|
364 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
365 |
-
|
366 |
-
/* set color */
|
367 |
-
$color = isset( $field_value['color'] ) ? esc_attr( $field_value['color'] ) : '';
|
368 |
-
|
369 |
-
/* input */
|
370 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '[color]" id="' . $field_id . '-picker" value="' . $color . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
371 |
-
|
372 |
-
echo '</div>';
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
echo '</div>';
|
377 |
-
|
378 |
-
echo '</div>';
|
379 |
-
|
380 |
-
}
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
}
|
383 |
|
384 |
-
/**
|
385 |
-
* Box Shadow Option Type
|
386 |
-
*
|
387 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
388 |
-
*
|
389 |
-
* @param array The options arguments
|
390 |
-
* @return string The markup.
|
391 |
-
*
|
392 |
-
* @access public
|
393 |
-
* @since 2.5.0
|
394 |
-
*/
|
395 |
if ( ! function_exists( 'ot_type_box_shadow' ) ) {
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
echo '</div>';
|
485 |
-
|
486 |
-
}
|
487 |
-
|
488 |
-
echo '</div>';
|
489 |
-
|
490 |
-
echo '</div>';
|
491 |
-
|
492 |
-
}
|
493 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
|
496 |
-
/**
|
497 |
-
* Category Checkbox option type.
|
498 |
-
*
|
499 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
500 |
-
*
|
501 |
-
* @param array An array of arguments.
|
502 |
-
* @return string
|
503 |
-
*
|
504 |
-
* @access public
|
505 |
-
* @since 2.0
|
506 |
-
*/
|
507 |
if ( ! function_exists( 'ot_type_category_checkbox' ) ) {
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
547 |
}
|
548 |
|
549 |
-
/**
|
550 |
-
* Category Select option type.
|
551 |
-
*
|
552 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
553 |
-
*
|
554 |
-
* @param array An array of arguments.
|
555 |
-
* @return string
|
556 |
-
*
|
557 |
-
* @access public
|
558 |
-
* @since 2.0
|
559 |
-
*/
|
560 |
if ( ! function_exists( 'ot_type_category_select' ) ) {
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
}
|
604 |
|
605 |
-
/**
|
606 |
-
* Checkbox option type.
|
607 |
-
*
|
608 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
609 |
-
*
|
610 |
-
* @param array An array of arguments.
|
611 |
-
* @return string
|
612 |
-
*
|
613 |
-
* @access public
|
614 |
-
* @since 2.0
|
615 |
-
*/
|
616 |
if ( ! function_exists( 'ot_type_checkbox' ) ) {
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
651 |
}
|
652 |
|
653 |
-
/**
|
654 |
-
* Colorpicker option type.
|
655 |
-
*
|
656 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
657 |
-
*
|
658 |
-
* @param array An array of arguments.
|
659 |
-
* @return string
|
660 |
-
*
|
661 |
-
* @access public
|
662 |
-
* @since 2.0
|
663 |
-
* @updated 2.2.0
|
664 |
-
*/
|
665 |
if ( ! function_exists( 'ot_type_colorpicker' ) ) {
|
666 |
-
|
667 |
-
function ot_type_colorpicker( $args = array() ) {
|
668 |
-
|
669 |
-
/* turns arguments array into variables */
|
670 |
-
extract( $args );
|
671 |
-
|
672 |
-
/* verify a description */
|
673 |
-
$has_desc = $field_desc ? true : false;
|
674 |
-
|
675 |
-
/* format setting outer wrapper */
|
676 |
-
echo '<div class="format-setting type-colorpicker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
677 |
-
|
678 |
-
/* description */
|
679 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
680 |
-
|
681 |
-
/* format setting inner wrapper */
|
682 |
-
echo '<div class="format-setting-inner">';
|
683 |
-
|
684 |
-
/* build colorpicker */
|
685 |
-
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
686 |
-
|
687 |
-
/* colorpicker JS */
|
688 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '"); });</script>';
|
689 |
-
|
690 |
-
/* set the default color */
|
691 |
-
$std = $field_std ? 'data-default-color="' . $field_std . '"' : '';
|
692 |
-
|
693 |
-
/* input */
|
694 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" ' . $std . ' />';
|
695 |
-
|
696 |
-
echo '</div>';
|
697 |
-
|
698 |
-
echo '</div>';
|
699 |
-
|
700 |
-
echo '</div>';
|
701 |
-
|
702 |
-
}
|
703 |
-
|
704 |
-
}
|
705 |
|
706 |
-
/**
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
718 |
|
719 |
-
|
|
|
720 |
|
721 |
-
|
722 |
-
|
723 |
|
724 |
-
|
|
|
725 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
726 |
}
|
727 |
|
728 |
-
/**
|
729 |
-
* CSS option type.
|
730 |
-
*
|
731 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
732 |
-
*
|
733 |
-
* @param array An array of arguments.
|
734 |
-
* @return string
|
735 |
-
*
|
736 |
-
* @access public
|
737 |
-
* @since 2.0
|
738 |
-
*/
|
739 |
if ( ! function_exists( 'ot_type_css' ) ) {
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
770 |
}
|
771 |
|
772 |
-
/**
|
773 |
-
* Custom Post Type Checkbox option type.
|
774 |
-
*
|
775 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
776 |
-
*
|
777 |
-
* @param array An array of arguments.
|
778 |
-
* @return string
|
779 |
-
*
|
780 |
-
* @access public
|
781 |
-
* @since 2.0
|
782 |
-
*/
|
783 |
if ( ! function_exists( 'ot_type_custom_post_type_checkbox' ) ) {
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
}
|
828 |
|
829 |
-
/**
|
830 |
-
* Custom Post Type Select option type.
|
831 |
-
*
|
832 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
833 |
-
*
|
834 |
-
* @param array An array of arguments.
|
835 |
-
* @return string
|
836 |
-
*
|
837 |
-
* @access public
|
838 |
-
* @since 2.0
|
839 |
-
*/
|
840 |
if ( ! function_exists( 'ot_type_custom_post_type_select' ) ) {
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
887 |
}
|
888 |
|
889 |
-
/**
|
890 |
-
* Date Picker option type.
|
891 |
-
*
|
892 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
893 |
-
*
|
894 |
-
* @param array An array of arguments.
|
895 |
-
* @return string
|
896 |
-
*
|
897 |
-
* @access public
|
898 |
-
* @since 2.3
|
899 |
-
*/
|
900 |
if ( ! function_exists( 'ot_type_date_picker' ) ) {
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
944 |
}
|
945 |
|
946 |
-
/**
|
947 |
-
* Date Time Picker option type.
|
948 |
-
*
|
949 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
950 |
-
*
|
951 |
-
* @param array An array of arguments.
|
952 |
-
* @return string
|
953 |
-
*
|
954 |
-
* @access public
|
955 |
-
* @since 2.3
|
956 |
-
*/
|
957 |
if ( ! function_exists( 'ot_type_date_time_picker' ) ) {
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1001 |
}
|
1002 |
|
1003 |
-
/**
|
1004 |
-
* Dimension Option Type
|
1005 |
-
*
|
1006 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1007 |
-
*
|
1008 |
-
* @param array The options arguments
|
1009 |
-
* @return string The markup.
|
1010 |
-
*
|
1011 |
-
* @access public
|
1012 |
-
* @since 2.5.0
|
1013 |
-
*/
|
1014 |
if ( ! function_exists( 'ot_type_dimension' ) ) {
|
1015 |
|
1016 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1017 |
|
1018 |
-
|
1019 |
-
|
1020 |
|
1021 |
-
|
1022 |
-
|
1023 |
|
1024 |
-
|
1025 |
-
|
1026 |
|
1027 |
-
|
1028 |
-
|
1029 |
|
1030 |
-
|
1031 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1032 |
|
1033 |
-
|
1034 |
-
|
1035 |
-
'width',
|
1036 |
-
'height',
|
1037 |
-
'unit'
|
1038 |
-
), $field_id );
|
1039 |
|
1040 |
-
|
1041 |
-
|
|
|
1042 |
|
1043 |
-
|
|
|
1044 |
|
1045 |
-
|
|
|
|
|
1046 |
|
1047 |
-
|
|
|
1048 |
|
1049 |
-
|
1050 |
-
if ( in_array( 'height', $ot_recognized_dimension_fields ) ) {
|
1051 |
|
1052 |
-
|
1053 |
|
1054 |
-
|
1055 |
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
if ( in_array( 'unit', $ot_recognized_dimension_fields ) ) {
|
1060 |
-
|
1061 |
-
echo '<div class="ot-option-group ot-option-group--one-third ot-option-group--is-last">';
|
1062 |
-
|
1063 |
-
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1064 |
-
|
1065 |
-
echo '<option value="">' . __( 'unit', 'option-tree' ) . '</option>';
|
1066 |
-
|
1067 |
-
foreach ( ot_recognized_dimension_unit_types( $field_id ) as $unit ) {
|
1068 |
-
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
echo '</select>';
|
1072 |
-
|
1073 |
-
echo '</div>';
|
1074 |
-
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
echo '</div>';
|
1078 |
|
1079 |
-
|
1080 |
|
1081 |
-
|
|
|
1082 |
|
|
|
|
|
|
|
|
|
1083 |
}
|
1084 |
|
1085 |
-
/**
|
1086 |
-
* Gallery option type.
|
1087 |
-
*
|
1088 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1089 |
-
*
|
1090 |
-
* @param array The options arguments
|
1091 |
-
* @return string The gallery metabox markup.
|
1092 |
-
*
|
1093 |
-
* @access public
|
1094 |
-
* @since 2.2.0
|
1095 |
-
*/
|
1096 |
if ( ! function_exists( 'ot_type_gallery' ) ) {
|
1097 |
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
preg_match( '/ids=\'(.*?)\'/', $field_value, $matches );
|
1125 |
-
|
1126 |
-
// Turn the field value into an array of IDs
|
1127 |
-
if ( isset( $matches[1] ) ) {
|
1128 |
-
|
1129 |
-
// Found the IDs in the shortcode
|
1130 |
-
$ids = explode( ',', $matches[1] );
|
1131 |
-
|
1132 |
-
} else {
|
1133 |
-
|
1134 |
-
// The string is only IDs
|
1135 |
-
$ids = ! empty( $field_value ) && $field_value != '' ? explode( ',', $field_value ) : array();
|
1136 |
-
|
1137 |
-
}
|
1138 |
-
|
1139 |
-
// Has attachment IDs
|
1140 |
-
if ( ! empty( $ids ) ) {
|
1141 |
-
|
1142 |
-
echo '<ul class="ot-gallery-list">';
|
1143 |
-
|
1144 |
-
foreach( $ids as $id ) {
|
1145 |
-
|
1146 |
-
if ( $id == '' )
|
1147 |
-
continue;
|
1148 |
-
|
1149 |
-
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
|
1150 |
-
|
1151 |
-
echo '<li><img src="' . $thumbnail[0] . '" width="75" height="75" /></li>';
|
1152 |
-
|
1153 |
-
}
|
1154 |
-
|
1155 |
-
echo '</ul>';
|
1156 |
-
|
1157 |
-
echo '
|
1158 |
-
<div class="ot-gallery-buttons">
|
1159 |
-
<a href="#" class="option-tree-ui-button button button-secondary hug-left ot-gallery-delete">' . __( 'Delete Gallery', 'option-tree' ) . '</a>
|
1160 |
-
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . __( 'Edit Gallery', 'option-tree' ) . '</a>
|
1161 |
-
</div>';
|
1162 |
-
|
1163 |
-
} else {
|
1164 |
-
|
1165 |
-
echo '
|
1166 |
-
<div class="ot-gallery-buttons">
|
1167 |
-
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . __( 'Create Gallery', 'option-tree' ) . '</a>
|
1168 |
-
</div>';
|
1169 |
-
|
1170 |
-
}
|
1171 |
-
|
1172 |
-
echo '</div>';
|
1173 |
-
|
1174 |
-
echo '</div>';
|
1175 |
-
|
1176 |
-
}
|
1177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1178 |
}
|
1179 |
|
1180 |
-
/**
|
1181 |
-
* Google Fonts option type.
|
1182 |
-
*
|
1183 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1184 |
-
*
|
1185 |
-
* @param array An array of arguments.
|
1186 |
-
* @return string
|
1187 |
-
*
|
1188 |
-
* @access public
|
1189 |
-
* @since 2.5.0
|
1190 |
-
*/
|
1191 |
if ( ! function_exists( 'ot_type_google_fonts' ) ) {
|
1192 |
-
|
1193 |
-
function ot_type_google_fonts( $args = array() ) {
|
1194 |
-
|
1195 |
-
/* turns arguments array into variables */
|
1196 |
-
extract( $args );
|
1197 |
-
|
1198 |
-
/* verify a description */
|
1199 |
-
$has_desc = $field_desc ? true : false;
|
1200 |
-
|
1201 |
-
/* format setting outer wrapper */
|
1202 |
-
echo '<div class="format-setting type-google-font ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1203 |
-
|
1204 |
-
/* description */
|
1205 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1206 |
-
|
1207 |
-
/* format setting inner wrapper */
|
1208 |
-
echo '<div class="format-setting-inner">';
|
1209 |
-
|
1210 |
-
/* allow fields to be filtered */
|
1211 |
-
$ot_recognized_google_fonts_fields = apply_filters( 'ot_recognized_google_font_fields', array(
|
1212 |
-
'variants',
|
1213 |
-
'subsets'
|
1214 |
-
), $field_id );
|
1215 |
-
|
1216 |
-
// Set a default to show at least one item.
|
1217 |
-
if ( ! is_array( $field_value ) || empty( $field_value ) ) {
|
1218 |
-
$field_value = array( array(
|
1219 |
-
'family' => '',
|
1220 |
-
'variants' => array(),
|
1221 |
-
'subsets' => array()
|
1222 |
-
) );
|
1223 |
-
}
|
1224 |
-
|
1225 |
-
foreach( $field_value as $key => $value ) {
|
1226 |
-
|
1227 |
-
echo '<div class="type-google-font-group">';
|
1228 |
-
|
1229 |
-
/* build font family */
|
1230 |
-
$family = isset( $value['family'] ) ? $value['family'] : '';
|
1231 |
-
echo '<div class="option-tree-google-font-family">';
|
1232 |
-
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . __( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . __( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1233 |
-
echo '<select name="' . esc_attr( $field_name ) . '[' . $key . '][family]" id="' . esc_attr( $field_id ) . '-' . $key . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1234 |
-
echo '<option value="">' . __( '-- Choose One --', 'option-tree' ) . '</option>';
|
1235 |
-
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1236 |
-
echo '<option value="' . esc_attr( $family_key ) . '" ' . selected( $family, $family_key, false ) . '>' . esc_html( $family_value ) . '</option>';
|
1237 |
-
}
|
1238 |
-
echo '</select>';
|
1239 |
-
echo '</div>';
|
1240 |
-
|
1241 |
-
/* build font variants */
|
1242 |
-
if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) {
|
1243 |
-
$variants = isset( $value['variants'] ) ? $value['variants'] : array();
|
1244 |
-
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . $key . '-" data-field-name="' . esc_attr( $field_name ) . '[' . $key . '][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1245 |
-
foreach ( ot_recognized_google_font_variants( $field_id, $family ) as $variant_key => $variant ) {
|
1246 |
-
echo '<p class="checkbox-wrap">';
|
1247 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . $key . '][variants][]" id="' . esc_attr( $field_id ) . '-' . $key . '-' . $variant . '" value="' . esc_attr( $variant ) . '" ' . checked( in_array( $variant, $variants ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1248 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . $key . '-' . $variant . '">' . esc_html( $variant ) . '</label>';
|
1249 |
-
echo '</p>';
|
1250 |
-
}
|
1251 |
-
echo '</div>';
|
1252 |
-
}
|
1253 |
-
|
1254 |
-
/* build font subsets */
|
1255 |
-
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) {
|
1256 |
-
$subsets = isset( $value['subsets'] ) ? $value['subsets'] : array();
|
1257 |
-
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . $key . '-" data-field-name="' . esc_attr( $field_name ) . '[' . $key . '][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1258 |
-
foreach ( ot_recognized_google_font_subsets( $field_id, $family ) as $subset_key => $subset ) {
|
1259 |
-
echo '<p class="checkbox-wrap">';
|
1260 |
-
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . $key . '][subsets][]" id="' . esc_attr( $field_id ) . '-' . $key . '-' . $subset . '" value="' . esc_attr( $subset ) . '" ' . checked( in_array( $subset, $subsets ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1261 |
-
echo '<label for="' . esc_attr( $field_id ) . '-' . $key . '-' . $subset . '">' . esc_html( $subset ) . '</label>';
|
1262 |
-
echo '</p>';
|
1263 |
-
}
|
1264 |
-
echo '</div>';
|
1265 |
-
}
|
1266 |
-
|
1267 |
-
echo '</div>';
|
1268 |
-
|
1269 |
-
}
|
1270 |
-
|
1271 |
-
echo '<div class="type-google-font-group-clone">';
|
1272 |
-
|
1273 |
-
/* build font family */
|
1274 |
-
echo '<div class="option-tree-google-font-family">';
|
1275 |
-
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . __( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . __( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1276 |
-
echo '<select name="' . esc_attr( $field_name ) . '[%key%][family]" id="' . esc_attr( $field_id ) . '-%key%" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1277 |
-
echo '<option value="">' . __( '-- Choose One --', 'option-tree' ) . '</option>';
|
1278 |
-
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1279 |
-
echo '<option value="' . esc_attr( $family_key ) . '">' . esc_html( $family_value ) . '</option>';
|
1280 |
-
}
|
1281 |
-
echo '</select>';
|
1282 |
-
echo '</div>';
|
1283 |
-
|
1284 |
-
/* build font variants */
|
1285 |
-
if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) {
|
1286 |
-
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1287 |
-
echo '</div>';
|
1288 |
-
}
|
1289 |
-
|
1290 |
-
/* build font subsets */
|
1291 |
-
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) {
|
1292 |
-
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1293 |
-
echo '</div>';
|
1294 |
-
}
|
1295 |
-
|
1296 |
-
echo '</div>';
|
1297 |
-
|
1298 |
-
echo '<a href="javascript:void(0);" class="js-add-google-font option-tree-ui-button button button-primary right hug-right" title="' . __( 'Add Google Font', 'option-tree' ) . '">' . __( 'Add Google Font', 'option-tree' ) . '</a>';
|
1299 |
-
|
1300 |
-
echo '</div>';
|
1301 |
-
|
1302 |
-
echo '</div>';
|
1303 |
-
|
1304 |
-
}
|
1305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1306 |
}
|
1307 |
|
1308 |
-
/**
|
1309 |
-
* JavaScript option type.
|
1310 |
-
*
|
1311 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1312 |
-
*
|
1313 |
-
* @param array An array of arguments.
|
1314 |
-
* @return string
|
1315 |
-
*
|
1316 |
-
* @access public
|
1317 |
-
* @since 2.5.0
|
1318 |
-
*/
|
1319 |
if ( ! function_exists( 'ot_type_javascript' ) ) {
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1350 |
}
|
1351 |
|
1352 |
-
/**
|
1353 |
-
* Link Color option type.
|
1354 |
-
*
|
1355 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1356 |
-
*
|
1357 |
-
* @param array The options arguments
|
1358 |
-
* @return string The markup.
|
1359 |
-
*
|
1360 |
-
* @access public
|
1361 |
-
* @since 2.5.0
|
1362 |
-
*/
|
1363 |
if ( ! function_exists( 'ot_type_link_color' ) ) {
|
1364 |
|
1365 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1366 |
|
1367 |
-
|
1368 |
-
|
1369 |
|
1370 |
-
|
1371 |
-
|
1372 |
|
1373 |
-
|
1374 |
-
|
1375 |
|
1376 |
-
|
1377 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1378 |
|
1379 |
-
|
1380 |
-
echo '<div class="format-setting-inner">';
|
1381 |
|
1382 |
-
|
1383 |
-
$ot_recognized_link_color_fields = apply_filters( 'ot_recognized_link_color_fields', array(
|
1384 |
-
'link' => _x( 'Standard', 'color picker', 'option-tree' ),
|
1385 |
-
'hover' => _x( 'Hover', 'color picker', 'option-tree' ),
|
1386 |
-
'active' => _x( 'Active', 'color picker', 'option-tree' ),
|
1387 |
-
'visited' => _x( 'Visited', 'color picker', 'option-tree' ),
|
1388 |
-
'focus' => _x( 'Focus', 'color picker', 'option-tree' )
|
1389 |
-
), $field_id );
|
1390 |
|
1391 |
-
|
1392 |
-
|
1393 |
|
1394 |
-
|
1395 |
-
|
1396 |
-
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
1397 |
|
1398 |
-
|
|
|
|
|
1399 |
|
1400 |
-
|
1401 |
-
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker-' . $type . '"); });</script>';
|
1402 |
|
1403 |
-
|
1404 |
-
$color = isset( $field_value[ $type ] ) ? esc_attr( $field_value[ $type ] ) : '';
|
1405 |
-
|
1406 |
-
/* set default color */
|
1407 |
-
$std = isset( $field_std[ $type ] ) ? 'data-default-color="' . $field_std[ $type ] . '"' : '';
|
1408 |
|
1409 |
-
|
1410 |
-
|
|
|
1411 |
|
1412 |
-
|
1413 |
|
1414 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1415 |
|
1416 |
-
|
|
|
1417 |
|
1418 |
-
|
|
|
1419 |
|
1420 |
-
|
|
|
|
|
|
|
1421 |
|
1422 |
-
|
|
|
1423 |
|
1424 |
-
|
|
|
1425 |
|
1426 |
-
|
1427 |
-
|
1428 |
-
*
|
1429 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1430 |
-
*
|
1431 |
-
* @param array An array of arguments.
|
1432 |
-
* @return string
|
1433 |
-
*
|
1434 |
-
* @access public
|
1435 |
-
* @since 2.0
|
1436 |
-
*/
|
1437 |
-
if ( ! function_exists( 'ot_type_list_item' ) ) {
|
1438 |
-
|
1439 |
-
function ot_type_list_item( $args = array() ) {
|
1440 |
-
|
1441 |
-
/* turns arguments array into variables */
|
1442 |
-
extract( $args );
|
1443 |
-
|
1444 |
-
/* verify a description */
|
1445 |
-
$has_desc = $field_desc ? true : false;
|
1446 |
-
|
1447 |
-
// Default
|
1448 |
-
$sortable = true;
|
1449 |
-
|
1450 |
-
// Check if the list can be sorted
|
1451 |
-
if ( ! empty( $field_class ) ) {
|
1452 |
-
$classes = explode( ' ', $field_class );
|
1453 |
-
if ( in_array( 'not-sortable', $classes ) ) {
|
1454 |
-
$sortable = false;
|
1455 |
-
str_replace( 'not-sortable', '', $field_class );
|
1456 |
-
}
|
1457 |
-
}
|
1458 |
-
|
1459 |
-
/* format setting outer wrapper */
|
1460 |
-
echo '<div class="format-setting type-list-item ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1461 |
-
|
1462 |
-
/* description */
|
1463 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1464 |
-
|
1465 |
-
/* format setting inner wrapper */
|
1466 |
-
echo '<div class="format-setting-inner">';
|
1467 |
-
|
1468 |
-
/* pass the settings array arround */
|
1469 |
-
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . ot_encode( serialize( $field_settings ) ) . '" />';
|
1470 |
-
|
1471 |
-
/**
|
1472 |
-
* settings pages have array wrappers like 'option_tree'.
|
1473 |
-
* So we need that value to create a proper array to save to.
|
1474 |
-
* This is only for NON metabox settings.
|
1475 |
-
*/
|
1476 |
-
if ( ! isset( $get_option ) )
|
1477 |
-
$get_option = '';
|
1478 |
-
|
1479 |
-
/* build list items */
|
1480 |
-
echo '<ul class="option-tree-setting-wrap' . ( $sortable ? ' option-tree-sortable' : '' ) .'" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
1481 |
-
|
1482 |
-
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
1483 |
-
|
1484 |
-
foreach( $field_value as $key => $list_item ) {
|
1485 |
-
|
1486 |
-
echo '<li class="ui-state-default list-list-item">';
|
1487 |
-
ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type );
|
1488 |
-
echo '</li>';
|
1489 |
-
|
1490 |
-
}
|
1491 |
-
|
1492 |
-
}
|
1493 |
-
|
1494 |
-
echo '</ul>';
|
1495 |
-
|
1496 |
-
/* button */
|
1497 |
-
echo '<a href="javascript:void(0);" class="option-tree-list-item-add option-tree-ui-button button button-primary right hug-right" title="' . __( 'Add New', 'option-tree' ) . '">' . __( 'Add New', 'option-tree' ) . '</a>';
|
1498 |
-
|
1499 |
-
/* description */
|
1500 |
-
$list_desc = $sortable ? __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) : '';
|
1501 |
-
echo '<div class="list-item-description">' . apply_filters( 'ot_list_item_description', $list_desc, $field_id ) . '</div>';
|
1502 |
-
|
1503 |
-
echo '</div>';
|
1504 |
-
|
1505 |
-
echo '</div>';
|
1506 |
-
|
1507 |
-
}
|
1508 |
-
|
1509 |
-
}
|
1510 |
|
1511 |
-
|
1512 |
-
* Measurement option type.
|
1513 |
-
*
|
1514 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1515 |
-
*
|
1516 |
-
* @param array An array of arguments.
|
1517 |
-
* @return string
|
1518 |
-
*
|
1519 |
-
* @access public
|
1520 |
-
* @since 2.0
|
1521 |
-
*/
|
1522 |
-
if ( ! function_exists( 'ot_type_measurement' ) ) {
|
1523 |
-
|
1524 |
-
function ot_type_measurement( $args = array() ) {
|
1525 |
-
|
1526 |
-
/* turns arguments array into variables */
|
1527 |
-
extract( $args );
|
1528 |
-
|
1529 |
-
/* verify a description */
|
1530 |
-
$has_desc = $field_desc ? true : false;
|
1531 |
-
|
1532 |
-
/* format setting outer wrapper */
|
1533 |
-
echo '<div class="format-setting type-measurement ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1534 |
-
|
1535 |
-
/* description */
|
1536 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1537 |
-
|
1538 |
-
/* format setting inner wrapper */
|
1539 |
-
echo '<div class="format-setting-inner">';
|
1540 |
-
|
1541 |
-
echo '<div class="option-tree-ui-measurement-input-wrap">';
|
1542 |
-
|
1543 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '[0]" id="' . esc_attr( $field_id ) . '-0" value="' . ( isset( $field_value[0] ) ? esc_attr( $field_value[0] ) : '' ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" />';
|
1544 |
-
|
1545 |
-
echo '</div>';
|
1546 |
-
|
1547 |
-
/* build measurement */
|
1548 |
-
echo '<select name="' . esc_attr( $field_name ) . '[1]" id="' . esc_attr( $field_id ) . '-1" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1549 |
-
|
1550 |
-
echo '<option value="">' . __( 'unit', 'option-tree' ) . '</option>';
|
1551 |
-
|
1552 |
-
foreach ( ot_measurement_unit_types( $field_id ) as $unit ) {
|
1553 |
-
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value[1] ) ? selected( $field_value[1], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1554 |
-
}
|
1555 |
-
|
1556 |
-
echo '</select>';
|
1557 |
-
|
1558 |
-
echo '</div>';
|
1559 |
-
|
1560 |
-
echo '</div>';
|
1561 |
-
|
1562 |
-
}
|
1563 |
-
|
1564 |
-
}
|
1565 |
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1570 |
-
*
|
1571 |
-
* @param array An array of arguments.
|
1572 |
-
* @return string
|
1573 |
-
*
|
1574 |
-
* @access public
|
1575 |
-
* @since 2.1
|
1576 |
-
*/
|
1577 |
-
if ( ! function_exists( 'ot_type_numeric_slider' ) ) {
|
1578 |
|
1579 |
-
|
1580 |
-
|
1581 |
-
/* turns arguments array into variables */
|
1582 |
-
extract( $args );
|
1583 |
-
|
1584 |
-
/* verify a description */
|
1585 |
-
$has_desc = $field_desc ? true : false;
|
1586 |
-
|
1587 |
-
$_options = explode( ',', $field_min_max_step );
|
1588 |
-
$min = isset( $_options[0] ) ? $_options[0] : 0;
|
1589 |
-
$max = isset( $_options[1] ) ? $_options[1] : 100;
|
1590 |
-
$step = isset( $_options[2] ) ? $_options[2] : 1;
|
1591 |
-
|
1592 |
-
/* format setting outer wrapper */
|
1593 |
-
echo '<div class="format-setting type-numeric-slider ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1594 |
-
|
1595 |
-
/* description */
|
1596 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
1597 |
-
|
1598 |
-
/* format setting inner wrapper */
|
1599 |
-
echo '<div class="format-setting-inner">';
|
1600 |
-
|
1601 |
-
echo '<div class="ot-numeric-slider-wrap">';
|
1602 |
-
|
1603 |
-
echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="ot-numeric-slider-hidden-input" value="' . esc_attr( $field_value ) . '" data-min="' . esc_attr( $min ) . '" data-max="' . esc_attr( $max ) . '" data-step="' . esc_attr( $step ) . '">';
|
1604 |
-
|
1605 |
-
echo '<input type="text" class="ot-numeric-slider-helper-input widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" value="' . esc_attr( $field_value ) . '" readonly>';
|
1606 |
-
|
1607 |
-
echo '<div id="ot_numeric_slider_' . esc_attr( $field_id ) . '" class="ot-numeric-slider"></div>';
|
1608 |
-
|
1609 |
-
echo '</div>';
|
1610 |
-
|
1611 |
-
echo '</div>';
|
1612 |
-
|
1613 |
-
echo '</div>';
|
1614 |
-
}
|
1615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1616 |
}
|
1617 |
|
1618 |
-
/**
|
1619 |
-
* On/Off option type
|
1620 |
-
*
|
1621 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1622 |
-
*
|
1623 |
-
* @param array The options arguments
|
1624 |
-
* @return string The gallery metabox markup.
|
1625 |
-
*
|
1626 |
-
* @access public
|
1627 |
-
* @since 2.2.0
|
1628 |
-
*/
|
1629 |
if ( ! function_exists( 'ot_type_on_off' ) ) {
|
1630 |
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1712 |
<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" onclick="">' . esc_attr( $choice['label'] ) . '</label>';
|
1713 |
-
|
1714 |
-
|
1715 |
-
echo '<span class="slide-button"></span>';
|
1716 |
|
1717 |
-
|
1718 |
|
1719 |
-
|
1720 |
|
1721 |
-
|
1722 |
|
1723 |
-
|
1724 |
|
|
|
1725 |
}
|
1726 |
|
1727 |
-
/**
|
1728 |
-
* Page Checkbox option type.
|
1729 |
-
*
|
1730 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1731 |
-
*
|
1732 |
-
* @param array An array of arguments.
|
1733 |
-
* @return string
|
1734 |
-
*
|
1735 |
-
* @access public
|
1736 |
-
* @since 2.0
|
1737 |
-
*/
|
1738 |
if ( ! function_exists( 'ot_type_page_checkbox' ) ) {
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1779 |
}
|
1780 |
|
1781 |
-
/**
|
1782 |
-
* Page Select option type.
|
1783 |
-
*
|
1784 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1785 |
-
*
|
1786 |
-
* @param array An array of arguments.
|
1787 |
-
* @return string
|
1788 |
-
*
|
1789 |
-
* @access public
|
1790 |
-
* @since 2.0
|
1791 |
-
*/
|
1792 |
if ( ! function_exists( 'ot_type_page_select' ) ) {
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1836 |
}
|
1837 |
|
1838 |
-
/**
|
1839 |
-
* Post Checkbox option type.
|
1840 |
-
*
|
1841 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1842 |
-
*
|
1843 |
-
* @param array An array of arguments.
|
1844 |
-
* @return string
|
1845 |
-
*
|
1846 |
-
* @access public
|
1847 |
-
* @since 2.0
|
1848 |
-
*/
|
1849 |
if ( ! function_exists( 'ot_type_post_checkbox' ) ) {
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1890 |
}
|
1891 |
|
1892 |
-
/**
|
1893 |
-
* Post Select option type.
|
1894 |
-
*
|
1895 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1896 |
-
*
|
1897 |
-
* @param array An array of arguments.
|
1898 |
-
* @return string
|
1899 |
-
*
|
1900 |
-
* @access public
|
1901 |
-
* @since 2.0
|
1902 |
-
*/
|
1903 |
if ( ! function_exists( 'ot_type_post_select' ) ) {
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1947 |
}
|
1948 |
|
1949 |
-
/**
|
1950 |
-
* Radio option type.
|
1951 |
-
*
|
1952 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1953 |
-
*
|
1954 |
-
* @param array An array of arguments.
|
1955 |
-
* @return string
|
1956 |
-
*
|
1957 |
-
* @access public
|
1958 |
-
* @since 2.0
|
1959 |
-
*/
|
1960 |
if ( ! function_exists( 'ot_type_radio' ) ) {
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1990 |
}
|
1991 |
|
1992 |
-
/**
|
1993 |
-
* Radio Images option type.
|
1994 |
-
*
|
1995 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
1996 |
-
*
|
1997 |
-
* @param array An array of arguments.
|
1998 |
-
* @return string
|
1999 |
-
*
|
2000 |
-
* @access public
|
2001 |
-
* @since 2.0
|
2002 |
-
*/
|
2003 |
if ( ! function_exists( 'ot_type_radio_image' ) ) {
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2061 |
}
|
2062 |
|
2063 |
-
/**
|
2064 |
-
* Select option type.
|
2065 |
-
*
|
2066 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2067 |
-
*
|
2068 |
-
* @param array An array of arguments.
|
2069 |
-
* @return string
|
2070 |
-
*
|
2071 |
-
* @access public
|
2072 |
-
* @since 2.0
|
2073 |
-
*/
|
2074 |
if ( ! function_exists( 'ot_type_select' ) ) {
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2112 |
}
|
2113 |
|
2114 |
-
/**
|
2115 |
-
* Sidebar Select option type.
|
2116 |
-
*
|
2117 |
-
* This option type makes it possible for users to select a WordPress registered sidebar
|
2118 |
-
* to use on a specific area. By using the two provided filters, 'ot_recognized_sidebars',
|
2119 |
-
* and 'ot_recognized_sidebars_{$field_id}' we can be selective about which sidebars are
|
2120 |
-
* available on a specific content area.
|
2121 |
-
*
|
2122 |
-
* For example, if we create a WordPress theme that provides the ability to change the
|
2123 |
-
* Blog Sidebar and we don't want to have the footer sidebars available on this area,
|
2124 |
-
* we can unset those sidebars either manually or by using a regular expression if we
|
2125 |
-
* have a common name like footer-sidebar-$i.
|
2126 |
-
*
|
2127 |
-
* @param array An array of arguments.
|
2128 |
-
* @return string
|
2129 |
-
*
|
2130 |
-
* @access public
|
2131 |
-
* @since 2.1
|
2132 |
-
*/
|
2133 |
if ( ! function_exists( 'ot_type_sidebar_select' ) ) {
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2185 |
}
|
2186 |
|
2187 |
-
/**
|
2188 |
-
* List Item option type.
|
2189 |
-
*
|
2190 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2191 |
-
*
|
2192 |
-
* @param array An array of arguments.
|
2193 |
-
* @return string
|
2194 |
-
*
|
2195 |
-
* @access public
|
2196 |
-
* @since 2.0
|
2197 |
-
*/
|
2198 |
if ( ! function_exists( 'ot_type_slider' ) ) {
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2257 |
}
|
2258 |
|
2259 |
-
/**
|
2260 |
-
* Social Links option type.
|
2261 |
-
*
|
2262 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2263 |
-
*
|
2264 |
-
* @param array An array of arguments.
|
2265 |
-
* @return string
|
2266 |
-
*
|
2267 |
-
* @access public
|
2268 |
-
* @since 2.4.0
|
2269 |
-
*/
|
2270 |
if ( ! function_exists( 'ot_type_social_links' ) ) {
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2422 |
}
|
2423 |
|
2424 |
-
/**
|
2425 |
-
* Spacing Option Type.
|
2426 |
-
*
|
2427 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2428 |
-
*
|
2429 |
-
* @param array An array of arguments.
|
2430 |
-
* @return string
|
2431 |
-
*
|
2432 |
-
* @access public
|
2433 |
-
* @since 2.5.0
|
2434 |
-
*/
|
2435 |
if ( ! function_exists( 'ot_type_spacing' ) ) {
|
2436 |
|
2437 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2438 |
|
2439 |
-
|
2440 |
-
|
2441 |
|
2442 |
-
|
2443 |
-
|
2444 |
|
2445 |
-
|
2446 |
-
|
2447 |
|
2448 |
-
|
2449 |
-
|
2450 |
|
2451 |
-
|
2452 |
-
|
2453 |
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
|
|
|
|
|
|
|
|
2462 |
|
2463 |
-
|
2464 |
-
|
2465 |
|
2466 |
-
|
2467 |
|
2468 |
-
|
|
|
2469 |
|
2470 |
-
|
|
|
2471 |
|
2472 |
-
|
2473 |
-
if ( in_array( 'right', $ot_recognized_spacing_fields ) ) {
|
2474 |
|
2475 |
-
|
|
|
2476 |
|
2477 |
-
|
|
|
2478 |
|
2479 |
-
|
2480 |
|
2481 |
-
|
2482 |
-
|
2483 |
|
2484 |
-
|
|
|
2485 |
|
2486 |
-
|
2487 |
|
2488 |
-
|
|
|
2489 |
|
2490 |
-
|
2491 |
-
|
2492 |
|
2493 |
-
|
2494 |
|
2495 |
-
|
2496 |
|
2497 |
-
|
2498 |
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
echo '<div class="ot-option-group ot-option-group--is-last">';
|
2503 |
-
|
2504 |
-
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2505 |
-
|
2506 |
-
echo '<option value="">' . __( 'unit', 'option-tree' ) . '</option>';
|
2507 |
-
|
2508 |
-
foreach ( ot_recognized_spacing_unit_types( $field_id ) as $unit ) {
|
2509 |
-
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
2510 |
-
}
|
2511 |
-
|
2512 |
-
echo '</select>';
|
2513 |
-
|
2514 |
-
echo '</div>';
|
2515 |
|
2516 |
-
|
2517 |
-
|
2518 |
-
echo '</div>';
|
2519 |
|
2520 |
-
|
|
|
2521 |
|
2522 |
-
|
2523 |
|
|
|
|
|
2524 |
}
|
2525 |
|
2526 |
-
/**
|
2527 |
-
* Tab option type.
|
2528 |
-
*
|
2529 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2530 |
-
*
|
2531 |
-
* @param array An array of arguments.
|
2532 |
-
* @return string
|
2533 |
-
*
|
2534 |
-
* @access public
|
2535 |
-
* @since 2.3.0
|
2536 |
-
*/
|
2537 |
if ( ! function_exists( 'ot_type_tab' ) ) {
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
}
|
2552 |
-
|
2553 |
}
|
2554 |
|
2555 |
-
/**
|
2556 |
-
* Tag Checkbox option type.
|
2557 |
-
*
|
2558 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2559 |
-
*
|
2560 |
-
* @param array An array of arguments.
|
2561 |
-
* @return string
|
2562 |
-
*
|
2563 |
-
* @access public
|
2564 |
-
* @since 2.0
|
2565 |
-
*/
|
2566 |
if ( ! function_exists( 'ot_type_tag_checkbox' ) ) {
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2606 |
}
|
2607 |
|
2608 |
-
/**
|
2609 |
-
* Tag Select option type.
|
2610 |
-
*
|
2611 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2612 |
-
*
|
2613 |
-
* @param array An array of arguments.
|
2614 |
-
* @return string
|
2615 |
-
*
|
2616 |
-
* @access public
|
2617 |
-
* @since 2.0
|
2618 |
-
*/
|
2619 |
if ( ! function_exists( 'ot_type_tag_select' ) ) {
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2662 |
}
|
2663 |
|
2664 |
-
/**
|
2665 |
-
* Taxonomy Checkbox option type.
|
2666 |
-
*
|
2667 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2668 |
-
*
|
2669 |
-
* @param array An array of arguments.
|
2670 |
-
* @return string
|
2671 |
-
*
|
2672 |
-
* @access public
|
2673 |
-
* @since 2.0
|
2674 |
-
*/
|
2675 |
if ( ! function_exists( 'ot_type_taxonomy_checkbox' ) ) {
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2718 |
}
|
2719 |
|
2720 |
-
/**
|
2721 |
-
* Taxonomy Select option type.
|
2722 |
-
*
|
2723 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2724 |
-
*
|
2725 |
-
* @param array An array of arguments.
|
2726 |
-
* @return string
|
2727 |
-
*
|
2728 |
-
* @access public
|
2729 |
-
* @since 2.0
|
2730 |
-
*/
|
2731 |
if ( ! function_exists( 'ot_type_taxonomy_select' ) ) {
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2777 |
}
|
2778 |
|
2779 |
-
/**
|
2780 |
-
* Text option type.
|
2781 |
-
*
|
2782 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2783 |
-
*
|
2784 |
-
* @param array An array of arguments.
|
2785 |
-
* @return string
|
2786 |
-
*
|
2787 |
-
* @access public
|
2788 |
-
* @since 2.0
|
2789 |
-
*/
|
2790 |
if ( ! function_exists( 'ot_type_text' ) ) {
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2818 |
}
|
2819 |
|
2820 |
-
/**
|
2821 |
-
* Textarea option type.
|
2822 |
-
*
|
2823 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2824 |
-
*
|
2825 |
-
* @param array An array of arguments.
|
2826 |
-
* @return string
|
2827 |
-
*
|
2828 |
-
* @access public
|
2829 |
-
* @since 2.0
|
2830 |
-
*/
|
2831 |
if ( ! function_exists( 'ot_type_textarea' ) ) {
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2871 |
}
|
2872 |
|
2873 |
-
/**
|
2874 |
-
* Textarea Simple option type.
|
2875 |
-
*
|
2876 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2877 |
-
*
|
2878 |
-
* @param array An array of arguments.
|
2879 |
-
* @return string
|
2880 |
-
*
|
2881 |
-
* @access public
|
2882 |
-
* @since 2.0
|
2883 |
-
*/
|
2884 |
if ( ! function_exists( 'ot_type_textarea_simple' ) ) {
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2919 |
}
|
2920 |
|
2921 |
-
/**
|
2922 |
-
* Textblock option type.
|
2923 |
-
*
|
2924 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2925 |
-
*
|
2926 |
-
* @param array An array of arguments.
|
2927 |
-
* @return string
|
2928 |
-
*
|
2929 |
-
* @access public
|
2930 |
-
* @since 2.0
|
2931 |
-
*/
|
2932 |
if ( ! function_exists( 'ot_type_textblock' ) ) {
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2949 |
}
|
2950 |
|
2951 |
-
/**
|
2952 |
-
* Textblock Titled option type.
|
2953 |
-
*
|
2954 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2955 |
-
*
|
2956 |
-
* @param array An array of arguments.
|
2957 |
-
* @return string
|
2958 |
-
*
|
2959 |
-
* @access public
|
2960 |
-
* @since 2.0
|
2961 |
-
*/
|
2962 |
if ( ! function_exists( 'ot_type_textblock_titled' ) ) {
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2979 |
}
|
2980 |
|
2981 |
-
/**
|
2982 |
-
* Typography option type.
|
2983 |
-
*
|
2984 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
2985 |
-
*
|
2986 |
-
* @param array An array of arguments.
|
2987 |
-
* @return string
|
2988 |
-
*
|
2989 |
-
* @access public
|
2990 |
-
* @since 2.0
|
2991 |
-
*/
|
2992 |
if ( ! function_exists( 'ot_type_typography' ) ) {
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3149 |
}
|
3150 |
|
3151 |
-
/**
|
3152 |
-
* Upload option type.
|
3153 |
-
*
|
3154 |
-
* See @ot_display_by_type to see the full list of available arguments.
|
3155 |
-
*
|
3156 |
-
* @param array An array of arguments.
|
3157 |
-
* @return string
|
3158 |
-
*
|
3159 |
-
* @access public
|
3160 |
-
* @since 2.0
|
3161 |
-
*/
|
3162 |
if ( ! function_exists( 'ot_type_upload' ) ) {
|
3163 |
-
|
3164 |
-
function ot_type_upload( $args = array() ) {
|
3165 |
-
|
3166 |
-
/* turns arguments array into variables */
|
3167 |
-
extract( $args );
|
3168 |
-
|
3169 |
-
/* verify a description */
|
3170 |
-
$has_desc = $field_desc ? true : false;
|
3171 |
-
|
3172 |
-
/* If an attachment ID is stored here fetch its URL and replace the value */
|
3173 |
-
if ( $field_value && wp_attachment_is_image( $field_value ) ) {
|
3174 |
-
|
3175 |
-
$attachment_data = wp_get_attachment_image_src( $field_value, 'original' );
|
3176 |
-
|
3177 |
-
/* check for attachment data */
|
3178 |
-
if ( $attachment_data ) {
|
3179 |
-
|
3180 |
-
$field_src = $attachment_data[0];
|
3181 |
-
|
3182 |
-
}
|
3183 |
-
|
3184 |
-
}
|
3185 |
-
|
3186 |
-
/* format setting outer wrapper */
|
3187 |
-
echo '<div class="format-setting type-upload ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
3188 |
-
|
3189 |
-
/* description */
|
3190 |
-
echo $has_desc ? '<div class="description">' . htmlspecialchars_decode( $field_desc ) . '</div>' : '';
|
3191 |
-
|
3192 |
-
/* format setting inner wrapper */
|
3193 |
-
echo '<div class="format-setting-inner">';
|
3194 |
-
|
3195 |
-
/* build upload */
|
3196 |
-
echo '<div class="option-tree-ui-upload-parent">';
|
3197 |
-
|
3198 |
-
/* input */
|
3199 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-upload-input ' . esc_attr( $field_class ) . '" />';
|
3200 |
-
|
3201 |
-
/* add media button */
|
3202 |
-
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . $post_id . '" title="' . __( 'Add Media', 'option-tree' ) . '"><span class="icon ot-icon-plus-circle"></span>' . __( 'Add Media', 'option-tree' ) . '</a>';
|
3203 |
-
|
3204 |
-
echo '</div>';
|
3205 |
-
|
3206 |
-
/* media */
|
3207 |
-
if ( $field_value ) {
|
3208 |
-
|
3209 |
-
echo '<div class="option-tree-ui-media-wrap" id="' . esc_attr( $field_id ) . '_media">';
|
3210 |
-
|
3211 |
-
/* replace image src */
|
3212 |
-
if ( isset( $field_src ) )
|
3213 |
-
$field_value = $field_src;
|
3214 |
-
|
3215 |
-
if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value ) )
|
3216 |
-
echo '<div class="option-tree-ui-image-wrap"><img src="' . esc_url( $field_value ) . '" alt="" /></div>';
|
3217 |
-
|
3218 |
-
echo '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="' . __( 'Remove Media', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"></span>' . __( 'Remove Media', 'option-tree' ) . '</a>';
|
3219 |
-
|
3220 |
-
echo '</div>';
|
3221 |
-
|
3222 |
-
}
|
3223 |
-
|
3224 |
-
echo '</div>';
|
3225 |
-
|
3226 |
-
echo '</div>';
|
3227 |
-
|
3228 |
-
}
|
3229 |
-
|
3230 |
-
}
|
3231 |
|
3232 |
-
|
3233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Option Type Functions.
|
4 |
+
*
|
5 |
* Functions used to build each option type.
|
6 |
*
|
7 |
+
* @package OptionTree
|
|
|
|
|
|
|
8 |
*/
|
9 |
|
10 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
11 |
+
exit( 'No direct script access allowed' );
|
12 |
+
}
|
13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
if ( ! function_exists( 'ot_display_by_type' ) ) {
|
15 |
|
16 |
+
/**
|
17 |
+
* Builds the HTML for each of the available option types by calling those
|
18 |
+
* function with call_user_func and passing the arguments to the second param.
|
19 |
+
*
|
20 |
+
* All fields are required!
|
21 |
+
*
|
22 |
+
* @param array $args The array of arguments are as follows.
|
23 |
+
* @var string $type Type of option.
|
24 |
+
* @var string $field_id The field ID.
|
25 |
+
* @var string $field_name The field Name.
|
26 |
+
* @var mixed $field_value The field value is a string or an array of values.
|
27 |
+
* @var string $field_desc The field description.
|
28 |
+
* @var string $field_std The standard value.
|
29 |
+
* @var string $field_class Extra CSS classes.
|
30 |
+
* @var array $field_choices The array of option choices.
|
31 |
+
* @var array $field_settings The array of settings for a list item.
|
32 |
+
*
|
33 |
+
* @access public
|
34 |
+
* @since 2.0
|
35 |
+
*/
|
36 |
+
function ot_display_by_type( $args = array() ) {
|
37 |
+
|
38 |
+
// Allow filters to be executed on the array.
|
39 |
+
$args = apply_filters( 'ot_display_by_type', $args );
|
40 |
+
|
41 |
+
if ( empty( $args['type'] ) ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
+
|
45 |
+
// Build the function name.
|
46 |
+
$function_name_by_type = str_replace( '-', '_', 'ot_type_' . $args['type'] );
|
47 |
+
|
48 |
+
// Call the function & pass in arguments array.
|
49 |
+
if ( function_exists( $function_name_by_type ) ) {
|
50 |
+
call_user_func( $function_name_by_type, $args );
|
51 |
+
} else {
|
52 |
+
echo '<p>' . esc_html__( 'Sorry, this function does not exist', 'option-tree' ) . '</p>';
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
if ( ! function_exists( 'ot_type_background' ) ) {
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Background option type.
|
62 |
+
*
|
63 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
64 |
+
*
|
65 |
+
* @param array $args An array of arguments.
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @since 2.0
|
69 |
+
*/
|
70 |
+
function ot_type_background( $args = array() ) {
|
71 |
+
|
72 |
+
// Turns arguments array into variables.
|
73 |
+
extract( $args ); // phpcs:ignore
|
74 |
+
|
75 |
+
// Verify a description.
|
76 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
77 |
+
|
78 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
79 |
+
if ( isset( $field_value['background-image'] ) && wp_attachment_is_image( $field_value['background-image'] ) ) {
|
80 |
+
|
81 |
+
$attachment_data = wp_get_attachment_image_src( $field_value['background-image'], 'original' );
|
82 |
+
|
83 |
+
/* check for attachment data */
|
84 |
+
if ( $attachment_data ) {
|
85 |
+
|
86 |
+
$field_src = $attachment_data[0];
|
87 |
+
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
// Format setting outer wrapper.
|
92 |
+
echo '<div class="format-setting type-background ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
93 |
+
|
94 |
+
// Description.
|
95 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
96 |
+
|
97 |
+
// Format setting inner wrapper.
|
98 |
+
echo '<div class="format-setting-inner">';
|
99 |
+
|
100 |
+
// Allow fields to be filtered.
|
101 |
+
$ot_recognized_background_fields = apply_filters(
|
102 |
+
'ot_recognized_background_fields',
|
103 |
+
array(
|
104 |
+
'background-color',
|
105 |
+
'background-repeat',
|
106 |
+
'background-attachment',
|
107 |
+
'background-position',
|
108 |
+
'background-size',
|
109 |
+
'background-image',
|
110 |
+
),
|
111 |
+
$field_id
|
112 |
+
);
|
113 |
+
|
114 |
+
echo '<div class="ot-background-group">';
|
115 |
+
|
116 |
+
// Build background color.
|
117 |
+
if ( in_array( 'background-color', $ot_recognized_background_fields, true ) ) {
|
118 |
+
|
119 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
120 |
+
|
121 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
122 |
+
|
123 |
+
$background_color = isset( $field_value['background-color'] ) ? $field_value['background-color'] : '';
|
124 |
+
|
125 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[background-color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $background_color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
126 |
+
|
127 |
+
echo '</div>';
|
128 |
+
}
|
129 |
+
|
130 |
+
// Build background repeat.
|
131 |
+
if ( in_array( 'background-repeat', $ot_recognized_background_fields, true ) ) {
|
132 |
+
|
133 |
+
$background_repeat = isset( $field_value['background-repeat'] ) ? esc_attr( $field_value['background-repeat'] ) : '';
|
134 |
+
|
135 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-repeat]" id="' . esc_attr( $field_id ) . '-repeat" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
136 |
+
|
137 |
+
echo '<option value="">' . esc_html__( 'background-repeat', 'option-tree' ) . '</option>';
|
138 |
+
foreach ( ot_recognized_background_repeat( $field_id ) as $key => $value ) {
|
139 |
+
|
140 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $background_repeat, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
141 |
+
}
|
142 |
+
|
143 |
+
echo '</select>';
|
144 |
+
}
|
145 |
+
|
146 |
+
// Build background attachment.
|
147 |
+
if ( in_array( 'background-attachment', $ot_recognized_background_fields, true ) ) {
|
148 |
+
|
149 |
+
$background_attachment = isset( $field_value['background-attachment'] ) ? $field_value['background-attachment'] : '';
|
150 |
+
|
151 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-attachment]" id="' . esc_attr( $field_id ) . '-attachment" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
152 |
+
|
153 |
+
echo '<option value="">' . esc_html__( 'background-attachment', 'option-tree' ) . '</option>';
|
154 |
+
|
155 |
+
foreach ( ot_recognized_background_attachment( $field_id ) as $key => $value ) {
|
156 |
+
|
157 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $background_attachment, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
158 |
+
}
|
159 |
+
|
160 |
+
echo '</select>';
|
161 |
+
}
|
162 |
+
|
163 |
+
// Build background position.
|
164 |
+
if ( in_array( 'background-position', $ot_recognized_background_fields, true ) ) {
|
165 |
+
|
166 |
+
$background_position = isset( $field_value['background-position'] ) ? $field_value['background-position'] : '';
|
167 |
+
|
168 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-position]" id="' . esc_attr( $field_id ) . '-position" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
169 |
+
|
170 |
+
echo '<option value="">' . esc_html__( 'background-position', 'option-tree' ) . '</option>';
|
171 |
+
|
172 |
+
foreach ( ot_recognized_background_position( $field_id ) as $key => $value ) {
|
173 |
+
|
174 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $background_position, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
175 |
+
}
|
176 |
+
|
177 |
+
echo '</select>';
|
178 |
+
}
|
179 |
+
|
180 |
+
// Build background size .
|
181 |
+
if ( in_array( 'background-size', $ot_recognized_background_fields, true ) ) {
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Use this filter to create a select instead of an text input.
|
185 |
+
* Be sure to return the array in the correct format. Add an empty
|
186 |
+
* value to the first choice so the user can leave it blank.
|
187 |
+
*
|
188 |
+
* Example: array(
|
189 |
+
* array(
|
190 |
+
* 'label' => 'background-size',
|
191 |
+
* 'value' => ''
|
192 |
+
* ),
|
193 |
+
* array(
|
194 |
+
* 'label' => 'cover',
|
195 |
+
* 'value' => 'cover'
|
196 |
+
* ),
|
197 |
+
* array(
|
198 |
+
* 'label' => 'contain',
|
199 |
+
* 'value' => 'contain'
|
200 |
+
* )
|
201 |
+
* )
|
202 |
+
*/
|
203 |
+
$choices = apply_filters( 'ot_type_background_size_choices', '', $field_id );
|
204 |
+
|
205 |
+
if ( is_array( $choices ) && ! empty( $choices ) ) {
|
206 |
+
|
207 |
+
// Build select.
|
208 |
+
echo '<select name="' . esc_attr( $field_name ) . '[background-size]" id="' . esc_attr( $field_id ) . '-size" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
209 |
+
|
210 |
+
foreach ( (array) $choices as $choice ) {
|
211 |
+
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
212 |
+
echo '<option value="' . esc_attr( $choice['value'] ) . '" ' . selected( ( isset( $field_value['background-size'] ) ? $field_value['background-size'] : '' ), $choice['value'], false ) . '>' . esc_attr( $choice['label'] ) . '</option>';
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
echo '</select>';
|
217 |
+
} else {
|
218 |
+
|
219 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[background-size]" id="' . esc_attr( $field_id ) . '-size" value="' . esc_attr( isset( $field_value['background-size'] ) ? $field_value['background-size'] : '' ) . '" class="widefat ot-background-size-input option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'background-size', 'option-tree' ) . '" />';
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
echo '</div>';
|
224 |
+
|
225 |
+
// Build background image.
|
226 |
+
if ( in_array( 'background-image', $ot_recognized_background_fields, true ) ) {
|
227 |
+
|
228 |
+
echo '<div class="option-tree-ui-upload-parent">';
|
229 |
+
|
230 |
+
// Input.
|
231 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[background-image]" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( isset( $field_value['background-image'] ) ? $field_value['background-image'] : '' ) . '" class="widefat option-tree-ui-upload-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'background-image', 'option-tree' ) . '" />';
|
232 |
+
|
233 |
+
// Add media button.
|
234 |
+
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . esc_attr( $post_id ) . '" title="' . esc_html__( 'Add Media', 'option-tree' ) . '"><span class="icon ot-icon-plus-circle"></span>' . esc_html__( 'Add Media', 'option-tree' ) . '</a>';
|
235 |
+
|
236 |
+
echo '</div>';
|
237 |
+
|
238 |
+
// Media.
|
239 |
+
if ( isset( $field_value['background-image'] ) && '' !== $field_value['background-image'] ) {
|
240 |
+
|
241 |
+
/* replace image src */
|
242 |
+
if ( isset( $field_src ) ) {
|
243 |
+
$field_value['background-image'] = $field_src;
|
244 |
+
}
|
245 |
+
|
246 |
+
echo '<div class="option-tree-ui-media-wrap" id="' . esc_attr( $field_id ) . '_media">';
|
247 |
+
|
248 |
+
if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value['background-image'] ) ) {
|
249 |
+
echo '<div class="option-tree-ui-image-wrap"><img src="' . esc_url_raw( $field_value['background-image'] ) . '" alt="" /></div>';
|
250 |
+
}
|
251 |
+
|
252 |
+
echo '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Media', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"></span>' . esc_html__( 'Remove Media', 'option-tree' ) . '</a>';
|
253 |
+
|
254 |
+
echo '</div>';
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
echo '</div>';
|
259 |
+
|
260 |
+
echo '</div>';
|
261 |
+
}
|
|
|
|
|
|
|
262 |
}
|
263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
if ( ! function_exists( 'ot_type_border' ) ) {
|
265 |
|
266 |
+
/**
|
267 |
+
* Border Option Type
|
268 |
+
*
|
269 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
270 |
+
*
|
271 |
+
* @param array $args The options arguments.
|
272 |
+
*
|
273 |
+
* @access public
|
274 |
+
* @since 2.5.0
|
275 |
+
*/
|
276 |
+
function ot_type_border( $args = array() ) {
|
277 |
+
|
278 |
+
// Turns arguments array into variables.
|
279 |
+
extract( $args ); // phpcs:ignore
|
280 |
+
|
281 |
+
// Verify a description.
|
282 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
283 |
+
|
284 |
+
// Format setting outer wrapper.
|
285 |
+
echo '<div class="format-setting type-border ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
286 |
+
|
287 |
+
// Description.
|
288 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
289 |
+
|
290 |
+
// Format setting inner wrapper.
|
291 |
+
echo '<div class="format-setting-inner">';
|
292 |
+
|
293 |
+
// Allow fields to be filtered.
|
294 |
+
$ot_recognized_border_fields = apply_filters(
|
295 |
+
'ot_recognized_border_fields',
|
296 |
+
array(
|
297 |
+
'width',
|
298 |
+
'unit',
|
299 |
+
'style',
|
300 |
+
'color',
|
301 |
+
),
|
302 |
+
$field_id
|
303 |
+
);
|
304 |
+
|
305 |
+
// Build border width.
|
306 |
+
if ( in_array( 'width', $ot_recognized_border_fields, true ) ) {
|
307 |
+
|
308 |
+
$width = isset( $field_value['width'] ) ? $field_value['width'] : '';
|
309 |
+
|
310 |
+
echo '<div class="ot-option-group ot-option-group--one-sixth"><input type="text" name="' . esc_attr( $field_name ) . '[width]" id="' . esc_attr( $field_id ) . '-width" value="' . esc_attr( $width ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'width', 'option-tree' ) . '" /></div>';
|
311 |
+
}
|
312 |
+
|
313 |
+
// Build unit dropdown.
|
314 |
+
if ( in_array( 'unit', $ot_recognized_border_fields, true ) ) {
|
315 |
+
|
316 |
+
echo '<div class="ot-option-group ot-option-group--one-fourth">';
|
317 |
+
|
318 |
+
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
|
320 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
321 |
+
|
322 |
+
foreach ( ot_recognized_border_unit_types( $field_id ) as $unit ) {
|
323 |
+
echo '<option value="' . esc_attr( $unit ) . '" ' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
324 |
+
}
|
325 |
+
|
326 |
+
echo '</select>';
|
327 |
+
|
328 |
+
echo '</div>';
|
329 |
+
}
|
330 |
+
|
331 |
+
// Build style dropdown.
|
332 |
+
if ( in_array( 'style', $ot_recognized_border_fields, true ) ) {
|
333 |
+
|
334 |
+
echo '<div class="ot-option-group ot-option-group--one-fourth">';
|
335 |
+
|
336 |
+
echo '<select name="' . esc_attr( $field_name ) . '[style]" id="' . esc_attr( $field_id ) . '-style" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
337 |
+
|
338 |
+
echo '<option value="">' . esc_html__( 'style', 'option-tree' ) . '</option>';
|
339 |
+
|
340 |
+
foreach ( ot_recognized_border_style_types( $field_id ) as $key => $style ) {
|
341 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . ( isset( $field_value['style'] ) ? selected( $field_value['style'], $key, false ) : '' ) . '>' . esc_attr( $style ) . '</option>';
|
342 |
+
}
|
343 |
+
|
344 |
+
echo '</select>';
|
345 |
+
|
346 |
+
echo '</div>';
|
347 |
+
}
|
348 |
+
|
349 |
+
// Build color.
|
350 |
+
if ( in_array( 'color', $ot_recognized_border_fields, true ) ) {
|
351 |
+
|
352 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
353 |
+
|
354 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
355 |
+
|
356 |
+
$color = isset( $field_value['color'] ) ? $field_value['color'] : '';
|
357 |
+
|
358 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
359 |
+
|
360 |
+
echo '</div>';
|
361 |
+
}
|
362 |
+
|
363 |
+
echo '</div>';
|
364 |
+
|
365 |
+
echo '</div>';
|
366 |
+
}
|
367 |
}
|
368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
if ( ! function_exists( 'ot_type_box_shadow' ) ) {
|
370 |
|
371 |
+
/**
|
372 |
+
* Box Shadow Option Type
|
373 |
+
*
|
374 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
375 |
+
*
|
376 |
+
* @param array $args The options arguments.
|
377 |
+
*
|
378 |
+
* @access public
|
379 |
+
* @since 2.5.0
|
380 |
+
*/
|
381 |
+
function ot_type_box_shadow( $args = array() ) {
|
382 |
+
|
383 |
+
// Turns arguments array into variables.
|
384 |
+
extract( $args ); // phpcs:ignore
|
385 |
+
|
386 |
+
// Verify a description.
|
387 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
388 |
+
|
389 |
+
// Format setting outer wrapper.
|
390 |
+
echo '<div class="format-setting type-box-shadow ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
391 |
+
|
392 |
+
// Description.
|
393 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
394 |
+
|
395 |
+
// Format setting inner wrapper.
|
396 |
+
echo '<div class="format-setting-inner">';
|
397 |
+
|
398 |
+
// Allow fields to be filtered.
|
399 |
+
$ot_recognized_box_shadow_fields = apply_filters(
|
400 |
+
'ot_recognized_box_shadow_fields',
|
401 |
+
array(
|
402 |
+
'inset',
|
403 |
+
'offset-x',
|
404 |
+
'offset-y',
|
405 |
+
'blur-radius',
|
406 |
+
'spread-radius',
|
407 |
+
'color',
|
408 |
+
),
|
409 |
+
$field_id
|
410 |
+
);
|
411 |
+
|
412 |
+
// Build inset.
|
413 |
+
if ( in_array( 'inset', $ot_recognized_box_shadow_fields, true ) ) {
|
414 |
+
|
415 |
+
echo '<div class="ot-option-group ot-option-group--checkbox"><p>';
|
416 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[inset]" id="' . esc_attr( $field_id ) . '-inset" value="inset" ' . ( isset( $field_value['inset'] ) ? checked( $field_value['inset'], 'inset', false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
417 |
+
echo '<label for="' . esc_attr( $field_id ) . '-inset">inset</label>';
|
418 |
+
echo '</p></div>';
|
419 |
+
}
|
420 |
+
|
421 |
+
// Build horizontal offset.
|
422 |
+
if ( in_array( 'offset-x', $ot_recognized_box_shadow_fields, true ) ) {
|
423 |
+
|
424 |
+
$offset_x = isset( $field_value['offset-x'] ) ? esc_attr( $field_value['offset-x'] ) : '';
|
425 |
+
|
426 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-arrows-h ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[offset-x]" id="' . esc_attr( $field_id ) . '-offset-x" value="' . esc_attr( $offset_x ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'offset-x', 'option-tree' ) . '" /></div>';
|
427 |
+
}
|
428 |
+
|
429 |
+
// Build vertical offset.
|
430 |
+
if ( in_array( 'offset-y', $ot_recognized_box_shadow_fields, true ) ) {
|
431 |
+
|
432 |
+
$offset_y = isset( $field_value['offset-y'] ) ? esc_attr( $field_value['offset-y'] ) : '';
|
433 |
+
|
434 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-arrows-v ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[offset-y]" id="' . esc_attr( $field_id ) . '-offset-y" value="' . esc_attr( $offset_y ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'offset-y', 'option-tree' ) . '" /></div>';
|
435 |
+
}
|
436 |
+
|
437 |
+
// Build blur-radius radius.
|
438 |
+
if ( in_array( 'blur-radius', $ot_recognized_box_shadow_fields, true ) ) {
|
439 |
+
|
440 |
+
$blur_radius = isset( $field_value['blur-radius'] ) ? esc_attr( $field_value['blur-radius'] ) : '';
|
441 |
+
|
442 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-circle ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[blur-radius]" id="' . esc_attr( $field_id ) . '-blur-radius" value="' . esc_attr( $blur_radius ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'blur-radius', 'option-tree' ) . '" /></div>';
|
443 |
+
}
|
444 |
+
|
445 |
+
// Build spread-radius radius.
|
446 |
+
if ( in_array( 'spread-radius', $ot_recognized_box_shadow_fields, true ) ) {
|
447 |
+
|
448 |
+
$spread_radius = isset( $field_value['spread-radius'] ) ? esc_attr( $field_value['spread-radius'] ) : '';
|
449 |
+
|
450 |
+
echo '<div class="ot-option-group ot-option-group--one-fifth"><span class="ot-icon-arrows-alt ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[spread-radius]" id="' . esc_attr( $field_id ) . '-spread-radius" value="' . esc_attr( $spread_radius ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'spread-radius', 'option-tree' ) . '" /></div>';
|
451 |
+
}
|
452 |
+
|
453 |
+
// Build color.
|
454 |
+
if ( in_array( 'color', $ot_recognized_box_shadow_fields, true ) ) {
|
455 |
+
|
456 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
|
458 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
459 |
+
|
460 |
+
$color = isset( $field_value['color'] ) ? $field_value['color'] : '';
|
461 |
+
|
462 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
463 |
+
|
464 |
+
echo '</div>';
|
465 |
+
}
|
466 |
+
|
467 |
+
echo '</div>';
|
468 |
+
|
469 |
+
echo '</div>';
|
470 |
+
}
|
471 |
}
|
472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
if ( ! function_exists( 'ot_type_category_checkbox' ) ) {
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Category Checkbox option type.
|
477 |
+
*
|
478 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
479 |
+
*
|
480 |
+
* @param array $args An array of arguments.
|
481 |
+
*
|
482 |
+
* @access public
|
483 |
+
* @since 2.0
|
484 |
+
*/
|
485 |
+
function ot_type_category_checkbox( $args = array() ) {
|
486 |
+
|
487 |
+
// Turns arguments array into variables.
|
488 |
+
extract( $args );// phpcs:ignore
|
489 |
+
|
490 |
+
// Verify a description.
|
491 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
492 |
+
|
493 |
+
// Format setting outer wrapper.
|
494 |
+
echo '<div class="format-setting type-category-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
495 |
+
|
496 |
+
// Description.
|
497 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
498 |
+
|
499 |
+
// Format setting inner wrapper.
|
500 |
+
echo '<div class="format-setting-inner">';
|
501 |
+
|
502 |
+
// Get category array.
|
503 |
+
$categories = get_categories( apply_filters( 'ot_type_category_checkbox_query', array( 'hide_empty' => false ), $field_id ) );
|
504 |
+
|
505 |
+
// Build categories.
|
506 |
+
if ( ! empty( $categories ) ) {
|
507 |
+
foreach ( $categories as $category ) {
|
508 |
+
echo '<p>';
|
509 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $category->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $category->term_id ) . '" value="' . esc_attr( $category->term_id ) . '" ' . ( isset( $field_value[ $category->term_id ] ) ? checked( $field_value[ $category->term_id ], $category->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
510 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $category->term_id ) . '">' . esc_attr( $category->name ) . '</label>';
|
511 |
+
echo '</p>';
|
512 |
+
}
|
513 |
+
} else {
|
514 |
+
echo '<p>' . esc_html__( 'No Categories Found', 'option-tree' ) . '</p>';
|
515 |
+
}
|
516 |
+
|
517 |
+
echo '</div>';
|
518 |
+
|
519 |
+
echo '</div>';
|
520 |
+
}
|
521 |
}
|
522 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
if ( ! function_exists( 'ot_type_category_select' ) ) {
|
524 |
+
|
525 |
+
/**
|
526 |
+
* Category Select option type.
|
527 |
+
*
|
528 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
529 |
+
*
|
530 |
+
* @param array $args An array of arguments.
|
531 |
+
*
|
532 |
+
* @access public
|
533 |
+
* @since 2.0
|
534 |
+
*/
|
535 |
+
function ot_type_category_select( $args = array() ) {
|
536 |
+
|
537 |
+
// Turns arguments array into variables.
|
538 |
+
extract( $args ); // phpcs:ignore
|
539 |
+
|
540 |
+
// Verify a description.
|
541 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
542 |
+
|
543 |
+
// Format setting outer wrapper.
|
544 |
+
echo '<div class="format-setting type-category-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
545 |
+
|
546 |
+
// Description.
|
547 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
548 |
+
|
549 |
+
// Format setting inner wrapper.
|
550 |
+
echo '<div class="format-setting-inner">';
|
551 |
+
|
552 |
+
// Build category.
|
553 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
554 |
+
|
555 |
+
// Get category array.
|
556 |
+
$categories = get_categories( apply_filters( 'ot_type_category_select_query', array( 'hide_empty' => false ), $field_id ) );
|
557 |
+
|
558 |
+
// Has cats.
|
559 |
+
if ( ! empty( $categories ) ) {
|
560 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
561 |
+
foreach ( $categories as $category ) {
|
562 |
+
echo '<option value="' . esc_attr( $category->term_id ) . '" ' . selected( $field_value, $category->term_id, false ) . '>' . esc_attr( $category->name ) . '</option>';
|
563 |
+
}
|
564 |
+
} else {
|
565 |
+
echo '<option value="">' . esc_html__( 'No Categories Found', 'option-tree' ) . '</option>';
|
566 |
+
}
|
567 |
+
|
568 |
+
echo '</select>';
|
569 |
+
|
570 |
+
echo '</div>';
|
571 |
+
|
572 |
+
echo '</div>';
|
573 |
+
}
|
574 |
}
|
575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
if ( ! function_exists( 'ot_type_checkbox' ) ) {
|
577 |
+
|
578 |
+
/**
|
579 |
+
* Checkbox option type.
|
580 |
+
*
|
581 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
582 |
+
*
|
583 |
+
* @param array $args An array of arguments.
|
584 |
+
*
|
585 |
+
* @access public
|
586 |
+
* @since 2.0
|
587 |
+
*/
|
588 |
+
function ot_type_checkbox( $args = array() ) {
|
589 |
+
|
590 |
+
// Turns arguments array into variables.
|
591 |
+
extract( $args ); // phpcs:ignore
|
592 |
+
|
593 |
+
// Verify a description.
|
594 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
595 |
+
|
596 |
+
// Format setting outer wrapper.
|
597 |
+
echo '<div class="format-setting type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
598 |
+
|
599 |
+
// Description.
|
600 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
601 |
+
|
602 |
+
// Format setting inner wrapper.
|
603 |
+
echo '<div class="format-setting-inner">';
|
604 |
+
|
605 |
+
// Build checkbox.
|
606 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
607 |
+
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
608 |
+
echo '<p>';
|
609 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . ( isset( $field_value[ $key ] ) ? checked( $field_value[ $key ], $choice['value'], false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
610 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label>';
|
611 |
+
echo '</p>';
|
612 |
+
}
|
613 |
+
}
|
614 |
+
|
615 |
+
echo '</div>';
|
616 |
+
|
617 |
+
echo '</div>';
|
618 |
+
}
|
619 |
}
|
620 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
if ( ! function_exists( 'ot_type_colorpicker' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
|
623 |
+
/**
|
624 |
+
* Colorpicker option type.
|
625 |
+
*
|
626 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
627 |
+
*
|
628 |
+
* @param array $args An array of arguments.
|
629 |
+
*
|
630 |
+
* @access public
|
631 |
+
* @since 2.0
|
632 |
+
* @updated 2.2.0
|
633 |
+
*/
|
634 |
+
function ot_type_colorpicker( $args = array() ) {
|
635 |
+
|
636 |
+
// Turns arguments array into variables.
|
637 |
+
extract( $args ); // phpcs:ignore
|
638 |
+
|
639 |
+
// Verify a description.
|
640 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
641 |
+
|
642 |
+
// Format setting outer wrapper.
|
643 |
+
echo '<div class="format-setting type-colorpicker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
644 |
+
|
645 |
+
// Description.
|
646 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
647 |
+
|
648 |
+
// Format setting inner wrapper.
|
649 |
+
echo '<div class="format-setting-inner">';
|
650 |
|
651 |
+
// Build colorpicker.
|
652 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
653 |
|
654 |
+
// Colorpicker JS.
|
655 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '"); });</script>';
|
656 |
|
657 |
+
// Input.
|
658 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '"' . ( ! empty( $field_std ) ? ' data-default-color="' . esc_attr( $field_std ) . '"' : '' ) . ' />';
|
659 |
|
660 |
+
echo '</div>';
|
661 |
+
|
662 |
+
echo '</div>';
|
663 |
+
|
664 |
+
echo '</div>';
|
665 |
+
}
|
666 |
+
}
|
667 |
+
|
668 |
+
if ( ! function_exists( 'ot_type_colorpicker_opacity' ) ) {
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Colorpicker Opacity option type.
|
672 |
+
*
|
673 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
674 |
+
*
|
675 |
+
* @param array $args An array of arguments.
|
676 |
+
*
|
677 |
+
* @access public
|
678 |
+
* @since 2.5.0
|
679 |
+
*/
|
680 |
+
function ot_type_colorpicker_opacity( $args = array() ) {
|
681 |
+
|
682 |
+
$args['field_class'] = isset( $args['field_class'] ) ? $args['field_class'] . ' ot-colorpicker-opacity' : 'ot-colorpicker-opacity';
|
683 |
+
ot_type_colorpicker( $args );
|
684 |
+
}
|
685 |
}
|
686 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
if ( ! function_exists( 'ot_type_css' ) ) {
|
688 |
+
|
689 |
+
/**
|
690 |
+
* CSS option type.
|
691 |
+
*
|
692 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
693 |
+
*
|
694 |
+
* @param array $args An array of arguments.
|
695 |
+
*
|
696 |
+
* @access public
|
697 |
+
* @since 2.0
|
698 |
+
*/
|
699 |
+
function ot_type_css( $args = array() ) {
|
700 |
+
|
701 |
+
// Turns arguments array into variables.
|
702 |
+
extract( $args ); // phpcs:ignore
|
703 |
+
|
704 |
+
// Verify a description.
|
705 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
706 |
+
|
707 |
+
// Format setting outer wrapper.
|
708 |
+
echo '<div class="format-setting type-css simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
709 |
+
|
710 |
+
// Description.
|
711 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
712 |
+
|
713 |
+
// Format setting inner wrapper.
|
714 |
+
echo '<div class="format-setting-inner">';
|
715 |
+
|
716 |
+
// Build textarea for CSS.
|
717 |
+
echo '<textarea class="hidden" id="textarea_' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '">' . esc_textarea( $field_value ) . '</textarea>';
|
718 |
+
|
719 |
+
// Build pre to convert it into ace editor later.
|
720 |
+
echo '<pre class="ot-css-editor ' . esc_attr( $field_class ) . '" id="' . esc_attr( $field_id ) . '">' . esc_textarea( $field_value ) . '</pre>';
|
721 |
+
|
722 |
+
echo '</div>';
|
723 |
+
|
724 |
+
echo '</div>';
|
725 |
+
}
|
726 |
}
|
727 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
728 |
if ( ! function_exists( 'ot_type_custom_post_type_checkbox' ) ) {
|
729 |
+
|
730 |
+
/**
|
731 |
+
* Custom Post Type Checkbox option type.
|
732 |
+
*
|
733 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
734 |
+
*
|
735 |
+
* @param array $args An array of arguments.
|
736 |
+
*
|
737 |
+
* @access public
|
738 |
+
* @since 2.0
|
739 |
+
*/
|
740 |
+
function ot_type_custom_post_type_checkbox( $args = array() ) {
|
741 |
+
|
742 |
+
// Turns arguments array into variables.
|
743 |
+
extract( $args ); // phpcs:ignore
|
744 |
+
|
745 |
+
// Verify a description.
|
746 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
747 |
+
|
748 |
+
// Format setting outer wrapper.
|
749 |
+
echo '<div class="format-setting type-custom-post-type-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
750 |
+
|
751 |
+
// Description.
|
752 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
753 |
+
|
754 |
+
// Format setting inner wrapper.
|
755 |
+
echo '<div class="format-setting-inner">';
|
756 |
+
|
757 |
+
// Setup the post types.
|
758 |
+
$post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' );
|
759 |
+
|
760 |
+
// Query posts array.
|
761 |
+
$my_posts = get_posts(
|
762 |
+
apply_filters(
|
763 |
+
'ot_type_custom_post_type_checkbox_query',
|
764 |
+
array(
|
765 |
+
'post_type' => $post_type,
|
766 |
+
'posts_per_page' => -1,
|
767 |
+
'orderby' => 'title',
|
768 |
+
'order' => 'ASC',
|
769 |
+
'post_status' => 'any',
|
770 |
+
),
|
771 |
+
$field_id
|
772 |
+
)
|
773 |
+
);
|
774 |
+
|
775 |
+
// Has posts.
|
776 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
777 |
+
foreach ( $my_posts as $my_post ) {
|
778 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
779 |
+
echo '<p>';
|
780 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[ $my_post->ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
781 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . esc_html( $post_title ) . '</label>';
|
782 |
+
echo '</p>';
|
783 |
+
}
|
784 |
+
} else {
|
785 |
+
echo '<p>' . esc_html__( 'No Posts Found', 'option-tree' ) . '</p>';
|
786 |
+
}
|
787 |
+
|
788 |
+
echo '</div>';
|
789 |
+
|
790 |
+
echo '</div>';
|
791 |
+
}
|
792 |
}
|
793 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
794 |
if ( ! function_exists( 'ot_type_custom_post_type_select' ) ) {
|
795 |
+
|
796 |
+
/**
|
797 |
+
* Custom Post Type Select option type.
|
798 |
+
*
|
799 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
800 |
+
*
|
801 |
+
* @param array $args An array of arguments.
|
802 |
+
*
|
803 |
+
* @access public
|
804 |
+
* @since 2.0
|
805 |
+
*/
|
806 |
+
function ot_type_custom_post_type_select( $args = array() ) {
|
807 |
+
|
808 |
+
// Turns arguments array into variables.
|
809 |
+
extract( $args ); // phpcs:ignore
|
810 |
+
|
811 |
+
// Verify a description.
|
812 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
813 |
+
|
814 |
+
// Format setting outer wrapper.
|
815 |
+
echo '<div class="format-setting type-custom-post-type-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
816 |
+
|
817 |
+
// Description.
|
818 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
819 |
+
|
820 |
+
// Format setting inner wrapper.
|
821 |
+
echo '<div class="format-setting-inner">';
|
822 |
+
|
823 |
+
// Build category.
|
824 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
825 |
+
|
826 |
+
// Setup the post types.
|
827 |
+
$post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' );
|
828 |
+
|
829 |
+
// Query posts array.
|
830 |
+
$my_posts = get_posts(
|
831 |
+
apply_filters(
|
832 |
+
'ot_type_custom_post_type_select_query',
|
833 |
+
array(
|
834 |
+
'post_type' => $post_type,
|
835 |
+
'posts_per_page' => -1,
|
836 |
+
'orderby' => 'title',
|
837 |
+
'order' => 'ASC',
|
838 |
+
'post_status' => 'any',
|
839 |
+
),
|
840 |
+
$field_id
|
841 |
+
)
|
842 |
+
);
|
843 |
+
|
844 |
+
// Has posts.
|
845 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
846 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
847 |
+
foreach ( $my_posts as $my_post ) {
|
848 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
849 |
+
echo '<option value="' . esc_attr( $my_post->ID ) . '" ' . selected( $field_value, $my_post->ID, false ) . '>' . esc_html( $post_title ) . '</option>';
|
850 |
+
}
|
851 |
+
} else {
|
852 |
+
echo '<option value="">' . esc_html__( 'No Posts Found', 'option-tree' ) . '</option>';
|
853 |
+
}
|
854 |
+
|
855 |
+
echo '</select>';
|
856 |
+
|
857 |
+
echo '</div>';
|
858 |
+
|
859 |
+
echo '</div>';
|
860 |
+
}
|
861 |
}
|
862 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
863 |
if ( ! function_exists( 'ot_type_date_picker' ) ) {
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Date Picker option type.
|
867 |
+
*
|
868 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
869 |
+
*
|
870 |
+
* @param array $args An array of arguments.
|
871 |
+
*
|
872 |
+
* @access public
|
873 |
+
* @since 2.3
|
874 |
+
*/
|
875 |
+
function ot_type_date_picker( $args = array() ) {
|
876 |
+
|
877 |
+
// Turns arguments array into variables.
|
878 |
+
extract( $args ); // phpcs:ignore
|
879 |
+
|
880 |
+
// Verify a description.
|
881 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
882 |
+
|
883 |
+
// Filter date format.
|
884 |
+
$date_format = apply_filters( 'ot_type_date_picker_date_format', 'yy-mm-dd', $field_id );
|
885 |
+
|
886 |
+
/**
|
887 |
+
* Filter the addition of the readonly attribute.
|
888 |
+
*
|
889 |
+
* @since 2.5.0
|
890 |
+
*
|
891 |
+
* @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'.
|
892 |
+
* @param string $field_id The field ID.
|
893 |
+
*/
|
894 |
+
$is_readonly = apply_filters( 'ot_type_date_picker_readonly', false, $field_id );
|
895 |
+
|
896 |
+
// Format setting outer wrapper.
|
897 |
+
echo '<div class="format-setting type-date-picker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
898 |
+
|
899 |
+
// Date picker JS.
|
900 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_date_picker("' . esc_attr( $field_id ) . '", "' . esc_attr( $date_format ) . '"); });</script>';
|
901 |
+
|
902 |
+
// Description.
|
903 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
904 |
+
|
905 |
+
// Format setting inner wrapper.
|
906 |
+
echo '<div class="format-setting-inner">';
|
907 |
+
|
908 |
+
// Build date picker.
|
909 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '"' . ( true === $is_readonly ? ' readonly' : '' ) . ' />';
|
910 |
+
|
911 |
+
echo '</div>';
|
912 |
+
|
913 |
+
echo '</div>';
|
914 |
+
}
|
915 |
}
|
916 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
917 |
if ( ! function_exists( 'ot_type_date_time_picker' ) ) {
|
918 |
+
|
919 |
+
/**
|
920 |
+
* Date Time Picker option type.
|
921 |
+
*
|
922 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
923 |
+
*
|
924 |
+
* @param array $args An array of arguments.
|
925 |
+
*
|
926 |
+
* @access public
|
927 |
+
* @since 2.3
|
928 |
+
*/
|
929 |
+
function ot_type_date_time_picker( $args = array() ) {
|
930 |
+
|
931 |
+
// Turns arguments array into variables.
|
932 |
+
extract( $args ); // phpcs:ignore
|
933 |
+
|
934 |
+
// Verify a description.
|
935 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
936 |
+
|
937 |
+
// Filter date format.
|
938 |
+
$date_format = apply_filters( 'ot_type_date_time_picker_date_format', 'yy-mm-dd', $field_id );
|
939 |
+
|
940 |
+
/**
|
941 |
+
* Filter the addition of the readonly attribute.
|
942 |
+
*
|
943 |
+
* @since 2.5.0
|
944 |
+
*
|
945 |
+
* @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'.
|
946 |
+
* @param string $field_id The field ID.
|
947 |
+
*/
|
948 |
+
$is_readonly = apply_filters( 'ot_type_date_time_picker_readonly', false, $field_id );
|
949 |
+
|
950 |
+
// Format setting outer wrapper.
|
951 |
+
echo '<div class="format-setting type-date-time-picker ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
952 |
+
|
953 |
+
// Date time picker JS.
|
954 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_date_time_picker("' . esc_attr( $field_id ) . '", "' . esc_attr( $date_format ) . '"); });</script>';
|
955 |
+
|
956 |
+
// Description.
|
957 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
958 |
+
|
959 |
+
// Format setting inner wrapper.
|
960 |
+
echo '<div class="format-setting-inner">';
|
961 |
+
|
962 |
+
// Build date time picker.
|
963 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '"' . ( true === $is_readonly ? ' readonly' : '' ) . ' />';
|
964 |
+
|
965 |
+
echo '</div>';
|
966 |
+
|
967 |
+
echo '</div>';
|
968 |
+
}
|
969 |
}
|
970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
if ( ! function_exists( 'ot_type_dimension' ) ) {
|
972 |
|
973 |
+
/**
|
974 |
+
* Dimension Option Type
|
975 |
+
*
|
976 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
977 |
+
*
|
978 |
+
* @param array $args The options arguments.
|
979 |
+
*
|
980 |
+
* @access public
|
981 |
+
* @since 2.5.0
|
982 |
+
*/
|
983 |
+
function ot_type_dimension( $args = array() ) {
|
984 |
+
|
985 |
+
// Turns arguments array into variables.
|
986 |
+
extract( $args ); // phpcs:ignore
|
987 |
|
988 |
+
// Verify a description.
|
989 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
990 |
|
991 |
+
// Format setting outer wrapper.
|
992 |
+
echo '<div class="format-setting type-dimension ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
993 |
|
994 |
+
// Description.
|
995 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
996 |
|
997 |
+
// Format setting inner wrapper.
|
998 |
+
echo '<div class="format-setting-inner">';
|
999 |
|
1000 |
+
// Allow fields to be filtered.
|
1001 |
+
$ot_recognized_dimension_fields = apply_filters(
|
1002 |
+
'ot_recognized_dimension_fields',
|
1003 |
+
array(
|
1004 |
+
'width',
|
1005 |
+
'height',
|
1006 |
+
'unit',
|
1007 |
+
),
|
1008 |
+
$field_id
|
1009 |
+
);
|
1010 |
|
1011 |
+
// Build width dimension.
|
1012 |
+
if ( in_array( 'width', $ot_recognized_dimension_fields, true ) ) {
|
|
|
|
|
|
|
|
|
1013 |
|
1014 |
+
$width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : '';
|
1015 |
+
echo '<div class="ot-option-group ot-option-group--one-third"><span class="ot-icon-arrows-h ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[width]" id="' . esc_attr( $field_id ) . '-width" value="' . esc_attr( $width ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'width', 'option-tree' ) . '" /></div>';
|
1016 |
+
}
|
1017 |
|
1018 |
+
// Build height dimension.
|
1019 |
+
if ( in_array( 'height', $ot_recognized_dimension_fields, true ) ) {
|
1020 |
|
1021 |
+
$height = isset( $field_value['height'] ) ? esc_attr( $field_value['height'] ) : '';
|
1022 |
+
echo '<div class="ot-option-group ot-option-group--one-third"><span class="ot-icon-arrows-v ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[height]" id="' . esc_attr( $field_id ) . '-height" value="' . esc_attr( $height ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'height', 'option-tree' ) . '" /></div>';
|
1023 |
+
}
|
1024 |
|
1025 |
+
// Build unit dropdown.
|
1026 |
+
if ( in_array( 'unit', $ot_recognized_dimension_fields, true ) ) {
|
1027 |
|
1028 |
+
echo '<div class="ot-option-group ot-option-group--one-third ot-option-group--is-last">';
|
|
|
1029 |
|
1030 |
+
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1031 |
|
1032 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
1033 |
|
1034 |
+
foreach ( ot_recognized_dimension_unit_types( $field_id ) as $unit ) {
|
1035 |
+
echo '<option value="' . esc_attr( $unit ) . '" ' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1036 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1037 |
|
1038 |
+
echo '</select>';
|
1039 |
|
1040 |
+
echo '</div>';
|
1041 |
+
}
|
1042 |
|
1043 |
+
echo '</div>';
|
1044 |
+
|
1045 |
+
echo '</div>';
|
1046 |
+
}
|
1047 |
}
|
1048 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1049 |
if ( ! function_exists( 'ot_type_gallery' ) ) {
|
1050 |
|
1051 |
+
/**
|
1052 |
+
* Gallery option type.
|
1053 |
+
*
|
1054 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1055 |
+
*
|
1056 |
+
* @param array $args The options arguments.
|
1057 |
+
*
|
1058 |
+
* @access public
|
1059 |
+
* @since 2.2.0
|
1060 |
+
*/
|
1061 |
+
function ot_type_gallery( $args = array() ) {
|
1062 |
+
|
1063 |
+
// Turns arguments array into variables.
|
1064 |
+
extract( $args ); // phpcs:ignore
|
1065 |
+
|
1066 |
+
// Verify a description.
|
1067 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1068 |
+
|
1069 |
+
// Format setting outer wrapper.
|
1070 |
+
echo '<div class="format-setting type-gallery ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1071 |
+
|
1072 |
+
// Description.
|
1073 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1074 |
+
|
1075 |
+
// Format setting inner wrapper.
|
1076 |
+
echo '<div class="format-setting-inner">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1077 |
|
1078 |
+
$field_value = trim( $field_value );
|
1079 |
+
|
1080 |
+
// Saved values.
|
1081 |
+
echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="ot-gallery-value ' . esc_attr( $field_class ) . '" />';
|
1082 |
+
|
1083 |
+
// Search the string for the IDs.
|
1084 |
+
preg_match( '/ids=\'(.*?)\'/', $field_value, $matches );
|
1085 |
+
|
1086 |
+
// Turn the field value into an array of IDs.
|
1087 |
+
if ( isset( $matches[1] ) ) {
|
1088 |
+
|
1089 |
+
// Found the IDs in the shortcode.
|
1090 |
+
$ids = explode( ',', $matches[1] );
|
1091 |
+
} else {
|
1092 |
+
|
1093 |
+
// The string is only IDs.
|
1094 |
+
$ids = ! empty( $field_value ) && '' !== $field_value ? explode( ',', $field_value ) : array();
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
// Has attachment IDs.
|
1098 |
+
if ( ! empty( $ids ) ) {
|
1099 |
+
|
1100 |
+
echo '<ul class="ot-gallery-list">';
|
1101 |
+
|
1102 |
+
foreach ( $ids as $id ) {
|
1103 |
+
|
1104 |
+
if ( '' === $id ) {
|
1105 |
+
continue;
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
|
1109 |
+
|
1110 |
+
echo '<li><img src="' . esc_url_raw( $thumbnail[0] ) . '" width="75" height="75" /></li>';
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
echo '</ul>';
|
1114 |
+
|
1115 |
+
echo '
|
1116 |
+
<div class="ot-gallery-buttons">
|
1117 |
+
<a href="#" class="option-tree-ui-button button button-secondary hug-left ot-gallery-delete">' . esc_html__( 'Delete Gallery', 'option-tree' ) . '</a>
|
1118 |
+
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . esc_html__( 'Edit Gallery', 'option-tree' ) . '</a>
|
1119 |
+
</div>';
|
1120 |
+
|
1121 |
+
} else {
|
1122 |
+
|
1123 |
+
echo '
|
1124 |
+
<div class="ot-gallery-buttons">
|
1125 |
+
<a href="#" class="option-tree-ui-button button button-primary right hug-right ot-gallery-edit">' . esc_html__( 'Create Gallery', 'option-tree' ) . '</a>
|
1126 |
+
</div>';
|
1127 |
+
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
echo '</div>';
|
1131 |
+
|
1132 |
+
echo '</div>';
|
1133 |
+
}
|
1134 |
}
|
1135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1136 |
if ( ! function_exists( 'ot_type_google_fonts' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1137 |
|
1138 |
+
/**
|
1139 |
+
* Google Fonts option type.
|
1140 |
+
*
|
1141 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1142 |
+
*
|
1143 |
+
* @param array $args An array of arguments.
|
1144 |
+
*
|
1145 |
+
* @access public
|
1146 |
+
* @since 2.5.0
|
1147 |
+
*/
|
1148 |
+
function ot_type_google_fonts( $args = array() ) {
|
1149 |
+
|
1150 |
+
// Turns arguments array into variables.
|
1151 |
+
extract( $args ); // phpcs:ignore
|
1152 |
+
|
1153 |
+
// Verify a description.
|
1154 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1155 |
+
|
1156 |
+
// Format setting outer wrapper.
|
1157 |
+
echo '<div class="format-setting type-google-font ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1158 |
+
|
1159 |
+
// Description.
|
1160 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1161 |
+
|
1162 |
+
// Format setting inner wrapper.
|
1163 |
+
echo '<div class="format-setting-inner">';
|
1164 |
+
|
1165 |
+
// Allow fields to be filtered.
|
1166 |
+
$ot_recognized_google_fonts_fields = apply_filters(
|
1167 |
+
'ot_recognized_google_font_fields',
|
1168 |
+
array(
|
1169 |
+
'variants',
|
1170 |
+
'subsets',
|
1171 |
+
),
|
1172 |
+
$field_id
|
1173 |
+
);
|
1174 |
+
|
1175 |
+
// Set a default to show at least one item.
|
1176 |
+
if ( ! is_array( $field_value ) || empty( $field_value ) ) {
|
1177 |
+
$field_value = array(
|
1178 |
+
array(
|
1179 |
+
'family' => '',
|
1180 |
+
'variants' => array(),
|
1181 |
+
'subsets' => array(),
|
1182 |
+
),
|
1183 |
+
);
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
foreach ( $field_value as $key => $value ) {
|
1187 |
+
|
1188 |
+
echo '<div class="type-google-font-group">';
|
1189 |
+
|
1190 |
+
// Build font family.
|
1191 |
+
$family = isset( $value['family'] ) ? $value['family'] : '';
|
1192 |
+
echo '<div class="option-tree-google-font-family">';
|
1193 |
+
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . esc_html__( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1194 |
+
echo '<select name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][family]" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1195 |
+
echo '<option value="">' . esc_html__( '-- Choose One --', 'option-tree' ) . '</option>';
|
1196 |
+
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1197 |
+
echo '<option value="' . esc_attr( $family_key ) . '" ' . selected( $family, $family_key, false ) . '>' . esc_html( $family_value ) . '</option>';
|
1198 |
+
}
|
1199 |
+
echo '</select>';
|
1200 |
+
echo '</div>';
|
1201 |
+
|
1202 |
+
// Build font variants.
|
1203 |
+
if ( in_array( 'variants', $ot_recognized_google_fonts_fields, true ) ) {
|
1204 |
+
$variants = isset( $value['variants'] ) ? $value['variants'] : array();
|
1205 |
+
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-" data-field-name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1206 |
+
foreach ( ot_recognized_google_font_variants( $field_id, $family ) as $variant_key => $variant ) {
|
1207 |
+
echo '<p class="checkbox-wrap">';
|
1208 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][variants][]" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $variant ) . '" value="' . esc_attr( $variant ) . '" ' . checked( in_array( $variant, $variants, true ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1209 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $variant ) . '">' . esc_html( $variant ) . '</label>';
|
1210 |
+
echo '</p>';
|
1211 |
+
}
|
1212 |
+
echo '</div>';
|
1213 |
+
}
|
1214 |
+
|
1215 |
+
// Build font subsets.
|
1216 |
+
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields, true ) ) {
|
1217 |
+
$subsets = isset( $value['subsets'] ) ? $value['subsets'] : array();
|
1218 |
+
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-" data-field-name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1219 |
+
foreach ( ot_recognized_google_font_subsets( $field_id, $family ) as $subset_key => $subset ) {
|
1220 |
+
echo '<p class="checkbox-wrap">';
|
1221 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $key ) . '][subsets][]" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $subset ) . '" value="' . esc_attr( $subset ) . '" ' . checked( in_array( $subset, $subsets, true ), true, false ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1222 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '-' . esc_attr( $subset ) . '">' . esc_html( $subset ) . '</label>';
|
1223 |
+
echo '</p>';
|
1224 |
+
}
|
1225 |
+
echo '</div>';
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
echo '</div>';
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
echo '<div class="type-google-font-group-clone">';
|
1232 |
+
|
1233 |
+
/* build font family */
|
1234 |
+
echo '<div class="option-tree-google-font-family">';
|
1235 |
+
echo '<a href="javascript:void(0);" class="js-remove-google-font option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Google Font', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"/>' . esc_html__( 'Remove Google Font', 'option-tree' ) . '</a>';
|
1236 |
+
echo '<select name="' . esc_attr( $field_name ) . '[%key%][family]" id="' . esc_attr( $field_id ) . '-%key%" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1237 |
+
echo '<option value="">' . esc_html__( '-- Choose One --', 'option-tree' ) . '</option>';
|
1238 |
+
|
1239 |
+
foreach ( ot_recognized_google_font_families( $field_id ) as $family_key => $family_value ) {
|
1240 |
+
echo '<option value="' . esc_attr( $family_key ) . '">' . esc_html( $family_value ) . '</option>';
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
echo '</select>';
|
1244 |
+
echo '</div>';
|
1245 |
+
|
1246 |
+
// Build font variants.
|
1247 |
+
if ( in_array( 'variants', $ot_recognized_google_fonts_fields, true ) ) {
|
1248 |
+
echo '<div class="option-tree-google-font-variants" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][variants]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1249 |
+
echo '</div>';
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
// Build font subsets.
|
1253 |
+
if ( in_array( 'subsets', $ot_recognized_google_fonts_fields, true ) ) {
|
1254 |
+
echo '<div class="option-tree-google-font-subsets" data-field-id-prefix="' . esc_attr( $field_id ) . '-%key%-" data-field-name="' . esc_attr( $field_name ) . '[%key%][subsets]" data-field-class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '">';
|
1255 |
+
echo '</div>';
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
echo '</div>';
|
1259 |
+
|
1260 |
+
echo '<a href="javascript:void(0);" class="js-add-google-font option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add Google Font', 'option-tree' ) . '">' . esc_html__( 'Add Google Font', 'option-tree' ) . '</a>';
|
1261 |
+
|
1262 |
+
echo '</div>';
|
1263 |
+
|
1264 |
+
echo '</div>';
|
1265 |
+
}
|
1266 |
}
|
1267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1268 |
if ( ! function_exists( 'ot_type_javascript' ) ) {
|
1269 |
+
|
1270 |
+
/**
|
1271 |
+
* JavaScript option type.
|
1272 |
+
*
|
1273 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1274 |
+
*
|
1275 |
+
* @param array $args An array of arguments.
|
1276 |
+
*
|
1277 |
+
* @access public
|
1278 |
+
* @since 2.5.0
|
1279 |
+
*/
|
1280 |
+
function ot_type_javascript( $args = array() ) {
|
1281 |
+
|
1282 |
+
// Turns arguments array into variables.
|
1283 |
+
extract( $args ); // phpcs:ignore
|
1284 |
+
|
1285 |
+
// Verify a description.
|
1286 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1287 |
+
|
1288 |
+
// Format setting outer wrapper.
|
1289 |
+
echo '<div class="format-setting type-javascript simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1290 |
+
|
1291 |
+
// Description.
|
1292 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1293 |
+
|
1294 |
+
// Format setting inner wrapper.
|
1295 |
+
echo '<div class="format-setting-inner">';
|
1296 |
+
|
1297 |
+
// Build textarea for CSS.
|
1298 |
+
echo '<textarea class="hidden" id="textarea_' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '">' . esc_textarea( $field_value ) . '</textarea>';
|
1299 |
+
|
1300 |
+
// Build pre to convert it into ace editor later.
|
1301 |
+
echo '<pre class="ot-javascript-editor ' . esc_attr( $field_class ) . '" id="' . esc_attr( $field_id ) . '">' . esc_textarea( $field_value ) . '</pre>';
|
1302 |
+
|
1303 |
+
echo '</div>';
|
1304 |
+
|
1305 |
+
echo '</div>';
|
1306 |
+
}
|
1307 |
}
|
1308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1309 |
if ( ! function_exists( 'ot_type_link_color' ) ) {
|
1310 |
|
1311 |
+
/**
|
1312 |
+
* Link Color option type.
|
1313 |
+
*
|
1314 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1315 |
+
*
|
1316 |
+
* @param array $args The options arguments.
|
1317 |
+
*
|
1318 |
+
* @access public
|
1319 |
+
* @since 2.5.0
|
1320 |
+
*/
|
1321 |
+
function ot_type_link_color( $args = array() ) {
|
1322 |
+
|
1323 |
+
// Turns arguments array into variables.
|
1324 |
+
extract( $args ); // phpcs:ignore
|
1325 |
+
|
1326 |
+
// Verify a description.
|
1327 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1328 |
+
|
1329 |
+
// Format setting outer wrapper.
|
1330 |
+
echo '<div class="format-setting type-link-color ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1331 |
+
|
1332 |
+
// Description.
|
1333 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1334 |
+
|
1335 |
+
// Format setting inner wrapper.
|
1336 |
+
echo '<div class="format-setting-inner">';
|
1337 |
+
|
1338 |
+
// Allow fields to be filtered.
|
1339 |
+
$ot_recognized_link_color_fields = apply_filters(
|
1340 |
+
'ot_recognized_link_color_fields',
|
1341 |
+
array(
|
1342 |
+
'link' => _x( 'Standard', 'color picker', 'option-tree' ),
|
1343 |
+
'hover' => _x( 'Hover', 'color picker', 'option-tree' ),
|
1344 |
+
'active' => _x( 'Active', 'color picker', 'option-tree' ),
|
1345 |
+
'visited' => _x( 'Visited', 'color picker', 'option-tree' ),
|
1346 |
+
'focus' => _x( 'Focus', 'color picker', 'option-tree' ),
|
1347 |
+
),
|
1348 |
+
$field_id
|
1349 |
+
);
|
1350 |
+
|
1351 |
+
// Build link color fields.
|
1352 |
+
foreach ( $ot_recognized_link_color_fields as $type => $label ) {
|
1353 |
+
|
1354 |
+
if ( array_key_exists( $type, $ot_recognized_link_color_fields ) ) {
|
1355 |
+
|
1356 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
1357 |
+
|
1358 |
+
echo '<label for="' . esc_attr( $field_id ) . '-picker-' . esc_attr( $type ) . '" class="option-tree-ui-colorpicker-label">' . esc_attr( $label ) . '</label>';
|
1359 |
+
|
1360 |
+
// Colorpicker JS.
|
1361 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker-' . esc_attr( $type ) . '"); });</script>';
|
1362 |
+
|
1363 |
+
// Set color.
|
1364 |
+
$color = isset( $field_value[ $type ] ) ? esc_attr( $field_value[ $type ] ) : '';
|
1365 |
+
|
1366 |
+
// Set default color.
|
1367 |
+
$std = isset( $field_std[ $type ] ) ? 'data-default-color="' . $field_std[ $type ] . '"' : '';
|
1368 |
+
|
1369 |
+
// Input.
|
1370 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[' . esc_attr( $type ) . ']" id="' . esc_attr( $field_id ) . '-picker-' . esc_attr( $type ) . '" value="' . esc_attr( $color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" ' . esc_attr( $std ) . ' />';
|
1371 |
+
|
1372 |
+
echo '</div>';
|
1373 |
+
|
1374 |
+
}
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
echo '</div>';
|
1378 |
+
|
1379 |
+
echo '</div>';
|
1380 |
+
}
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
if ( ! function_exists( 'ot_type_list_item' ) ) {
|
1384 |
+
|
1385 |
+
/**
|
1386 |
+
* List Item option type.
|
1387 |
+
*
|
1388 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1389 |
+
*
|
1390 |
+
* @param array $args An array of arguments.
|
1391 |
+
*
|
1392 |
+
* @access public
|
1393 |
+
* @since 2.0
|
1394 |
+
*/
|
1395 |
+
function ot_type_list_item( $args = array() ) {
|
1396 |
+
|
1397 |
+
// Turns arguments array into variables.
|
1398 |
+
extract( $args ); // phpcs:ignore
|
1399 |
+
|
1400 |
+
// Verify a description.
|
1401 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1402 |
+
|
1403 |
+
// Default.
|
1404 |
+
$sortable = true;
|
1405 |
+
|
1406 |
+
// Check if the list can be sorted.
|
1407 |
+
if ( ! empty( $field_class ) ) {
|
1408 |
+
$classes = explode( ' ', $field_class );
|
1409 |
+
if ( in_array( 'not-sortable', $classes, true ) ) {
|
1410 |
+
$sortable = false;
|
1411 |
+
str_replace( 'not-sortable', '', $field_class );
|
1412 |
+
}
|
1413 |
+
}
|
1414 |
+
|
1415 |
+
// Format setting outer wrapper.
|
1416 |
+
echo '<div class="format-setting type-list-item ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1417 |
+
|
1418 |
+
// Description.
|
1419 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1420 |
+
|
1421 |
+
// Format setting inner wrapper.
|
1422 |
+
echo '<div class="format-setting-inner">';
|
1423 |
+
|
1424 |
+
// Pass the settings array arround.
|
1425 |
+
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . esc_attr( ot_encode( $field_settings ) ) . '" />';
|
1426 |
+
|
1427 |
+
/**
|
1428 |
+
* Settings pages have array wrappers like 'option_tree'.
|
1429 |
+
* So we need that value to create a proper array to save to.
|
1430 |
+
* This is only for NON metabox settings.
|
1431 |
+
*/
|
1432 |
+
if ( ! isset( $get_option ) ) {
|
1433 |
+
$get_option = '';
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
// Build list items.
|
1437 |
+
echo '<ul class="option-tree-setting-wrap' . ( $sortable ? ' option-tree-sortable' : '' ) . '" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
1438 |
+
|
1439 |
+
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
1440 |
+
|
1441 |
+
foreach ( $field_value as $key => $list_item ) {
|
1442 |
+
|
1443 |
+
echo '<li class="ui-state-default list-list-item">';
|
1444 |
+
ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type );
|
1445 |
+
echo '</li>';
|
1446 |
+
}
|
1447 |
+
}
|
1448 |
+
|
1449 |
+
echo '</ul>';
|
1450 |
+
|
1451 |
+
// Button.
|
1452 |
+
echo '<a href="javascript:void(0);" class="option-tree-list-item-add option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add New', 'option-tree' ) . '">' . esc_html__( 'Add New', 'option-tree' ) . '</a>';
|
1453 |
+
|
1454 |
+
// Description.
|
1455 |
+
$list_desc = $sortable ? __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) : '';
|
1456 |
+
echo '<div class="list-item-description">' . esc_html( apply_filters( 'ot_list_item_description', $list_desc, $field_id ) ) . '</div>';
|
1457 |
+
|
1458 |
+
echo '</div>';
|
1459 |
+
|
1460 |
+
echo '</div>';
|
1461 |
+
}
|
1462 |
+
}
|
1463 |
+
|
1464 |
+
if ( ! function_exists( 'ot_type_measurement' ) ) {
|
1465 |
+
|
1466 |
+
/**
|
1467 |
+
* Measurement option type.
|
1468 |
+
*
|
1469 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1470 |
+
*
|
1471 |
+
* @param array $args An array of arguments.
|
1472 |
+
*
|
1473 |
+
* @access public
|
1474 |
+
* @since 2.0
|
1475 |
+
*/
|
1476 |
+
function ot_type_measurement( $args = array() ) {
|
1477 |
+
|
1478 |
+
// Turns arguments array into variables.
|
1479 |
+
extract( $args ); // phpcs:ignore
|
1480 |
+
|
1481 |
+
// Verify a description.
|
1482 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1483 |
|
1484 |
+
// Format setting outer wrapper.
|
1485 |
+
echo '<div class="format-setting type-measurement ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1486 |
|
1487 |
+
// Description.
|
1488 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1489 |
|
1490 |
+
// Format setting inner wrapper.
|
1491 |
+
echo '<div class="format-setting-inner">';
|
1492 |
|
1493 |
+
echo '<div class="option-tree-ui-measurement-input-wrap">';
|
|
|
1494 |
|
1495 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[0]" id="' . esc_attr( $field_id ) . '-0" value="' . esc_attr( ( isset( $field_value[0] ) ? $field_value[0] : '' ) ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" />';
|
|
|
1496 |
|
1497 |
+
echo '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1498 |
|
1499 |
+
// Build measurement.
|
1500 |
+
echo '<select name="' . esc_attr( $field_name ) . '[1]" id="' . esc_attr( $field_id ) . '-1" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1501 |
|
1502 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
|
|
|
|
1503 |
|
1504 |
+
foreach ( ot_measurement_unit_types( $field_id ) as $unit ) {
|
1505 |
+
echo '<option value="' . esc_attr( $unit ) . '" ' . ( isset( $field_value[1] ) ? selected( $field_value[1], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
1506 |
+
}
|
1507 |
|
1508 |
+
echo '</select>';
|
|
|
1509 |
|
1510 |
+
echo '</div>';
|
|
|
|
|
|
|
|
|
1511 |
|
1512 |
+
echo '</div>';
|
1513 |
+
}
|
1514 |
+
}
|
1515 |
|
1516 |
+
if ( ! function_exists( 'ot_type_numeric_slider' ) ) {
|
1517 |
|
1518 |
+
/**
|
1519 |
+
* Numeric Slider option type.
|
1520 |
+
*
|
1521 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1522 |
+
*
|
1523 |
+
* @param array $args An array of arguments.
|
1524 |
+
*
|
1525 |
+
* @access public
|
1526 |
+
* @since 2.1
|
1527 |
+
*/
|
1528 |
+
function ot_type_numeric_slider( $args = array() ) {
|
1529 |
|
1530 |
+
// Turns arguments array into variables.
|
1531 |
+
extract( $args ); // phpcs:ignore
|
1532 |
|
1533 |
+
// Verify a description.
|
1534 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1535 |
|
1536 |
+
$_options = explode( ',', $field_min_max_step );
|
1537 |
+
$min = isset( $_options[0] ) ? $_options[0] : 0;
|
1538 |
+
$max = isset( $_options[1] ) ? $_options[1] : 100;
|
1539 |
+
$step = isset( $_options[2] ) ? $_options[2] : 1;
|
1540 |
|
1541 |
+
// Format setting outer wrapper.
|
1542 |
+
echo '<div class="format-setting type-numeric-slider ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1543 |
|
1544 |
+
// Description.
|
1545 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1546 |
|
1547 |
+
// Format setting inner wrapper.
|
1548 |
+
echo '<div class="format-setting-inner">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1549 |
|
1550 |
+
echo '<div class="ot-numeric-slider-wrap">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1551 |
|
1552 |
+
echo '<input type="hidden" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="ot-numeric-slider-hidden-input" value="' . esc_attr( $field_value ) . '" data-min="' . esc_attr( $min ) . '" data-max="' . esc_attr( $max ) . '" data-step="' . esc_attr( $step ) . '">';
|
1553 |
+
|
1554 |
+
echo '<input type="text" class="ot-numeric-slider-helper-input widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" value="' . esc_attr( $field_value ) . '" readonly>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1555 |
|
1556 |
+
echo '<div id="ot_numeric_slider_' . esc_attr( $field_id ) . '" class="ot-numeric-slider"></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1557 |
|
1558 |
+
echo '</div>';
|
1559 |
+
|
1560 |
+
echo '</div>';
|
1561 |
+
|
1562 |
+
echo '</div>';
|
1563 |
+
}
|
1564 |
}
|
1565 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1566 |
if ( ! function_exists( 'ot_type_on_off' ) ) {
|
1567 |
|
1568 |
+
/**
|
1569 |
+
* On/Off option type
|
1570 |
+
*
|
1571 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1572 |
+
*
|
1573 |
+
* @param array $args The options arguments.
|
1574 |
+
*
|
1575 |
+
* @access public
|
1576 |
+
* @since 2.2.0
|
1577 |
+
*/
|
1578 |
+
function ot_type_on_off( $args = array() ) {
|
1579 |
+
|
1580 |
+
// Turns arguments array into variables.
|
1581 |
+
extract( $args ); // phpcs:ignore
|
1582 |
+
|
1583 |
+
// Verify a description.
|
1584 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1585 |
+
|
1586 |
+
// Format setting outer wrapper.
|
1587 |
+
echo '<div class="format-setting type-radio ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1588 |
+
|
1589 |
+
// Description.
|
1590 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1591 |
+
|
1592 |
+
// Format setting inner wrapper.
|
1593 |
+
echo '<div class="format-setting-inner">';
|
1594 |
+
|
1595 |
+
// Force only two choices, and allowing filtering on the choices value & label.
|
1596 |
+
$field_choices = array(
|
1597 |
+
array(
|
1598 |
+
/**
|
1599 |
+
* Filter the value of the On button.
|
1600 |
+
*
|
1601 |
+
* @since 2.5.0
|
1602 |
+
*
|
1603 |
+
* @param string $value The On button value. Default 'on'.
|
1604 |
+
* @param string $field_id The field ID.
|
1605 |
+
* @param string $filter_id For filtering both on/off value with one function.
|
1606 |
+
*/
|
1607 |
+
'value' => apply_filters( 'ot_on_off_switch_on_value', 'on', $field_id, 'on' ),
|
1608 |
+
/**
|
1609 |
+
* Filter the label of the On button.
|
1610 |
+
*
|
1611 |
+
* @since 2.5.0
|
1612 |
+
*
|
1613 |
+
* @param string $label The On button label. Default 'On'.
|
1614 |
+
* @param string $field_id The field ID.
|
1615 |
+
* @param string $filter_id For filtering both on/off label with one function.
|
1616 |
+
*/
|
1617 |
+
'label' => apply_filters( 'ot_on_off_switch_on_label', esc_html__( 'On', 'option-tree' ), $field_id, 'on' ),
|
1618 |
+
),
|
1619 |
+
array(
|
1620 |
+
/**
|
1621 |
+
* Filter the value of the Off button.
|
1622 |
+
*
|
1623 |
+
* @since 2.5.0
|
1624 |
+
*
|
1625 |
+
* @param string $value The Off button value. Default 'off'.
|
1626 |
+
* @param string $field_id The field ID.
|
1627 |
+
* @param string $filter_id For filtering both on/off value with one function.
|
1628 |
+
*/
|
1629 |
+
'value' => apply_filters( 'ot_on_off_switch_off_value', 'off', $field_id, 'off' ),
|
1630 |
+
/**
|
1631 |
+
* Filter the label of the Off button.
|
1632 |
+
*
|
1633 |
+
* @since 2.5.0
|
1634 |
+
*
|
1635 |
+
* @param string $label The Off button label. Default 'Off'.
|
1636 |
+
* @param string $field_id The field ID.
|
1637 |
+
* @param string $filter_id For filtering both on/off label with one function.
|
1638 |
+
*/
|
1639 |
+
'label' => apply_filters( 'ot_on_off_switch_off_label', esc_html__( 'Off', 'option-tree' ), $field_id, 'off' ),
|
1640 |
+
),
|
1641 |
+
);
|
1642 |
+
|
1643 |
+
/**
|
1644 |
+
* Filter the width of the On/Off switch.
|
1645 |
+
*
|
1646 |
+
* @since 2.5.0
|
1647 |
+
*
|
1648 |
+
* @param string $switch_width The switch width. Default '100px'.
|
1649 |
+
* @param string $field_id The field ID.
|
1650 |
+
*/
|
1651 |
+
$switch_width = apply_filters( 'ot_on_off_switch_width', '100px', $field_id );
|
1652 |
+
|
1653 |
+
echo '<div class="on-off-switch"' . ( '100px' !== $switch_width ? sprintf( ' style="width:%s"', esc_attr( $switch_width ) ) : '' ) . '>'; // phpcs:ignore
|
1654 |
+
|
1655 |
+
// Build radio.
|
1656 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
1657 |
+
echo '
|
1658 |
+
<input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . checked( $field_value, $choice['value'], false ) . ' class="radio option-tree-ui-radio ' . esc_attr( $field_class ) . '" />
|
1659 |
<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" onclick="">' . esc_attr( $choice['label'] ) . '</label>';
|
1660 |
+
}
|
|
|
|
|
1661 |
|
1662 |
+
echo '<span class="slide-button"></span>';
|
1663 |
|
1664 |
+
echo '</div>';
|
1665 |
|
1666 |
+
echo '</div>';
|
1667 |
|
1668 |
+
echo '</div>';
|
1669 |
|
1670 |
+
}
|
1671 |
}
|
1672 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1673 |
if ( ! function_exists( 'ot_type_page_checkbox' ) ) {
|
1674 |
+
|
1675 |
+
/**
|
1676 |
+
* Page Checkbox option type.
|
1677 |
+
*
|
1678 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1679 |
+
*
|
1680 |
+
* @param array $args An array of arguments.
|
1681 |
+
*
|
1682 |
+
* @access public
|
1683 |
+
* @since 2.0
|
1684 |
+
*/
|
1685 |
+
function ot_type_page_checkbox( $args = array() ) {
|
1686 |
+
|
1687 |
+
// Turns arguments array into variables.
|
1688 |
+
extract( $args ); // phpcs:ignore
|
1689 |
+
|
1690 |
+
// Verify a description.
|
1691 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1692 |
+
|
1693 |
+
// Format setting outer wrapper.
|
1694 |
+
echo '<div class="format-setting type-page-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1695 |
+
|
1696 |
+
// Description.
|
1697 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1698 |
+
|
1699 |
+
// Format setting inner wrapper.
|
1700 |
+
echo '<div class="format-setting-inner">';
|
1701 |
+
|
1702 |
+
// Query pages array.
|
1703 |
+
$my_posts = get_posts(
|
1704 |
+
apply_filters(
|
1705 |
+
'ot_type_page_checkbox_query',
|
1706 |
+
array(
|
1707 |
+
'post_type' => array( 'page' ),
|
1708 |
+
'posts_per_page' => -1,
|
1709 |
+
'orderby' => 'title',
|
1710 |
+
'order' => 'ASC',
|
1711 |
+
'post_status' => 'any',
|
1712 |
+
),
|
1713 |
+
$field_id
|
1714 |
+
)
|
1715 |
+
);
|
1716 |
+
|
1717 |
+
// Has pages.
|
1718 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1719 |
+
foreach ( $my_posts as $my_post ) {
|
1720 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1721 |
+
echo '<p>';
|
1722 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[ $my_post->ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1723 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . esc_html( $post_title ) . '</label>';
|
1724 |
+
echo '</p>';
|
1725 |
+
}
|
1726 |
+
} else {
|
1727 |
+
echo '<p>' . esc_html__( 'No Pages Found', 'option-tree' ) . '</p>';
|
1728 |
+
}
|
1729 |
+
|
1730 |
+
echo '</div>';
|
1731 |
+
|
1732 |
+
echo '</div>';
|
1733 |
+
}
|
1734 |
}
|
1735 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1736 |
if ( ! function_exists( 'ot_type_page_select' ) ) {
|
1737 |
+
|
1738 |
+
/**
|
1739 |
+
* Page Select option type.
|
1740 |
+
*
|
1741 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1742 |
+
*
|
1743 |
+
* @param array $args An array of arguments.
|
1744 |
+
*
|
1745 |
+
* @access public
|
1746 |
+
* @since 2.0
|
1747 |
+
*/
|
1748 |
+
function ot_type_page_select( $args = array() ) {
|
1749 |
+
|
1750 |
+
// Turns arguments array into variables.
|
1751 |
+
extract( $args ); // phpcs:ignore
|
1752 |
+
|
1753 |
+
// Verify a description.
|
1754 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1755 |
+
|
1756 |
+
// Format setting outer wrapper.
|
1757 |
+
echo '<div class="format-setting type-page-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1758 |
+
|
1759 |
+
// Description.
|
1760 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1761 |
+
|
1762 |
+
// Format setting inner wrapper.
|
1763 |
+
echo '<div class="format-setting-inner">';
|
1764 |
+
|
1765 |
+
// Build page select.
|
1766 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1767 |
+
|
1768 |
+
// Query pages array.
|
1769 |
+
$my_posts = get_posts(
|
1770 |
+
apply_filters(
|
1771 |
+
'ot_type_page_select_query',
|
1772 |
+
array(
|
1773 |
+
'post_type' => array( 'page' ),
|
1774 |
+
'posts_per_page' => -1,
|
1775 |
+
'orderby' => 'title',
|
1776 |
+
'order' => 'ASC',
|
1777 |
+
'post_status' => 'any',
|
1778 |
+
),
|
1779 |
+
$field_id
|
1780 |
+
)
|
1781 |
+
);
|
1782 |
+
|
1783 |
+
// Has pages.
|
1784 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1785 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
1786 |
+
foreach ( $my_posts as $my_post ) {
|
1787 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1788 |
+
echo '<option value="' . esc_attr( $my_post->ID ) . '" ' . selected( $field_value, $my_post->ID, false ) . '>' . esc_html( $post_title ) . '</option>';
|
1789 |
+
}
|
1790 |
+
} else {
|
1791 |
+
echo '<option value="">' . esc_html__( 'No Pages Found', 'option-tree' ) . '</option>';
|
1792 |
+
}
|
1793 |
+
|
1794 |
+
echo '</select>';
|
1795 |
+
|
1796 |
+
echo '</div>';
|
1797 |
+
|
1798 |
+
echo '</div>';
|
1799 |
+
}
|
1800 |
}
|
1801 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1802 |
if ( ! function_exists( 'ot_type_post_checkbox' ) ) {
|
1803 |
+
|
1804 |
+
/**
|
1805 |
+
* Post Checkbox option type.
|
1806 |
+
*
|
1807 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1808 |
+
*
|
1809 |
+
* @param array $args An array of arguments.
|
1810 |
+
*
|
1811 |
+
* @access public
|
1812 |
+
* @since 2.0
|
1813 |
+
*/
|
1814 |
+
function ot_type_post_checkbox( $args = array() ) {
|
1815 |
+
|
1816 |
+
// Turns arguments array into variables.
|
1817 |
+
extract( $args ); // phpcs:ignore
|
1818 |
+
|
1819 |
+
// Verify a description.
|
1820 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1821 |
+
|
1822 |
+
// Format setting outer wrapper.
|
1823 |
+
echo '<div class="format-setting type-post-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1824 |
+
|
1825 |
+
// Description.
|
1826 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1827 |
+
|
1828 |
+
// Format setting inner wrapper.
|
1829 |
+
echo '<div class="format-setting-inner">';
|
1830 |
+
|
1831 |
+
// Query posts array.
|
1832 |
+
$my_posts = get_posts(
|
1833 |
+
apply_filters(
|
1834 |
+
'ot_type_post_checkbox_query',
|
1835 |
+
array(
|
1836 |
+
'post_type' => array( 'post' ),
|
1837 |
+
'posts_per_page' => -1,
|
1838 |
+
'orderby' => 'title',
|
1839 |
+
'order' => 'ASC',
|
1840 |
+
'post_status' => 'any',
|
1841 |
+
),
|
1842 |
+
$field_id
|
1843 |
+
)
|
1844 |
+
);
|
1845 |
+
|
1846 |
+
// Has posts.
|
1847 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1848 |
+
foreach ( $my_posts as $my_post ) {
|
1849 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1850 |
+
echo '<p>';
|
1851 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $my_post->ID ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '" value="' . esc_attr( $my_post->ID ) . '" ' . ( isset( $field_value[ $my_post->ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
1852 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $my_post->ID ) . '">' . esc_html( $post_title ) . '</label>';
|
1853 |
+
echo '</p>';
|
1854 |
+
}
|
1855 |
+
} else {
|
1856 |
+
echo '<p>' . esc_html__( 'No Posts Found', 'option-tree' ) . '</p>';
|
1857 |
+
}
|
1858 |
+
|
1859 |
+
echo '</div>';
|
1860 |
+
|
1861 |
+
echo '</div>';
|
1862 |
+
}
|
1863 |
}
|
1864 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1865 |
if ( ! function_exists( 'ot_type_post_select' ) ) {
|
1866 |
+
|
1867 |
+
/**
|
1868 |
+
* Post Select option type.
|
1869 |
+
*
|
1870 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1871 |
+
*
|
1872 |
+
* @param array $args An array of arguments.
|
1873 |
+
*
|
1874 |
+
* @access public
|
1875 |
+
* @since 2.0
|
1876 |
+
*/
|
1877 |
+
function ot_type_post_select( $args = array() ) {
|
1878 |
+
|
1879 |
+
// Turns arguments array into variables.
|
1880 |
+
extract( $args ); // phpcs:ignore
|
1881 |
+
|
1882 |
+
// Verify a description.
|
1883 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1884 |
+
|
1885 |
+
// Format setting outer wrapper.
|
1886 |
+
echo '<div class="format-setting type-post-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1887 |
+
|
1888 |
+
/* description */
|
1889 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1890 |
+
|
1891 |
+
// Format setting inner wrapper.
|
1892 |
+
echo '<div class="format-setting-inner">';
|
1893 |
+
|
1894 |
+
// Build page select.
|
1895 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
1896 |
+
|
1897 |
+
// Query posts array.
|
1898 |
+
$my_posts = get_posts(
|
1899 |
+
apply_filters(
|
1900 |
+
'ot_type_post_select_query',
|
1901 |
+
array(
|
1902 |
+
'post_type' => array( 'post' ),
|
1903 |
+
'posts_per_page' => -1,
|
1904 |
+
'orderby' => 'title',
|
1905 |
+
'order' => 'ASC',
|
1906 |
+
'post_status' => 'any',
|
1907 |
+
),
|
1908 |
+
$field_id
|
1909 |
+
)
|
1910 |
+
);
|
1911 |
+
|
1912 |
+
// Has posts.
|
1913 |
+
if ( is_array( $my_posts ) && ! empty( $my_posts ) ) {
|
1914 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
1915 |
+
foreach ( $my_posts as $my_post ) {
|
1916 |
+
$post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled';
|
1917 |
+
echo '<option value="' . esc_attr( $my_post->ID ) . '" ' . selected( $field_value, $my_post->ID, false ) . '>' . esc_html( $post_title ) . '</option>';
|
1918 |
+
}
|
1919 |
+
} else {
|
1920 |
+
echo '<option value="">' . esc_html__( 'No Posts Found', 'option-tree' ) . '</option>';
|
1921 |
+
}
|
1922 |
+
|
1923 |
+
echo '</select>';
|
1924 |
+
|
1925 |
+
echo '</div>';
|
1926 |
+
|
1927 |
+
echo '</div>';
|
1928 |
+
}
|
1929 |
}
|
1930 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1931 |
if ( ! function_exists( 'ot_type_radio' ) ) {
|
1932 |
+
|
1933 |
+
/**
|
1934 |
+
* Radio option type.
|
1935 |
+
*
|
1936 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1937 |
+
*
|
1938 |
+
* @param array $args An array of arguments.
|
1939 |
+
*
|
1940 |
+
* @access public
|
1941 |
+
* @since 2.0
|
1942 |
+
*/
|
1943 |
+
function ot_type_radio( $args = array() ) {
|
1944 |
+
|
1945 |
+
// Turns arguments array into variables.
|
1946 |
+
extract( $args ); // phpcs:ignore
|
1947 |
+
|
1948 |
+
// Verify a description.
|
1949 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1950 |
+
|
1951 |
+
// Format setting outer wrapper.
|
1952 |
+
echo '<div class="format-setting type-radio ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1953 |
+
|
1954 |
+
// Description.
|
1955 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1956 |
+
|
1957 |
+
// Format setting inner wrapper.
|
1958 |
+
echo '<div class="format-setting-inner">';
|
1959 |
+
|
1960 |
+
// Build radio.
|
1961 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
1962 |
+
echo '<p><input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . checked( $field_value, $choice['value'], false ) . ' class="radio option-tree-ui-radio ' . esc_attr( $field_class ) . '" /><label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label></p>';
|
1963 |
+
}
|
1964 |
+
|
1965 |
+
echo '</div>';
|
1966 |
+
|
1967 |
+
echo '</div>';
|
1968 |
+
}
|
1969 |
}
|
1970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1971 |
if ( ! function_exists( 'ot_type_radio_image' ) ) {
|
1972 |
+
|
1973 |
+
/**
|
1974 |
+
* Radio Images option type.
|
1975 |
+
*
|
1976 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
1977 |
+
*
|
1978 |
+
* @param array $args An array of arguments.
|
1979 |
+
*
|
1980 |
+
* @access public
|
1981 |
+
* @since 2.0
|
1982 |
+
*/
|
1983 |
+
function ot_type_radio_image( $args = array() ) {
|
1984 |
+
|
1985 |
+
// Turns arguments array into variables.
|
1986 |
+
extract( $args ); // phpcs:ignore
|
1987 |
+
|
1988 |
+
// Verify a description.
|
1989 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
1990 |
+
|
1991 |
+
// Format setting outer wrapper.
|
1992 |
+
echo '<div class="format-setting type-radio-image ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
1993 |
+
|
1994 |
+
// Description.
|
1995 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
1996 |
+
|
1997 |
+
// Format setting inner wrapper.
|
1998 |
+
echo '<div class="format-setting-inner">';
|
1999 |
+
|
2000 |
+
/**
|
2001 |
+
* Load the default filterable images if nothing
|
2002 |
+
* has been set in the choices array.
|
2003 |
+
*/
|
2004 |
+
if ( empty( $field_choices ) ) {
|
2005 |
+
$field_choices = ot_radio_images( $field_id );
|
2006 |
+
}
|
2007 |
+
|
2008 |
+
// Build radio image.
|
2009 |
+
foreach ( (array) $field_choices as $key => $choice ) {
|
2010 |
+
|
2011 |
+
$src = str_replace( 'OT_URL', OT_URL, $choice['src'] );
|
2012 |
+
$src = str_replace( 'OT_THEME_URL', OT_THEME_URL, $src );
|
2013 |
+
|
2014 |
+
// Make radio image source filterable.
|
2015 |
+
$src = apply_filters( 'ot_type_radio_image_src', $src, $field_id );
|
2016 |
+
|
2017 |
+
/**
|
2018 |
+
* Filter the image attributes.
|
2019 |
+
*
|
2020 |
+
* @since 2.5.3
|
2021 |
+
*
|
2022 |
+
* @param string $attributes The image attributes.
|
2023 |
+
* @param string $field_id The field ID.
|
2024 |
+
* @param array $choice The choice.
|
2025 |
+
*/
|
2026 |
+
$attributes = apply_filters( 'ot_type_radio_image_attributes', '', $field_id, $choice );
|
2027 |
+
|
2028 |
+
echo '<div class="option-tree-ui-radio-images">';
|
2029 |
+
echo '<p style="display:none"><input type="radio" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '" value="' . esc_attr( $choice['value'] ) . '" ' . checked( $field_value, $choice['value'], false ) . ' class="option-tree-ui-radio option-tree-ui-images" /><label for="' . esc_attr( $field_id ) . '-' . esc_attr( $key ) . '">' . esc_attr( $choice['label'] ) . '</label></p>';
|
2030 |
+
echo '<img ' . sanitize_text_field( $attributes ) . ' src="' . esc_url( $src ) . '" alt="' . esc_attr( $choice['label'] ) . '" title="' . esc_attr( $choice['label'] ) . '" class="option-tree-ui-radio-image ' . esc_attr( $field_class ) . ( $field_value === $choice['value'] ? ' option-tree-ui-radio-image-selected' : '' ) . '" />'; // phpcs:ignore
|
2031 |
+
echo '</div>';
|
2032 |
+
}
|
2033 |
+
|
2034 |
+
echo '</div>';
|
2035 |
+
|
2036 |
+
echo '</div>';
|
2037 |
+
}
|
2038 |
}
|
2039 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2040 |
if ( ! function_exists( 'ot_type_select' ) ) {
|
2041 |
+
|
2042 |
+
/**
|
2043 |
+
* Select option type.
|
2044 |
+
*
|
2045 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2046 |
+
*
|
2047 |
+
* @param array $args An array of arguments.
|
2048 |
+
*
|
2049 |
+
* @access public
|
2050 |
+
* @since 2.0
|
2051 |
+
*/
|
2052 |
+
function ot_type_select( $args = array() ) {
|
2053 |
+
|
2054 |
+
// Turns arguments array into variables.
|
2055 |
+
extract( $args ); // phpcs:ignore
|
2056 |
+
|
2057 |
+
// Verify a description.
|
2058 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2059 |
+
|
2060 |
+
// Format setting outer wrapper.
|
2061 |
+
echo '<div class="format-setting type-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2062 |
+
|
2063 |
+
// Description.
|
2064 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2065 |
+
|
2066 |
+
// Filter choices array.
|
2067 |
+
$field_choices = apply_filters( 'ot_type_select_choices', $field_choices, $field_id );
|
2068 |
+
|
2069 |
+
// Format setting inner wrapper.
|
2070 |
+
echo '<div class="format-setting-inner">';
|
2071 |
+
|
2072 |
+
// Build select.
|
2073 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2074 |
+
foreach ( (array) $field_choices as $choice ) {
|
2075 |
+
if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) {
|
2076 |
+
echo '<option value="' . esc_attr( $choice['value'] ) . '"' . selected( $field_value, $choice['value'], false ) . '>' . esc_attr( $choice['label'] ) . '</option>';
|
2077 |
+
}
|
2078 |
+
}
|
2079 |
+
|
2080 |
+
echo '</select>';
|
2081 |
+
|
2082 |
+
echo '</div>';
|
2083 |
+
|
2084 |
+
echo '</div>';
|
2085 |
+
}
|
2086 |
}
|
2087 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2088 |
if ( ! function_exists( 'ot_type_sidebar_select' ) ) {
|
2089 |
+
|
2090 |
+
/**
|
2091 |
+
* Sidebar Select option type.
|
2092 |
+
*
|
2093 |
+
* This option type makes it possible for users to select a WordPress registered sidebar
|
2094 |
+
* to use on a specific area. By using the two provided filters, 'ot_recognized_sidebars',
|
2095 |
+
* and 'ot_recognized_sidebars_{$field_id}' we can be selective about which sidebars are
|
2096 |
+
* available on a specific content area.
|
2097 |
+
*
|
2098 |
+
* For example, if we create a WordPress theme that provides the ability to change the
|
2099 |
+
* Blog Sidebar and we don't want to have the footer sidebars available on this area,
|
2100 |
+
* we can unset those sidebars either manually or by using a regular expression if we
|
2101 |
+
* have a common name like footer-sidebar-$i.
|
2102 |
+
*
|
2103 |
+
* @param array $args An array of arguments.
|
2104 |
+
*
|
2105 |
+
* @access public
|
2106 |
+
* @since 2.1
|
2107 |
+
*/
|
2108 |
+
function ot_type_sidebar_select( $args = array() ) {
|
2109 |
+
|
2110 |
+
// Turns arguments array into variables.
|
2111 |
+
extract( $args ); // phpcs:ignore
|
2112 |
+
|
2113 |
+
// Verify a description.
|
2114 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2115 |
+
|
2116 |
+
// Format setting outer wrapper.
|
2117 |
+
echo '<div class="format-setting type-sidebar-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2118 |
+
|
2119 |
+
// Description.
|
2120 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2121 |
+
|
2122 |
+
// Format setting inner wrapper.
|
2123 |
+
echo '<div class="format-setting-inner">';
|
2124 |
+
|
2125 |
+
// Build page select.
|
2126 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2127 |
+
|
2128 |
+
// Get the registered sidebars.
|
2129 |
+
global $wp_registered_sidebars;
|
2130 |
+
|
2131 |
+
$sidebars = array();
|
2132 |
+
foreach ( $wp_registered_sidebars as $id => $sidebar ) {
|
2133 |
+
$sidebars[ $id ] = $sidebar['name'];
|
2134 |
+
}
|
2135 |
+
|
2136 |
+
// Filters to restrict which sidebars are allowed to be selected, for example we can restrict footer sidebars to be selectable on a blog page.
|
2137 |
+
$sidebars = apply_filters( 'ot_recognized_sidebars', $sidebars );
|
2138 |
+
$sidebars = apply_filters( 'ot_recognized_sidebars_' . $field_id, $sidebars );
|
2139 |
+
|
2140 |
+
// Has sidebars.
|
2141 |
+
if ( count( $sidebars ) ) {
|
2142 |
+
echo '<option value="">-- ' . esc_html__( 'Choose Sidebar', 'option-tree' ) . ' --</option>';
|
2143 |
+
foreach ( $sidebars as $id => $sidebar ) {
|
2144 |
+
echo '<option value="' . esc_attr( $id ) . '" ' . selected( $field_value, $id, false ) . '>' . esc_attr( $sidebar ) . '</option>';
|
2145 |
+
}
|
2146 |
+
} else {
|
2147 |
+
echo '<option value="">' . esc_html__( 'No Sidebars', 'option-tree' ) . '</option>';
|
2148 |
+
}
|
2149 |
+
|
2150 |
+
echo '</select>';
|
2151 |
+
|
2152 |
+
echo '</div>';
|
2153 |
+
|
2154 |
+
echo '</div>';
|
2155 |
+
}
|
2156 |
}
|
2157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2158 |
if ( ! function_exists( 'ot_type_slider' ) ) {
|
2159 |
+
|
2160 |
+
/**
|
2161 |
+
* List Item option type.
|
2162 |
+
*
|
2163 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2164 |
+
*
|
2165 |
+
* @param array $args An array of arguments.
|
2166 |
+
*
|
2167 |
+
* @access public
|
2168 |
+
* @since 2.0
|
2169 |
+
*/
|
2170 |
+
function ot_type_slider( $args = array() ) {
|
2171 |
+
|
2172 |
+
// Turns arguments array into variables.
|
2173 |
+
extract( $args ); // phpcs:ignore
|
2174 |
+
|
2175 |
+
// Verify a description.
|
2176 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2177 |
+
|
2178 |
+
// Format setting outer wrapper.
|
2179 |
+
echo '<div class="format-setting type-slider ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2180 |
+
|
2181 |
+
// Description.
|
2182 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2183 |
+
|
2184 |
+
// Format setting inner wrapper.
|
2185 |
+
echo '<div class="format-setting-inner">';
|
2186 |
+
|
2187 |
+
// Pass the settings array around.
|
2188 |
+
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . esc_attr( ot_encode( $field_settings ) ) . '" />';
|
2189 |
+
|
2190 |
+
/**
|
2191 |
+
* Settings pages have array wrappers like 'option_tree'.
|
2192 |
+
* So we need that value to create a proper array to save to.
|
2193 |
+
* This is only for NON metabox settings.
|
2194 |
+
*/
|
2195 |
+
if ( ! isset( $get_option ) ) {
|
2196 |
+
$get_option = '';
|
2197 |
+
}
|
2198 |
+
|
2199 |
+
// Build list items.
|
2200 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
2201 |
+
|
2202 |
+
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
2203 |
+
|
2204 |
+
foreach ( $field_value as $key => $list_item ) {
|
2205 |
+
|
2206 |
+
echo '<li class="ui-state-default list-list-item">';
|
2207 |
+
ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type );
|
2208 |
+
echo '</li>';
|
2209 |
+
}
|
2210 |
+
}
|
2211 |
+
|
2212 |
+
echo '</ul>';
|
2213 |
+
|
2214 |
+
// Button.
|
2215 |
+
echo '<a href="javascript:void(0);" class="option-tree-list-item-add option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add New', 'option-tree' ) . '">' . esc_html__( 'Add New', 'option-tree' ) . '</a>'; // phpcs:ignore
|
2216 |
+
|
2217 |
+
// Description.
|
2218 |
+
echo '<div class="list-item-description">' . esc_html__( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) . '</div>';
|
2219 |
+
|
2220 |
+
echo '</div>';
|
2221 |
+
|
2222 |
+
echo '</div>';
|
2223 |
+
}
|
2224 |
}
|
2225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2226 |
if ( ! function_exists( 'ot_type_social_links' ) ) {
|
2227 |
+
|
2228 |
+
/**
|
2229 |
+
* Social Links option type.
|
2230 |
+
*
|
2231 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2232 |
+
*
|
2233 |
+
* @param array $args An array of arguments.
|
2234 |
+
*
|
2235 |
+
* @access public
|
2236 |
+
* @since 2.4.0
|
2237 |
+
*/
|
2238 |
+
function ot_type_social_links( $args = array() ) {
|
2239 |
+
|
2240 |
+
// Turns arguments array into variables.
|
2241 |
+
extract( $args ); // phpcs:ignore
|
2242 |
+
|
2243 |
+
// Load the default social links.
|
2244 |
+
if ( empty( $field_value ) && apply_filters( 'ot_type_social_links_load_defaults', true, $field_id ) ) {
|
2245 |
+
|
2246 |
+
$field_value = apply_filters(
|
2247 |
+
'ot_type_social_links_defaults',
|
2248 |
+
array(
|
2249 |
+
array(
|
2250 |
+
'name' => __( 'Facebook', 'option-tree' ),
|
2251 |
+
'title' => '',
|
2252 |
+
'href' => '',
|
2253 |
+
),
|
2254 |
+
array(
|
2255 |
+
'name' => __( 'Twitter', 'option-tree' ),
|
2256 |
+
'title' => '',
|
2257 |
+
'href' => '',
|
2258 |
+
),
|
2259 |
+
array(
|
2260 |
+
'name' => __( 'Google+', 'option-tree' ),
|
2261 |
+
'title' => '',
|
2262 |
+
'href' => '',
|
2263 |
+
),
|
2264 |
+
array(
|
2265 |
+
'name' => __( 'LinkedIn', 'option-tree' ),
|
2266 |
+
'title' => '',
|
2267 |
+
'href' => '',
|
2268 |
+
),
|
2269 |
+
array(
|
2270 |
+
'name' => __( 'Pinterest', 'option-tree' ),
|
2271 |
+
'title' => '',
|
2272 |
+
'href' => '',
|
2273 |
+
),
|
2274 |
+
array(
|
2275 |
+
'name' => __( 'Youtube', 'option-tree' ),
|
2276 |
+
'title' => '',
|
2277 |
+
'href' => '',
|
2278 |
+
),
|
2279 |
+
array(
|
2280 |
+
'name' => __( 'Dribbble', 'option-tree' ),
|
2281 |
+
'title' => '',
|
2282 |
+
'href' => '',
|
2283 |
+
),
|
2284 |
+
array(
|
2285 |
+
'name' => __( 'Github', 'option-tree' ),
|
2286 |
+
'title' => '',
|
2287 |
+
'href' => '',
|
2288 |
+
),
|
2289 |
+
array(
|
2290 |
+
'name' => __( 'Forrst', 'option-tree' ),
|
2291 |
+
'title' => '',
|
2292 |
+
'href' => '',
|
2293 |
+
),
|
2294 |
+
array(
|
2295 |
+
'name' => __( 'Digg', 'option-tree' ),
|
2296 |
+
'title' => '',
|
2297 |
+
'href' => '',
|
2298 |
+
),
|
2299 |
+
array(
|
2300 |
+
'name' => __( 'Delicious', 'option-tree' ),
|
2301 |
+
'title' => '',
|
2302 |
+
'href' => '',
|
2303 |
+
),
|
2304 |
+
array(
|
2305 |
+
'name' => __( 'Tumblr', 'option-tree' ),
|
2306 |
+
'title' => '',
|
2307 |
+
'href' => '',
|
2308 |
+
),
|
2309 |
+
array(
|
2310 |
+
'name' => __( 'Skype', 'option-tree' ),
|
2311 |
+
'title' => '',
|
2312 |
+
'href' => '',
|
2313 |
+
),
|
2314 |
+
array(
|
2315 |
+
'name' => __( 'SoundCloud', 'option-tree' ),
|
2316 |
+
'title' => '',
|
2317 |
+
'href' => '',
|
2318 |
+
),
|
2319 |
+
array(
|
2320 |
+
'name' => __( 'Vimeo', 'option-tree' ),
|
2321 |
+
'title' => '',
|
2322 |
+
'href' => '',
|
2323 |
+
),
|
2324 |
+
array(
|
2325 |
+
'name' => __( 'Flickr', 'option-tree' ),
|
2326 |
+
'title' => '',
|
2327 |
+
'href' => '',
|
2328 |
+
),
|
2329 |
+
array(
|
2330 |
+
'name' => __( 'VK.com', 'option-tree' ),
|
2331 |
+
'title' => '',
|
2332 |
+
'href' => '',
|
2333 |
+
),
|
2334 |
+
),
|
2335 |
+
$field_id
|
2336 |
+
);
|
2337 |
+
|
2338 |
+
}
|
2339 |
+
|
2340 |
+
// Verify a description.
|
2341 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2342 |
+
|
2343 |
+
// Format setting outer wrapper.
|
2344 |
+
echo '<div class="format-setting type-social-list-item ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2345 |
+
|
2346 |
+
// Description.
|
2347 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2348 |
+
|
2349 |
+
// Format setting inner wrapper.
|
2350 |
+
echo '<div class="format-setting-inner">';
|
2351 |
+
|
2352 |
+
// Pass the settings array around.
|
2353 |
+
echo '<input type="hidden" name="' . esc_attr( $field_id ) . '_settings_array" id="' . esc_attr( $field_id ) . '_settings_array" value="' . esc_attr( ot_encode( $field_settings ) ) . '" />';
|
2354 |
+
|
2355 |
+
/**
|
2356 |
+
* Settings pages have array wrappers like 'option_tree'.
|
2357 |
+
* So we need that value to create a proper array to save to.
|
2358 |
+
* This is only for NON metabox settings.
|
2359 |
+
*/
|
2360 |
+
if ( ! isset( $get_option ) ) {
|
2361 |
+
$get_option = '';
|
2362 |
+
}
|
2363 |
+
|
2364 |
+
// Build list items.
|
2365 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" data-name="' . esc_attr( $field_id ) . '" data-id="' . esc_attr( $post_id ) . '" data-get-option="' . esc_attr( $get_option ) . '" data-type="' . esc_attr( $type ) . '">';
|
2366 |
+
|
2367 |
+
if ( is_array( $field_value ) && ! empty( $field_value ) ) {
|
2368 |
+
|
2369 |
+
foreach ( $field_value as $key => $link ) {
|
2370 |
+
|
2371 |
+
echo '<li class="ui-state-default list-list-item">';
|
2372 |
+
ot_social_links_view( $field_id, $key, $link, $post_id, $get_option, $field_settings );
|
2373 |
+
echo '</li>';
|
2374 |
+
}
|
2375 |
+
}
|
2376 |
+
|
2377 |
+
echo '</ul>';
|
2378 |
+
|
2379 |
+
// Button.
|
2380 |
+
echo '<a href="javascript:void(0);" class="option-tree-social-links-add option-tree-ui-button button button-primary right hug-right" title="' . esc_html__( 'Add New', 'option-tree' ) . '">' . esc_html__( 'Add New', 'option-tree' ) . '</a>'; // phpcs:ignore
|
2381 |
+
|
2382 |
+
// Description.
|
2383 |
+
echo '<div class="list-item-description">' . esc_html( apply_filters( 'ot_social_links_description', __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ), $field_id ) ) . '</div>';
|
2384 |
+
|
2385 |
+
echo '</div>';
|
2386 |
+
|
2387 |
+
echo '</div>';
|
2388 |
+
}
|
2389 |
}
|
2390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2391 |
if ( ! function_exists( 'ot_type_spacing' ) ) {
|
2392 |
|
2393 |
+
/**
|
2394 |
+
* Spacing Option Type.
|
2395 |
+
*
|
2396 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2397 |
+
*
|
2398 |
+
* @param array $args An array of arguments.
|
2399 |
+
*
|
2400 |
+
* @access public
|
2401 |
+
* @since 2.5.0
|
2402 |
+
*/
|
2403 |
+
function ot_type_spacing( $args = array() ) {
|
2404 |
|
2405 |
+
// Turns arguments array into variables.
|
2406 |
+
extract( $args ); // phpcs:ignore
|
2407 |
|
2408 |
+
// Verify a description.
|
2409 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2410 |
|
2411 |
+
// Format setting outer wrapper.
|
2412 |
+
echo '<div class="format-setting type-spacing ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2413 |
|
2414 |
+
// Description.
|
2415 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2416 |
|
2417 |
+
// Format setting inner wrapper.
|
2418 |
+
echo '<div class="format-setting-inner">';
|
2419 |
|
2420 |
+
// Allow fields to be filtered.
|
2421 |
+
$ot_recognized_spacing_fields = apply_filters(
|
2422 |
+
'ot_recognized_spacing_fields',
|
2423 |
+
array(
|
2424 |
+
'top',
|
2425 |
+
'right',
|
2426 |
+
'bottom',
|
2427 |
+
'left',
|
2428 |
+
'unit',
|
2429 |
+
),
|
2430 |
+
$field_id
|
2431 |
+
);
|
2432 |
|
2433 |
+
// Build top spacing.
|
2434 |
+
if ( in_array( 'top', $ot_recognized_spacing_fields, true ) ) {
|
2435 |
|
2436 |
+
$top = isset( $field_value['top'] ) ? $field_value['top'] : '';
|
2437 |
|
2438 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-up ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[top]" id="' . esc_attr( $field_id ) . '-top" value="' . esc_attr( $top ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'top', 'option-tree' ) . '" /></div>';
|
2439 |
+
}
|
2440 |
|
2441 |
+
// Build right spacing.
|
2442 |
+
if ( in_array( 'right', $ot_recognized_spacing_fields, true ) ) {
|
2443 |
|
2444 |
+
$right = isset( $field_value['right'] ) ? $field_value['right'] : '';
|
|
|
2445 |
|
2446 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-right ot-option-group--icon"></span></span><input type="text" name="' . esc_attr( $field_name ) . '[right]" id="' . esc_attr( $field_id ) . '-right" value="' . esc_attr( $right ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'right', 'option-tree' ) . '" /></div>';
|
2447 |
+
}
|
2448 |
|
2449 |
+
// Build bottom spacing.
|
2450 |
+
if ( in_array( 'bottom', $ot_recognized_spacing_fields, true ) ) {
|
2451 |
|
2452 |
+
$bottom = isset( $field_value['bottom'] ) ? $field_value['bottom'] : '';
|
2453 |
|
2454 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-down ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[bottom]" id="' . esc_attr( $field_id ) . '-bottom" value="' . esc_attr( $bottom ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'bottom', 'option-tree' ) . '" /></div>';
|
2455 |
+
}
|
2456 |
|
2457 |
+
// Build left spacing.
|
2458 |
+
if ( in_array( 'left', $ot_recognized_spacing_fields, true ) ) {
|
2459 |
|
2460 |
+
$left = isset( $field_value['left'] ) ? $field_value['left'] : '';
|
2461 |
|
2462 |
+
echo '<div class="ot-option-group"><span class="ot-icon-arrow-left ot-option-group--icon"></span><input type="text" name="' . esc_attr( $field_name ) . '[left]" id="' . esc_attr( $field_id ) . '-left" value="' . esc_attr( $left ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" placeholder="' . esc_html__( 'left', 'option-tree' ) . '" /></div>';
|
2463 |
+
}
|
2464 |
|
2465 |
+
// Build unit dropdown.
|
2466 |
+
if ( in_array( 'unit', $ot_recognized_spacing_fields, true ) ) {
|
2467 |
|
2468 |
+
echo '<div class="ot-option-group ot-option-group--is-last">';
|
2469 |
|
2470 |
+
echo '<select name="' . esc_attr( $field_name ) . '[unit]" id="' . esc_attr( $field_id ) . '-unit" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2471 |
|
2472 |
+
echo '<option value="">' . esc_html__( 'unit', 'option-tree' ) . '</option>';
|
2473 |
|
2474 |
+
foreach ( ot_recognized_spacing_unit_types( $field_id ) as $unit ) {
|
2475 |
+
echo '<option value="' . esc_attr( $unit ) . '"' . ( isset( $field_value['unit'] ) ? selected( $field_value['unit'], $unit, false ) : '' ) . '>' . esc_attr( $unit ) . '</option>';
|
2476 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2477 |
|
2478 |
+
echo '</select>';
|
|
|
|
|
2479 |
|
2480 |
+
echo '</div>';
|
2481 |
+
}
|
2482 |
|
2483 |
+
echo '</div>';
|
2484 |
|
2485 |
+
echo '</div>';
|
2486 |
+
}
|
2487 |
}
|
2488 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2489 |
if ( ! function_exists( 'ot_type_tab' ) ) {
|
2490 |
+
|
2491 |
+
/**
|
2492 |
+
* Tab option type.
|
2493 |
+
*
|
2494 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2495 |
+
*
|
2496 |
+
* @access public
|
2497 |
+
* @since 2.3.0
|
2498 |
+
*/
|
2499 |
+
function ot_type_tab() {
|
2500 |
+
echo '<div class="format-setting type-tab"><br /></div>';
|
2501 |
+
}
|
|
|
|
|
|
|
2502 |
}
|
2503 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2504 |
if ( ! function_exists( 'ot_type_tag_checkbox' ) ) {
|
2505 |
+
|
2506 |
+
/**
|
2507 |
+
* Tag Checkbox option type.
|
2508 |
+
*
|
2509 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2510 |
+
*
|
2511 |
+
* @param array $args An array of arguments.
|
2512 |
+
*
|
2513 |
+
* @access public
|
2514 |
+
* @since 2.0
|
2515 |
+
*/
|
2516 |
+
function ot_type_tag_checkbox( $args = array() ) {
|
2517 |
+
|
2518 |
+
// Turns arguments array into variables.
|
2519 |
+
extract( $args ); // phpcs:ignore
|
2520 |
+
|
2521 |
+
// Verify a description.
|
2522 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2523 |
+
|
2524 |
+
// Format setting outer wrapper.
|
2525 |
+
echo '<div class="format-setting type-tag-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2526 |
+
|
2527 |
+
// Description.
|
2528 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2529 |
+
|
2530 |
+
// Format setting inner wrapper.
|
2531 |
+
echo '<div class="format-setting-inner">';
|
2532 |
+
|
2533 |
+
// Get tags.
|
2534 |
+
$tags = get_tags( array( 'hide_empty' => false ) );
|
2535 |
+
|
2536 |
+
// Has tags.
|
2537 |
+
if ( $tags ) {
|
2538 |
+
foreach ( $tags as $tag ) {
|
2539 |
+
echo '<p>';
|
2540 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $tag->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $tag->term_id ) . '" value="' . esc_attr( $tag->term_id ) . '" ' . ( isset( $field_value[ $tag->term_id ] ) ? checked( $field_value[ $tag->term_id ], $tag->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
2541 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $tag->term_id ) . '">' . esc_attr( $tag->name ) . '</label>';
|
2542 |
+
echo '</p>';
|
2543 |
+
}
|
2544 |
+
} else {
|
2545 |
+
echo '<p>' . esc_html__( 'No Tags Found', 'option-tree' ) . '</p>';
|
2546 |
+
}
|
2547 |
+
|
2548 |
+
echo '</div>';
|
2549 |
+
|
2550 |
+
echo '</div>';
|
2551 |
+
}
|
2552 |
}
|
2553 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2554 |
if ( ! function_exists( 'ot_type_tag_select' ) ) {
|
2555 |
+
|
2556 |
+
/**
|
2557 |
+
* Tag Select option type.
|
2558 |
+
*
|
2559 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2560 |
+
*
|
2561 |
+
* @param array $args An array of arguments.
|
2562 |
+
*
|
2563 |
+
* @access public
|
2564 |
+
* @since 2.0
|
2565 |
+
*/
|
2566 |
+
function ot_type_tag_select( $args = array() ) {
|
2567 |
+
|
2568 |
+
// Turns arguments array into variables.
|
2569 |
+
extract( $args ); // phpcs:ignore
|
2570 |
+
|
2571 |
+
// Verify a description.
|
2572 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2573 |
+
|
2574 |
+
// Format setting outer wrapper.
|
2575 |
+
echo '<div class="format-setting type-tag-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2576 |
+
|
2577 |
+
// Description.
|
2578 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2579 |
+
|
2580 |
+
// Format setting inner wrapper.
|
2581 |
+
echo '<div class="format-setting-inner">';
|
2582 |
+
|
2583 |
+
// Build tag select.
|
2584 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2585 |
+
|
2586 |
+
// Get tags.
|
2587 |
+
$tags = get_tags( array( 'hide_empty' => false ) );
|
2588 |
+
|
2589 |
+
// Has tags.
|
2590 |
+
if ( $tags ) {
|
2591 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
2592 |
+
foreach ( $tags as $tag ) {
|
2593 |
+
echo '<option value="' . esc_attr( $tag->term_id ) . '"' . selected( $field_value, $tag->term_id, false ) . '>' . esc_attr( $tag->name ) . '</option>';
|
2594 |
+
}
|
2595 |
+
} else {
|
2596 |
+
echo '<option value="">' . esc_html__( 'No Tags Found', 'option-tree' ) . '</option>';
|
2597 |
+
}
|
2598 |
+
|
2599 |
+
echo '</select>';
|
2600 |
+
|
2601 |
+
echo '</div>';
|
2602 |
+
|
2603 |
+
echo '</div>';
|
2604 |
+
}
|
2605 |
}
|
2606 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2607 |
if ( ! function_exists( 'ot_type_taxonomy_checkbox' ) ) {
|
2608 |
+
|
2609 |
+
/**
|
2610 |
+
* Taxonomy Checkbox option type.
|
2611 |
+
*
|
2612 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2613 |
+
*
|
2614 |
+
* @param array $args An array of arguments.
|
2615 |
+
*
|
2616 |
+
* @access public
|
2617 |
+
* @since 2.0
|
2618 |
+
*/
|
2619 |
+
function ot_type_taxonomy_checkbox( $args = array() ) {
|
2620 |
+
|
2621 |
+
// Turns arguments array into variables.
|
2622 |
+
extract( $args ); // phpcs:ignore
|
2623 |
+
|
2624 |
+
// Verify a description.
|
2625 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2626 |
+
|
2627 |
+
// Format setting outer wrapper.
|
2628 |
+
echo '<div class="format-setting type-taxonomy-checkbox type-checkbox ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2629 |
+
|
2630 |
+
// Description.
|
2631 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2632 |
+
|
2633 |
+
// Format setting inner wrapper.
|
2634 |
+
echo '<div class="format-setting-inner">';
|
2635 |
+
|
2636 |
+
// Setup the taxonomy.
|
2637 |
+
$taxonomy = isset( $field_taxonomy ) ? explode( ',', $field_taxonomy ) : array( 'category' );
|
2638 |
+
|
2639 |
+
// Get taxonomies.
|
2640 |
+
$taxonomies = get_categories(
|
2641 |
+
apply_filters(
|
2642 |
+
'ot_type_taxonomy_checkbox_query',
|
2643 |
+
array(
|
2644 |
+
'hide_empty' => false,
|
2645 |
+
'taxonomy' => $taxonomy,
|
2646 |
+
),
|
2647 |
+
$field_id
|
2648 |
+
)
|
2649 |
+
);
|
2650 |
+
|
2651 |
+
// Has tags.
|
2652 |
+
if ( $taxonomies ) {
|
2653 |
+
foreach ( $taxonomies as $taxonomy ) {
|
2654 |
+
echo '<p>';
|
2655 |
+
echo '<input type="checkbox" name="' . esc_attr( $field_name ) . '[' . esc_attr( $taxonomy->term_id ) . ']" id="' . esc_attr( $field_id ) . '-' . esc_attr( $taxonomy->term_id ) . '" value="' . esc_attr( $taxonomy->term_id ) . '" ' . ( isset( $field_value[ $taxonomy->term_id ] ) ? checked( $field_value[ $taxonomy->term_id ], $taxonomy->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />';
|
2656 |
+
echo '<label for="' . esc_attr( $field_id ) . '-' . esc_attr( $taxonomy->term_id ) . '">' . esc_attr( $taxonomy->name ) . '</label>';
|
2657 |
+
echo '</p>';
|
2658 |
+
}
|
2659 |
+
} else {
|
2660 |
+
echo '<p>' . esc_html__( 'No Taxonomies Found', 'option-tree' ) . '</p>';
|
2661 |
+
}
|
2662 |
+
|
2663 |
+
echo '</div>';
|
2664 |
+
|
2665 |
+
echo '</div>';
|
2666 |
+
}
|
2667 |
}
|
2668 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2669 |
if ( ! function_exists( 'ot_type_taxonomy_select' ) ) {
|
2670 |
+
|
2671 |
+
/**
|
2672 |
+
* Taxonomy Select option type.
|
2673 |
+
*
|
2674 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2675 |
+
*
|
2676 |
+
* @param array $args An array of arguments.
|
2677 |
+
*
|
2678 |
+
* @access public
|
2679 |
+
* @since 2.0
|
2680 |
+
*/
|
2681 |
+
function ot_type_taxonomy_select( $args = array() ) {
|
2682 |
+
|
2683 |
+
// Turns arguments array into variables.
|
2684 |
+
extract( $args ); // phpcs:ignore
|
2685 |
+
|
2686 |
+
// Verify a description.
|
2687 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2688 |
+
|
2689 |
+
// Format setting outer wrapper.
|
2690 |
+
echo '<div class="format-setting type-tag-select ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2691 |
+
|
2692 |
+
// Description.
|
2693 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2694 |
+
|
2695 |
+
// Format setting inner wrapper.
|
2696 |
+
echo '<div class="format-setting-inner">';
|
2697 |
+
|
2698 |
+
// Build tag select.
|
2699 |
+
echo '<select name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2700 |
+
|
2701 |
+
// Setup the taxonomy.
|
2702 |
+
$taxonomy = isset( $field_taxonomy ) ? explode( ',', $field_taxonomy ) : array( 'category' );
|
2703 |
+
|
2704 |
+
// Get taxonomies.
|
2705 |
+
$taxonomies = get_categories(
|
2706 |
+
apply_filters(
|
2707 |
+
'ot_type_taxonomy_select_query',
|
2708 |
+
array(
|
2709 |
+
'hide_empty' => false,
|
2710 |
+
'taxonomy' => $taxonomy,
|
2711 |
+
),
|
2712 |
+
$field_id
|
2713 |
+
)
|
2714 |
+
);
|
2715 |
+
|
2716 |
+
// Has tags.
|
2717 |
+
if ( $taxonomies ) {
|
2718 |
+
echo '<option value="">-- ' . esc_html__( 'Choose One', 'option-tree' ) . ' --</option>';
|
2719 |
+
foreach ( $taxonomies as $taxonomy ) {
|
2720 |
+
echo '<option value="' . esc_attr( $taxonomy->term_id ) . '"' . selected( $field_value, $taxonomy->term_id, false ) . '>' . esc_attr( $taxonomy->name ) . '</option>';
|
2721 |
+
}
|
2722 |
+
} else {
|
2723 |
+
echo '<option value="">' . esc_html__( 'No Taxonomies Found', 'option-tree' ) . '</option>';
|
2724 |
+
}
|
2725 |
+
|
2726 |
+
echo '</select>';
|
2727 |
+
|
2728 |
+
echo '</div>';
|
2729 |
+
|
2730 |
+
echo '</div>';
|
2731 |
+
}
|
2732 |
}
|
2733 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2734 |
if ( ! function_exists( 'ot_type_text' ) ) {
|
2735 |
+
|
2736 |
+
/**
|
2737 |
+
* Text option type.
|
2738 |
+
*
|
2739 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2740 |
+
*
|
2741 |
+
* @param array $args An array of arguments.
|
2742 |
+
*
|
2743 |
+
* @access public
|
2744 |
+
* @since 2.0
|
2745 |
+
*/
|
2746 |
+
function ot_type_text( $args = array() ) {
|
2747 |
+
|
2748 |
+
// Turns arguments array into variables.
|
2749 |
+
extract( $args ); // phpcs:ignore
|
2750 |
+
|
2751 |
+
// Verify a description.
|
2752 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2753 |
+
|
2754 |
+
// Format setting outer wrapper.
|
2755 |
+
echo '<div class="format-setting type-text ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2756 |
+
|
2757 |
+
// Description.
|
2758 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2759 |
+
|
2760 |
+
// Format setting inner wrapper.
|
2761 |
+
echo '<div class="format-setting-inner">';
|
2762 |
+
|
2763 |
+
// Build text input.
|
2764 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-input ' . esc_attr( $field_class ) . '" />';
|
2765 |
+
|
2766 |
+
echo '</div>';
|
2767 |
+
|
2768 |
+
echo '</div>';
|
2769 |
+
}
|
2770 |
}
|
2771 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2772 |
if ( ! function_exists( 'ot_type_textarea' ) ) {
|
2773 |
+
|
2774 |
+
/**
|
2775 |
+
* Textarea option type.
|
2776 |
+
*
|
2777 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2778 |
+
*
|
2779 |
+
* @param array $args An array of arguments.
|
2780 |
+
*
|
2781 |
+
* @access public
|
2782 |
+
* @since 2.0
|
2783 |
+
*/
|
2784 |
+
function ot_type_textarea( $args = array() ) {
|
2785 |
+
|
2786 |
+
// Turns arguments array into variables.
|
2787 |
+
extract( $args ); // phpcs:ignore
|
2788 |
+
|
2789 |
+
// Verify a description.
|
2790 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2791 |
+
|
2792 |
+
// Format setting outer wrapper.
|
2793 |
+
echo '<div class="format-setting type-textarea ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . ' fill-area">';
|
2794 |
+
|
2795 |
+
// Description.
|
2796 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2797 |
+
|
2798 |
+
// Format setting inner wrapper.
|
2799 |
+
echo '<div class="format-setting-inner">';
|
2800 |
+
|
2801 |
+
// Build textarea.
|
2802 |
+
wp_editor(
|
2803 |
+
$field_value,
|
2804 |
+
esc_attr( $field_id ),
|
2805 |
+
array(
|
2806 |
+
'editor_class' => esc_attr( $field_class ),
|
2807 |
+
'wpautop' => apply_filters( 'ot_wpautop', false, $field_id ),
|
2808 |
+
'media_buttons' => apply_filters( 'ot_media_buttons', true, $field_id ),
|
2809 |
+
'textarea_name' => esc_attr( $field_name ),
|
2810 |
+
'textarea_rows' => esc_attr( $field_rows ),
|
2811 |
+
'tinymce' => apply_filters( 'ot_tinymce', true, $field_id ),
|
2812 |
+
'quicktags' => apply_filters( 'ot_quicktags', array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ), $field_id ),
|
2813 |
+
)
|
2814 |
+
);
|
2815 |
+
|
2816 |
+
echo '</div>';
|
2817 |
+
|
2818 |
+
echo '</div>';
|
2819 |
+
}
|
2820 |
}
|
2821 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2822 |
if ( ! function_exists( 'ot_type_textarea_simple' ) ) {
|
2823 |
+
|
2824 |
+
/**
|
2825 |
+
* Textarea Simple option type.
|
2826 |
+
*
|
2827 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2828 |
+
*
|
2829 |
+
* @param array $args An array of arguments.
|
2830 |
+
*
|
2831 |
+
* @access public
|
2832 |
+
* @since 2.0
|
2833 |
+
*/
|
2834 |
+
function ot_type_textarea_simple( $args = array() ) {
|
2835 |
+
|
2836 |
+
// Turns arguments array into variables.
|
2837 |
+
extract( $args ); // phpcs:ignore
|
2838 |
+
|
2839 |
+
// Verify a description.
|
2840 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2841 |
+
|
2842 |
+
// Format setting outer wrapper.
|
2843 |
+
echo '<div class="format-setting type-textarea simple ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2844 |
+
|
2845 |
+
// Description.
|
2846 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2847 |
+
|
2848 |
+
// Format setting inner wrapper.
|
2849 |
+
echo '<div class="format-setting-inner">';
|
2850 |
+
|
2851 |
+
// Filter to allow wpautop.
|
2852 |
+
$wpautop = apply_filters( 'ot_wpautop', false, $field_id );
|
2853 |
+
|
2854 |
+
// Wpautop $field_value.
|
2855 |
+
if ( true === $wpautop ) {
|
2856 |
+
$field_value = wpautop( $field_value );
|
2857 |
+
}
|
2858 |
+
|
2859 |
+
// Build textarea simple.
|
2860 |
+
echo '<textarea class="textarea ' . esc_attr( $field_class ) . '" rows="' . esc_attr( $field_rows ) . '" cols="40" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '">' . esc_textarea( $field_value ) . '</textarea>';
|
2861 |
+
|
2862 |
+
echo '</div>';
|
2863 |
+
|
2864 |
+
echo '</div>';
|
2865 |
+
}
|
2866 |
}
|
2867 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2868 |
if ( ! function_exists( 'ot_type_textblock' ) ) {
|
2869 |
+
|
2870 |
+
/**
|
2871 |
+
* Textblock option type.
|
2872 |
+
*
|
2873 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2874 |
+
*
|
2875 |
+
* @param array $args An array of arguments.
|
2876 |
+
*
|
2877 |
+
* @access public
|
2878 |
+
* @since 2.0
|
2879 |
+
*/
|
2880 |
+
function ot_type_textblock( $args = array() ) {
|
2881 |
+
|
2882 |
+
// Turns arguments array into variables.
|
2883 |
+
extract( $args ); // phpcs:ignore
|
2884 |
+
|
2885 |
+
// Format setting outer wrapper.
|
2886 |
+
echo '<div class="format-setting type-textblock wide-desc">';
|
2887 |
+
|
2888 |
+
// Description.
|
2889 |
+
echo '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>';
|
2890 |
+
|
2891 |
+
echo '</div>';
|
2892 |
+
}
|
2893 |
}
|
2894 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2895 |
if ( ! function_exists( 'ot_type_textblock_titled' ) ) {
|
2896 |
+
|
2897 |
+
/**
|
2898 |
+
* Textblock Titled option type.
|
2899 |
+
*
|
2900 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2901 |
+
*
|
2902 |
+
* @param array $args An array of arguments.
|
2903 |
+
*
|
2904 |
+
* @access public
|
2905 |
+
* @since 2.0
|
2906 |
+
*/
|
2907 |
+
function ot_type_textblock_titled( $args = array() ) {
|
2908 |
+
|
2909 |
+
// Turns arguments array into variables.
|
2910 |
+
extract( $args ); // phpcs:ignore
|
2911 |
+
|
2912 |
+
// Format setting outer wrapper.
|
2913 |
+
echo '<div class="format-setting type-textblock titled wide-desc">';
|
2914 |
+
|
2915 |
+
// Description.
|
2916 |
+
echo '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>';
|
2917 |
+
|
2918 |
+
echo '</div>';
|
2919 |
+
}
|
2920 |
}
|
2921 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2922 |
if ( ! function_exists( 'ot_type_typography' ) ) {
|
2923 |
+
|
2924 |
+
/**
|
2925 |
+
* Typography option type.
|
2926 |
+
*
|
2927 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
2928 |
+
*
|
2929 |
+
* @param array $args An array of arguments.
|
2930 |
+
*
|
2931 |
+
* @access public
|
2932 |
+
* @since 2.0
|
2933 |
+
*/
|
2934 |
+
function ot_type_typography( $args = array() ) {
|
2935 |
+
|
2936 |
+
// Turns arguments array into variables.
|
2937 |
+
extract( $args ); // phpcs:ignore
|
2938 |
+
|
2939 |
+
// Verify a description.
|
2940 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
2941 |
+
|
2942 |
+
// Format setting outer wrapper.
|
2943 |
+
echo '<div class="format-setting type-typography ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
2944 |
+
|
2945 |
+
// Description.
|
2946 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : '';
|
2947 |
+
|
2948 |
+
// Format setting inner wrapper.
|
2949 |
+
echo '<div class="format-setting-inner">';
|
2950 |
+
|
2951 |
+
// Allow fields to be filtered.
|
2952 |
+
$ot_recognized_typography_fields = apply_filters(
|
2953 |
+
'ot_recognized_typography_fields',
|
2954 |
+
array(
|
2955 |
+
'font-color',
|
2956 |
+
'font-family',
|
2957 |
+
'font-size',
|
2958 |
+
'font-style',
|
2959 |
+
'font-variant',
|
2960 |
+
'font-weight',
|
2961 |
+
'letter-spacing',
|
2962 |
+
'line-height',
|
2963 |
+
'text-decoration',
|
2964 |
+
'text-transform',
|
2965 |
+
),
|
2966 |
+
$field_id
|
2967 |
+
);
|
2968 |
+
|
2969 |
+
// Build font color.
|
2970 |
+
if ( in_array( 'font-color', $ot_recognized_typography_fields, true ) ) {
|
2971 |
+
|
2972 |
+
// Build colorpicker.
|
2973 |
+
echo '<div class="option-tree-ui-colorpicker-input-wrap">';
|
2974 |
+
|
2975 |
+
// Colorpicker JS.
|
2976 |
+
echo '<script>jQuery(document).ready(function($) { OT_UI.bind_colorpicker("' . esc_attr( $field_id ) . '-picker"); });</script>';
|
2977 |
+
|
2978 |
+
// Set background color.
|
2979 |
+
$background_color = isset( $field_value['font-color'] ) ? esc_attr( $field_value['font-color'] ) : '';
|
2980 |
+
|
2981 |
+
/* input */
|
2982 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '[font-color]" id="' . esc_attr( $field_id ) . '-picker" value="' . esc_attr( $background_color ) . '" class="hide-color-picker ' . esc_attr( $field_class ) . '" />';
|
2983 |
+
|
2984 |
+
echo '</div>';
|
2985 |
+
}
|
2986 |
+
|
2987 |
+
// Build font family.
|
2988 |
+
if ( in_array( 'font-family', $ot_recognized_typography_fields, true ) ) {
|
2989 |
+
$font_family = isset( $field_value['font-family'] ) ? $field_value['font-family'] : '';
|
2990 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-family]" id="' . esc_attr( $field_id ) . '-font-family" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
2991 |
+
echo '<option value="">font-family</option>';
|
2992 |
+
foreach ( ot_recognized_font_families( $field_id ) as $key => $value ) {
|
2993 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_family, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
2994 |
+
}
|
2995 |
+
echo '</select>';
|
2996 |
+
}
|
2997 |
+
|
2998 |
+
// Build font size.
|
2999 |
+
if ( in_array( 'font-size', $ot_recognized_typography_fields, true ) ) {
|
3000 |
+
$font_size = isset( $field_value['font-size'] ) ? esc_attr( $field_value['font-size'] ) : '';
|
3001 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-size]" id="' . esc_attr( $field_id ) . '-font-size" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3002 |
+
echo '<option value="">font-size</option>';
|
3003 |
+
foreach ( ot_recognized_font_sizes( $field_id ) as $option ) {
|
3004 |
+
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $font_size, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3005 |
+
}
|
3006 |
+
echo '</select>';
|
3007 |
+
}
|
3008 |
+
|
3009 |
+
// Build font style.
|
3010 |
+
if ( in_array( 'font-style', $ot_recognized_typography_fields, true ) ) {
|
3011 |
+
$font_style = isset( $field_value['font-style'] ) ? esc_attr( $field_value['font-style'] ) : '';
|
3012 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-style]" id="' . esc_attr( $field_id ) . '-font-style" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3013 |
+
echo '<option value="">font-style</option>';
|
3014 |
+
foreach ( ot_recognized_font_styles( $field_id ) as $key => $value ) {
|
3015 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_style, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3016 |
+
}
|
3017 |
+
echo '</select>';
|
3018 |
+
}
|
3019 |
+
|
3020 |
+
// Build font variant.
|
3021 |
+
if ( in_array( 'font-variant', $ot_recognized_typography_fields, true ) ) {
|
3022 |
+
$font_variant = isset( $field_value['font-variant'] ) ? esc_attr( $field_value['font-variant'] ) : '';
|
3023 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-variant]" id="' . esc_attr( $field_id ) . '-font-variant" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3024 |
+
echo '<option value="">font-variant</option>';
|
3025 |
+
foreach ( ot_recognized_font_variants( $field_id ) as $key => $value ) {
|
3026 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_variant, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3027 |
+
}
|
3028 |
+
echo '</select>';
|
3029 |
+
}
|
3030 |
+
|
3031 |
+
// Build font weight.
|
3032 |
+
if ( in_array( 'font-weight', $ot_recognized_typography_fields, true ) ) {
|
3033 |
+
$font_weight = isset( $field_value['font-weight'] ) ? esc_attr( $field_value['font-weight'] ) : '';
|
3034 |
+
echo '<select name="' . esc_attr( $field_name ) . '[font-weight]" id="' . esc_attr( $field_id ) . '-font-weight" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3035 |
+
echo '<option value="">font-weight</option>';
|
3036 |
+
foreach ( ot_recognized_font_weights( $field_id ) as $key => $value ) {
|
3037 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $font_weight, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3038 |
+
}
|
3039 |
+
echo '</select>';
|
3040 |
+
}
|
3041 |
+
|
3042 |
+
// Build letter spacing.
|
3043 |
+
if ( in_array( 'letter-spacing', $ot_recognized_typography_fields, true ) ) {
|
3044 |
+
$letter_spacing = isset( $field_value['letter-spacing'] ) ? esc_attr( $field_value['letter-spacing'] ) : '';
|
3045 |
+
echo '<select name="' . esc_attr( $field_name ) . '[letter-spacing]" id="' . esc_attr( $field_id ) . '-letter-spacing" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3046 |
+
echo '<option value="">letter-spacing</option>';
|
3047 |
+
foreach ( ot_recognized_letter_spacing( $field_id ) as $option ) {
|
3048 |
+
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $letter_spacing, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3049 |
+
}
|
3050 |
+
echo '</select>';
|
3051 |
+
}
|
3052 |
+
|
3053 |
+
// Build line height.
|
3054 |
+
if ( in_array( 'line-height', $ot_recognized_typography_fields, true ) ) {
|
3055 |
+
$line_height = isset( $field_value['line-height'] ) ? esc_attr( $field_value['line-height'] ) : '';
|
3056 |
+
echo '<select name="' . esc_attr( $field_name ) . '[line-height]" id="' . esc_attr( $field_id ) . '-line-height" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3057 |
+
echo '<option value="">line-height</option>';
|
3058 |
+
foreach ( ot_recognized_line_heights( $field_id ) as $option ) {
|
3059 |
+
echo '<option value="' . esc_attr( $option ) . '" ' . selected( $line_height, $option, false ) . '>' . esc_attr( $option ) . '</option>';
|
3060 |
+
}
|
3061 |
+
echo '</select>';
|
3062 |
+
}
|
3063 |
+
|
3064 |
+
// Build text decoration.
|
3065 |
+
if ( in_array( 'text-decoration', $ot_recognized_typography_fields, true ) ) {
|
3066 |
+
$text_decoration = isset( $field_value['text-decoration'] ) ? esc_attr( $field_value['text-decoration'] ) : '';
|
3067 |
+
echo '<select name="' . esc_attr( $field_name ) . '[text-decoration]" id="' . esc_attr( $field_id ) . '-text-decoration" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3068 |
+
echo '<option value="">text-decoration</option>';
|
3069 |
+
foreach ( ot_recognized_text_decorations( $field_id ) as $key => $value ) {
|
3070 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $text_decoration, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3071 |
+
}
|
3072 |
+
echo '</select>';
|
3073 |
+
}
|
3074 |
+
|
3075 |
+
// Build text transform.
|
3076 |
+
if ( in_array( 'text-transform', $ot_recognized_typography_fields, true ) ) {
|
3077 |
+
$text_transform = isset( $field_value['text-transform'] ) ? esc_attr( $field_value['text-transform'] ) : '';
|
3078 |
+
echo '<select name="' . esc_attr( $field_name ) . '[text-transform]" id="' . esc_attr( $field_id ) . '-text-transform" class="option-tree-ui-select ' . esc_attr( $field_class ) . '">';
|
3079 |
+
echo '<option value="">text-transform</option>';
|
3080 |
+
foreach ( ot_recognized_text_transformations( $field_id ) as $key => $value ) {
|
3081 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected( $text_transform, $key, false ) . '>' . esc_attr( $value ) . '</option>';
|
3082 |
+
}
|
3083 |
+
echo '</select>';
|
3084 |
+
}
|
3085 |
+
|
3086 |
+
echo '</div>';
|
3087 |
+
|
3088 |
+
echo '</div>';
|
3089 |
+
|
3090 |
+
}
|
3091 |
}
|
3092 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3093 |
if ( ! function_exists( 'ot_type_upload' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3094 |
|
3095 |
+
/**
|
3096 |
+
* Upload option type.
|
3097 |
+
*
|
3098 |
+
* See @ot_display_by_type to see the full list of available arguments.
|
3099 |
+
*
|
3100 |
+
* @param array $args An array of arguments.
|
3101 |
+
*
|
3102 |
+
* @access public
|
3103 |
+
* @since 2.0
|
3104 |
+
*/
|
3105 |
+
function ot_type_upload( $args = array() ) {
|
3106 |
+
|
3107 |
+
// Turns arguments array into variables.
|
3108 |
+
extract( $args ); // phpcs:ignore
|
3109 |
+
|
3110 |
+
// Verify a description.
|
3111 |
+
$has_desc = ! empty( $field_desc ) ? true : false;
|
3112 |
+
|
3113 |
+
// If an attachment ID is stored here fetch its URL and replace the value.
|
3114 |
+
if ( $field_value && wp_attachment_is_image( $field_value ) ) {
|
3115 |
+
|
3116 |
+
$attachment_data = wp_get_attachment_image_src( $field_value, 'original' );
|
3117 |
+
|
3118 |
+
// Check for attachment data.
|
3119 |
+
if ( $attachment_data ) {
|
3120 |
+
|
3121 |
+
$field_src = $attachment_data[0];
|
3122 |
+
}
|
3123 |
+
}
|
3124 |
+
|
3125 |
+
// Format setting outer wrapper.
|
3126 |
+
echo '<div class="format-setting type-upload ' . ( $has_desc ? 'has-desc' : 'no-desc' ) . '">';
|
3127 |
+
|
3128 |
+
// Description.
|
3129 |
+
echo $has_desc ? '<div class="description">' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '</div>' : ''; // phpcs:ignore
|
3130 |
+
|
3131 |
+
// Format setting inner wrapper.
|
3132 |
+
echo '<div class="format-setting-inner">';
|
3133 |
+
|
3134 |
+
// Build upload.
|
3135 |
+
echo '<div class="option-tree-ui-upload-parent">';
|
3136 |
+
|
3137 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $field_value ) . '" class="widefat option-tree-ui-upload-input ' . esc_attr( $field_class ) . '" />';
|
3138 |
+
|
3139 |
+
// Add media button.
|
3140 |
+
echo '<a href="javascript:void(0);" class="ot_upload_media option-tree-ui-button button button-primary light" rel="' . esc_attr( $post_id ) . '" title="' . esc_html__( 'Add Media', 'option-tree' ) . '"><span class="icon ot-icon-plus-circle"></span>' . esc_html__( 'Add Media', 'option-tree' ) . '</a>'; // phpcs:ignore
|
3141 |
+
|
3142 |
+
echo '</div>';
|
3143 |
+
|
3144 |
+
// Media.
|
3145 |
+
if ( $field_value ) {
|
3146 |
+
|
3147 |
+
echo '<div class="option-tree-ui-media-wrap" id="' . esc_attr( $field_id ) . '_media">';
|
3148 |
+
|
3149 |
+
// Replace image src.
|
3150 |
+
if ( isset( $field_src ) ) {
|
3151 |
+
$field_value = $field_src;
|
3152 |
+
}
|
3153 |
+
|
3154 |
+
if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value ) ) {
|
3155 |
+
echo '<div class="option-tree-ui-image-wrap"><img src="' . esc_url( $field_value ) . '" alt="" /></div>';
|
3156 |
+
}
|
3157 |
+
|
3158 |
+
echo '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="' . esc_html__( 'Remove Media', 'option-tree' ) . '"><span class="icon ot-icon-minus-circle"></span>' . esc_html__( 'Remove Media', 'option-tree' ) . '</a>';
|
3159 |
+
|
3160 |
+
echo '</div>';
|
3161 |
+
|
3162 |
+
}
|
3163 |
+
|
3164 |
+
echo '</div>';
|
3165 |
+
|
3166 |
+
echo '</div>';
|
3167 |
+
}
|
3168 |
+
}
|
includes/ot-functions-settings-page.php
CHANGED
@@ -1,572 +1,487 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* OptionTree
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
*
|
14 |
-
* @return string
|
15 |
-
*
|
16 |
-
* @access public
|
17 |
-
* @since 2.0
|
18 |
-
*/
|
19 |
-
if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
|
20 |
-
|
21 |
-
function ot_type_theme_options_ui() {
|
22 |
-
global $blog_id;
|
23 |
-
|
24 |
-
echo '<form method="post" id="option-tree-settings-form">';
|
25 |
-
|
26 |
-
/* form nonce */
|
27 |
-
wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
|
28 |
-
|
29 |
-
/* format setting outer wrapper */
|
30 |
-
echo '<div class="format-setting type-textblock has-desc">';
|
31 |
-
|
32 |
-
/* description */
|
33 |
-
echo '<div class="description">';
|
34 |
-
|
35 |
-
echo '<h4>'. __( 'Warning!', 'option-tree' ) . '</h4>';
|
36 |
-
echo '<p class="warning">' . sprintf( __( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) . '"><code>Appearance->Theme Options</code></a>' ) . '</p>';
|
37 |
-
echo '<p class="warning">' . sprintf( __( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' ), '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation' ) . '"><code>OptionTree->Documentation</code></a>' ) . '</p>';
|
38 |
-
echo '<h4>'. __( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
|
39 |
-
echo '<p class="warning">' . __( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '</p>';
|
40 |
-
echo '<p>' . __( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '</p>';
|
41 |
-
echo '<p>' . __( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '</p>';
|
42 |
-
|
43 |
-
echo '</div>';
|
44 |
-
|
45 |
-
/* get the saved settings */
|
46 |
-
$settings = get_option( ot_settings_id() );
|
47 |
-
|
48 |
-
/* wrap settings array */
|
49 |
-
echo '<div class="format-setting-inner">';
|
50 |
-
|
51 |
-
/* set count to zero */
|
52 |
-
$count = 0;
|
53 |
-
|
54 |
-
/* loop through each section and its settings */
|
55 |
-
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="' . ot_settings_id() . '[settings]">';
|
56 |
-
|
57 |
-
if ( isset( $settings['sections'] ) ) {
|
58 |
-
|
59 |
-
foreach( $settings['sections'] as $section ) {
|
60 |
-
|
61 |
-
/* section */
|
62 |
-
echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '</li>';
|
63 |
-
|
64 |
-
/* increment item count */
|
65 |
-
$count++;
|
66 |
-
|
67 |
-
/* settings in this section */
|
68 |
-
if ( isset( $settings['settings'] ) ) {
|
69 |
-
|
70 |
-
foreach( $settings['settings'] as $setting ) {
|
71 |
-
|
72 |
-
if ( isset( $setting['section'] ) && $setting['section'] == $section['id'] ) {
|
73 |
-
|
74 |
-
echo '<li class="ui-state-default list-setting">' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '</li>';
|
75 |
-
|
76 |
-
/* increment item count */
|
77 |
-
$count++;
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
-
}
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
echo '</ul>';
|
90 |
-
|
91 |
-
/* buttons */
|
92 |
-
echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button button hug-left">' . __( 'Add Section', 'option-tree' ) . '</a>';
|
93 |
-
echo '<a href="javascript:void(0);" class="option-tree-setting-add option-tree-ui-button button">' . __( 'Add Setting', 'option-tree' ) . '</a>';
|
94 |
-
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
|
95 |
-
|
96 |
-
/* sidebar textarea */
|
97 |
-
echo '
|
98 |
-
<div class="format-setting-label" id="contextual-help-label">
|
99 |
-
<h3 class="label">' . __( 'Contextual Help', 'option-tree' ) . '</h3>
|
100 |
-
</div>
|
101 |
-
<div class="format-settings" id="contextual-help-setting">
|
102 |
-
<div class="format-setting type-textarea no-desc">
|
103 |
-
<div class="description"><strong>' . __( 'Contextual Help Sidebar', 'option-tree' ) . '</strong>: ' . __( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '</div>
|
104 |
-
<div class="format-setting-inner">
|
105 |
-
<textarea class="textarea" rows="10" cols="40" name="' . ot_settings_id(). '[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
|
106 |
-
</div>
|
107 |
-
</div>
|
108 |
-
</div>';
|
109 |
-
|
110 |
-
/* set count to zero */
|
111 |
-
$count = 0;
|
112 |
-
|
113 |
-
/* loop through each contextual_help content section */
|
114 |
-
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="' . ot_settings_id(). '[contextual_help][content]">';
|
115 |
-
|
116 |
-
if ( isset( $settings['contextual_help']['content'] ) ) {
|
117 |
-
|
118 |
-
foreach( $settings['contextual_help']['content'] as $content ) {
|
119 |
-
|
120 |
-
/* content */
|
121 |
-
echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]', $count, $content ) . '</li>';
|
122 |
-
|
123 |
-
/* increment content count */
|
124 |
-
$count++;
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
echo '</ul>';
|
131 |
-
|
132 |
-
echo '<a href="javascript:void(0);" class="option-tree-help-add option-tree-ui-button button hug-left">' . __( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
|
133 |
-
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Changes', 'option-tree' ) . '</button>';
|
134 |
-
|
135 |
-
echo '</div>';
|
136 |
-
|
137 |
-
echo '</div>';
|
138 |
-
|
139 |
-
echo '</form>';
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
-
/**
|
204 |
-
* Import Settings option type.
|
205 |
-
*
|
206 |
-
* @return string
|
207 |
-
*
|
208 |
-
* @access public
|
209 |
-
* @since 2.0
|
210 |
-
*/
|
211 |
if ( ! function_exists( 'ot_type_import_settings' ) ) {
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
|
|
|
|
|
|
246 |
}
|
247 |
|
248 |
-
/**
|
249 |
-
* Import Data option type.
|
250 |
-
*
|
251 |
-
* @return string
|
252 |
-
*
|
253 |
-
* @access public
|
254 |
-
* @since 2.0
|
255 |
-
*/
|
256 |
if ( ! function_exists( 'ot_type_import_data' ) ) {
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
293 |
}
|
294 |
|
295 |
-
/**
|
296 |
-
* Import Layouts option type.
|
297 |
-
*
|
298 |
-
* @return string
|
299 |
-
*
|
300 |
-
* @access public
|
301 |
-
* @since 2.0
|
302 |
-
*/
|
303 |
if ( ! function_exists( 'ot_type_import_layouts' ) ) {
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
340 |
}
|
341 |
|
342 |
-
/**
|
343 |
-
* Export Settings File option type.
|
344 |
-
*
|
345 |
-
* @return string
|
346 |
-
*
|
347 |
-
* @access public
|
348 |
-
* @since 2.0.8
|
349 |
-
*/
|
350 |
if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
385 |
}
|
386 |
|
387 |
-
/**
|
388 |
-
* Export Settings option type.
|
389 |
-
*
|
390 |
-
* @return string
|
391 |
-
*
|
392 |
-
* @access public
|
393 |
-
* @since 2.0
|
394 |
-
*/
|
395 |
if ( ! function_exists( 'ot_type_export_settings' ) ) {
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
}
|
422 |
|
423 |
-
/**
|
424 |
-
* Export Data option type.
|
425 |
-
*
|
426 |
-
* @return string
|
427 |
-
*
|
428 |
-
* @access public
|
429 |
-
* @since 2.0
|
430 |
-
*/
|
431 |
if ( ! function_exists( 'ot_type_export_data' ) ) {
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
}
|
458 |
|
459 |
-
/**
|
460 |
-
* Export Layouts option type.
|
461 |
-
*
|
462 |
-
* @return string
|
463 |
-
*
|
464 |
-
* @access public
|
465 |
-
* @since 2.0
|
466 |
-
*/
|
467 |
if ( ! function_exists( 'ot_type_export_layouts' ) ) {
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
|
|
|
|
|
|
|
|
|
|
494 |
}
|
495 |
|
496 |
-
/**
|
497 |
-
* Modify Layouts option type.
|
498 |
-
*
|
499 |
-
* @return string
|
500 |
-
*
|
501 |
-
* @access public
|
502 |
-
* @since 2.0
|
503 |
-
*/
|
504 |
if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
|
505 |
-
|
506 |
-
function ot_type_modify_layouts() {
|
507 |
-
|
508 |
-
echo '<form method="post" id="option-tree-settings-form">';
|
509 |
-
|
510 |
-
/* form nonce */
|
511 |
-
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
512 |
-
|
513 |
-
/* format setting outer wrapper */
|
514 |
-
echo '<div class="format-setting type-textarea has-desc">';
|
515 |
-
|
516 |
-
/* description */
|
517 |
-
echo '<div class="description">';
|
518 |
-
|
519 |
-
echo '<p>' . __( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '</p>';
|
520 |
-
echo '<p>' . __( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '</p>';
|
521 |
-
echo '<p>' . __( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '</p>';
|
522 |
-
if ( OT_SHOW_DOCS ) echo '<p>' . __( 'Visit <code>OptionTree->Documentation->Layouts Overview</code> to see a more in-depth description of what layouts are and how to use them.', 'option-tree' ) . '</p>';
|
523 |
-
|
524 |
-
echo '</div>';
|
525 |
-
|
526 |
-
echo '<div class="format-setting-inner">';
|
527 |
-
|
528 |
-
/* get the saved layouts */
|
529 |
-
$layouts = get_option( ot_layouts_id() );
|
530 |
-
|
531 |
-
/* set active layout */
|
532 |
-
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
533 |
-
|
534 |
-
echo '<input type="hidden" name="' . ot_layouts_id() . '[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
|
535 |
-
|
536 |
-
/* add new layout */
|
537 |
-
echo '<input type="text" name="' . ot_layouts_id() . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
538 |
-
|
539 |
-
/* loop through each layout */
|
540 |
-
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
|
541 |
-
|
542 |
-
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
543 |
-
|
544 |
-
foreach( $layouts as $key => $data ) {
|
545 |
-
|
546 |
-
/* skip active layout array */
|
547 |
-
if ( $key == 'active_layout' )
|
548 |
-
continue;
|
549 |
-
|
550 |
-
/* content */
|
551 |
-
echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>';
|
552 |
-
|
553 |
-
}
|
554 |
-
|
555 |
-
}
|
556 |
-
|
557 |
-
echo '</ul>';
|
558 |
-
|
559 |
-
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . __( 'Save Layouts', 'option-tree' ) . '</button>';
|
560 |
-
|
561 |
-
echo '</div>';
|
562 |
-
|
563 |
-
echo '</div>';
|
564 |
-
|
565 |
-
echo '</form>';
|
566 |
-
|
567 |
-
}
|
568 |
-
|
569 |
-
}
|
570 |
|
571 |
-
|
572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Settings Page Functions.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
11 |
|
12 |
+
if ( ! function_exists( 'ot_type_theme_options_ui' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Create option type.
|
16 |
+
*
|
17 |
+
* @access public
|
18 |
+
* @since 2.0
|
19 |
+
*/
|
20 |
+
function ot_type_theme_options_ui() {
|
21 |
+
global $blog_id;
|
22 |
+
|
23 |
+
echo '<form method="post" id="option-tree-settings-form">';
|
24 |
+
|
25 |
+
// Form nonce.
|
26 |
+
wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' );
|
27 |
+
|
28 |
+
// Format setting outer wrapper.
|
29 |
+
echo '<div class="format-setting type-textblock has-desc">';
|
30 |
+
|
31 |
+
// Description.
|
32 |
+
echo '<div class="description">';
|
33 |
+
|
34 |
+
echo '<h4>' . esc_html__( 'Warning!', 'option-tree' ) . '</h4>';
|
35 |
+
|
36 |
+
/* translators: %s: link to theme options */
|
37 |
+
$string = esc_html__( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' );
|
38 |
+
echo '<p class="warning">' . sprintf( $string, '<a href="' . esc_url_raw( get_admin_url( $blog_id, apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) . '"><code>' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '</code></a>' ) . '</p>'; // phpcs:ignore
|
39 |
+
|
40 |
+
/* translators: %s: link to documentation */
|
41 |
+
$string = esc_html__( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' );
|
42 |
+
echo '<p class="warning">' . sprintf( $string, '<a href="' . esc_url_raw( get_admin_url( $blog_id, 'admin.php?page=ot-documentation' ) ) . '"><code>' . esc_html__( 'OptionTree->Documentation', 'option-tree' ) . '</code></a>' ) . '</p>'; // phpcs:ignore
|
43 |
+
|
44 |
+
echo '<h4>' . esc_html__( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '</h4>';
|
45 |
+
echo '<p class="warning">' . esc_html__( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '</p>';
|
46 |
+
echo '<p>' . esc_html__( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '</p>';
|
47 |
+
echo '<p>' . esc_html__( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '</p>';
|
48 |
+
|
49 |
+
echo '</div>';
|
50 |
+
|
51 |
+
// Get the saved settings.
|
52 |
+
$settings = get_option( ot_settings_id() );
|
53 |
+
|
54 |
+
// Wrap settings array.
|
55 |
+
echo '<div class="format-setting-inner">';
|
56 |
+
|
57 |
+
// Set count to zero.
|
58 |
+
$count = 0;
|
59 |
+
|
60 |
+
// Loop through each section and its settings.
|
61 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_list" data-name="' . esc_attr( ot_settings_id() ) . '[settings]">';
|
62 |
+
|
63 |
+
if ( isset( $settings['sections'] ) ) {
|
64 |
+
|
65 |
+
foreach ( $settings['sections'] as $section ) {
|
66 |
+
|
67 |
+
// Section.
|
68 |
+
echo '<li class="' . ( $count == 0 ? 'ui-state-disabled' : 'ui-state-default' ) . ' list-section">' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '</li>'; // phpcs:ignore
|
69 |
+
|
70 |
+
// Increment item count.
|
71 |
+
$count++;
|
72 |
+
|
73 |
+
// Settings in this section.
|
74 |
+
if ( isset( $settings['settings'] ) ) {
|
75 |
+
|
76 |
+
foreach ( $settings['settings'] as $setting ) {
|
77 |
+
|
78 |
+
if ( isset( $setting['section'] ) && $setting['section'] === $section['id'] ) {
|
79 |
+
|
80 |
+
echo '<li class="ui-state-default list-setting">' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '</li>'; // phpcs:ignore
|
81 |
+
|
82 |
+
// Increment item count.
|
83 |
+
$count++;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
echo '</ul>';
|
91 |
+
|
92 |
+
// Buttons.
|
93 |
+
echo '<a href="javascript:void(0);" class="option-tree-section-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Section', 'option-tree' ) . '</a>';
|
94 |
+
echo '<a href="javascript:void(0);" class="option-tree-setting-add option-tree-ui-button button">' . esc_html__( 'Add Setting', 'option-tree' ) . '</a>';
|
95 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Changes', 'option-tree' ) . '</button>';
|
96 |
+
|
97 |
+
// Sidebar textarea.
|
98 |
+
echo '
|
99 |
+
<div class="format-setting-label" id="contextual-help-label">
|
100 |
+
<h3 class="label">' . esc_html__( 'Contextual Help', 'option-tree' ) . '</h3>
|
101 |
+
</div>
|
102 |
+
<div class="format-settings" id="contextual-help-setting">
|
103 |
+
<div class="format-setting type-textarea no-desc">
|
104 |
+
<div class="description"><strong>' . esc_html__( 'Contextual Help Sidebar', 'option-tree' ) . '</strong>: ' . esc_html__( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '</div>
|
105 |
+
<div class="format-setting-inner">
|
106 |
+
<textarea class="textarea" rows="10" cols="40" name="' . esc_attr( ot_settings_id() ) . '[contextual_help][sidebar]">' . ( isset( $settings['contextual_help']['sidebar'] ) ? esc_html( $settings['contextual_help']['sidebar'] ) : '' ) . '</textarea>
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
</div>';
|
110 |
+
|
111 |
+
// Set count to zero.
|
112 |
+
$count = 0;
|
113 |
+
|
114 |
+
// Loop through each contextual_help content section.
|
115 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_settings_help" data-name="' . esc_attr( ot_settings_id() ) . '[contextual_help][content]">';
|
116 |
+
|
117 |
+
if ( isset( $settings['contextual_help']['content'] ) ) {
|
118 |
+
|
119 |
+
foreach ( $settings['contextual_help']['content'] as $content ) {
|
120 |
+
|
121 |
+
// Content.
|
122 |
+
echo '<li class="ui-state-default list-contextual-help">' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]', $count, $content ) . '</li>'; // phpcs:ignore
|
123 |
+
|
124 |
+
// Increment content count.
|
125 |
+
$count++;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
echo '</ul>';
|
130 |
+
|
131 |
+
echo '<a href="javascript:void(0);" class="option-tree-help-add option-tree-ui-button button hug-left">' . esc_html__( 'Add Contextual Help Content', 'option-tree' ) . '</a>';
|
132 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Changes', 'option-tree' ) . '</button>';
|
133 |
+
|
134 |
+
echo '</div>';
|
135 |
+
|
136 |
+
echo '</div>';
|
137 |
+
|
138 |
+
echo '</form>';
|
139 |
+
}
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
if ( ! function_exists( 'ot_type_import_settings' ) ) {
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Import Settings option type.
|
146 |
+
*
|
147 |
+
* @access public
|
148 |
+
* @since 2.0
|
149 |
+
*/
|
150 |
+
function ot_type_import_settings() {
|
151 |
+
|
152 |
+
echo '<form method="post" id="import-settings-form">';
|
153 |
+
|
154 |
+
// Form nonce.
|
155 |
+
wp_nonce_field( 'import_settings_form', 'import_settings_nonce' );
|
156 |
+
|
157 |
+
// Format setting outer wrapper.
|
158 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
159 |
+
|
160 |
+
// Description.
|
161 |
+
echo '<div class="description">';
|
162 |
+
|
163 |
+
echo '<p>' . esc_html__( 'To import your Settings copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Settings" button.', 'option-tree' ) . '</p>';
|
164 |
+
|
165 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Settings', 'option-tree' ) . '</button>';
|
166 |
+
|
167 |
+
echo '</div>';
|
168 |
+
|
169 |
+
echo '<div class="format-setting-inner">';
|
170 |
+
|
171 |
+
echo '<textarea rows="10" cols="40" name="import_settings" id="import_settings" class="textarea"></textarea>';
|
172 |
+
|
173 |
+
echo '</div>';
|
174 |
+
|
175 |
+
echo '</div>';
|
176 |
+
|
177 |
+
echo '</form>';
|
178 |
+
|
179 |
+
}
|
180 |
}
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
if ( ! function_exists( 'ot_type_import_data' ) ) {
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Import Data option type.
|
186 |
+
*
|
187 |
+
* @access public
|
188 |
+
* @since 2.0
|
189 |
+
*/
|
190 |
+
function ot_type_import_data() {
|
191 |
+
|
192 |
+
echo '<form method="post" id="import-data-form">';
|
193 |
+
|
194 |
+
// Form nonce.
|
195 |
+
wp_nonce_field( 'import_data_form', 'import_data_nonce' );
|
196 |
+
|
197 |
+
// Format setting outer wrapper.
|
198 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
199 |
+
|
200 |
+
// Description.
|
201 |
+
echo '<div class="description">';
|
202 |
+
|
203 |
+
if ( OT_SHOW_SETTINGS_IMPORT ) {
|
204 |
+
echo '<p>' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '</p>';
|
205 |
+
}
|
206 |
+
|
207 |
+
echo '<p>' . esc_html__( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '</p>';
|
208 |
+
|
209 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Theme Options', 'option-tree' ) . '</button>';
|
210 |
+
|
211 |
+
echo '</div>';
|
212 |
+
|
213 |
+
echo '<div class="format-setting-inner">';
|
214 |
+
|
215 |
+
echo '<textarea rows="10" cols="40" name="import_data" id="import_data" class="textarea"></textarea>';
|
216 |
+
|
217 |
+
echo '</div>';
|
218 |
+
|
219 |
+
echo '</div>';
|
220 |
+
|
221 |
+
echo '</form>';
|
222 |
+
}
|
223 |
}
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
if ( ! function_exists( 'ot_type_import_layouts' ) ) {
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Import Layouts option type.
|
229 |
+
*
|
230 |
+
* @access public
|
231 |
+
* @since 2.0
|
232 |
+
*/
|
233 |
+
function ot_type_import_layouts() {
|
234 |
+
|
235 |
+
echo '<form method="post" id="import-layouts-form">';
|
236 |
+
|
237 |
+
// Form nonce.
|
238 |
+
wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' );
|
239 |
+
|
240 |
+
// Format setting outer wrapper.
|
241 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
242 |
+
|
243 |
+
// Description.
|
244 |
+
echo '<div class="description">';
|
245 |
+
|
246 |
+
if ( OT_SHOW_SETTINGS_IMPORT ) {
|
247 |
+
echo '<p>' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '</p>';
|
248 |
+
}
|
249 |
+
|
250 |
+
echo '<p>' . esc_html__( 'To import your Layouts copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Layouts" button. Keep in mind that when you import your layouts, the active layout\'s saved data will write over the current data set for your Theme Options.', 'option-tree' ) . '</p>';
|
251 |
+
|
252 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Import Layouts', 'option-tree' ) . '</button>';
|
253 |
+
|
254 |
+
echo '</div>';
|
255 |
+
|
256 |
+
echo '<div class="format-setting-inner">';
|
257 |
+
|
258 |
+
echo '<textarea rows="10" cols="40" name="import_layouts" id="import_layouts" class="textarea"></textarea>';
|
259 |
+
|
260 |
+
echo '</div>';
|
261 |
+
|
262 |
+
echo '</div>';
|
263 |
+
|
264 |
+
echo '</form>';
|
265 |
+
}
|
266 |
}
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
if ( ! function_exists( 'ot_type_export_settings_file' ) ) {
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Export Settings File option type.
|
272 |
+
*
|
273 |
+
* @access public
|
274 |
+
* @since 2.0.8
|
275 |
+
*/
|
276 |
+
function ot_type_export_settings_file() {
|
277 |
+
global $blog_id;
|
278 |
+
|
279 |
+
echo '<form method="post" id="export-settings-file-form">';
|
280 |
+
|
281 |
+
// Form nonce.
|
282 |
+
wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' );
|
283 |
+
|
284 |
+
// Format setting outer wrapper.
|
285 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
286 |
+
|
287 |
+
// Description.
|
288 |
+
echo '<div class="description">';
|
289 |
+
|
290 |
+
/* translators: %1$s: file name, %2$s: link to I18n docs, %3$s: link to internal docs */
|
291 |
+
$string = esc_html__( 'Export your Settings into a fully functional %1$s file. If you want to add your own custom %2$s text domain to the file, enter it into the text field before exporting. For more information on how to use this file read the documentation on %3$s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' );
|
292 |
+
echo '<p>' . sprintf( $string, '<code>theme-options.php</code>', '<a href="http://codex.wordpress.org/I18n_for_WordPress_Developers" target="_blank">I18n</a>', '<a href="' . get_admin_url( $blog_id, 'admin.php?page=ot-documentation#section_theme_mode' ) . '">' . esc_html__( 'Theme Mode', 'option-tree' ) . '</a>' ) . '</p>'; // phpcs:ignore
|
293 |
+
|
294 |
+
echo '</div>';
|
295 |
+
|
296 |
+
echo '<div class="format-setting-inner">';
|
297 |
+
|
298 |
+
echo '<input type="text" name="domain" value="" class="widefat option-tree-ui-input" placeholder="text-domain" autocomplete="off" />';
|
299 |
+
|
300 |
+
echo '<button class="option-tree-ui-button button button-primary hug-left">' . esc_html__( 'Export Settings File', 'option-tree' ) . '</button>';
|
301 |
+
|
302 |
+
echo '</div>';
|
303 |
+
|
304 |
+
echo '</div>';
|
305 |
+
|
306 |
+
echo '</form>';
|
307 |
+
}
|
308 |
}
|
309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
if ( ! function_exists( 'ot_type_export_settings' ) ) {
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Export Settings option type.
|
314 |
+
*
|
315 |
+
* @access public
|
316 |
+
* @since 2.0
|
317 |
+
*/
|
318 |
+
function ot_type_export_settings() {
|
319 |
+
|
320 |
+
// Format setting outer wrapper.
|
321 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
322 |
+
|
323 |
+
// Description.
|
324 |
+
echo '<div class="description">';
|
325 |
+
|
326 |
+
/* translators: %1$s: visual path to import, %2$s: visual path to settings */
|
327 |
+
$string = esc_html__( 'Export your Settings by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %1$s textarea on another web site.', 'option-tree' );
|
328 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Settings', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
329 |
+
|
330 |
+
echo '</div>';
|
331 |
+
|
332 |
+
// Get theme options data.
|
333 |
+
$settings = get_option( ot_settings_id(), array() );
|
334 |
+
$settings = ! empty( $settings ) ? ot_encode( $settings ) : '';
|
335 |
+
|
336 |
+
echo '<div class="format-setting-inner">';
|
337 |
+
echo '<textarea rows="10" cols="40" name="export_settings" id="export_settings" class="textarea">' . $settings . '</textarea>'; // phpcs:ignore
|
338 |
+
echo '</div>';
|
339 |
+
|
340 |
+
echo '</div>';
|
341 |
+
|
342 |
+
}
|
343 |
}
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
if ( ! function_exists( 'ot_type_export_data' ) ) {
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Export Data option type.
|
349 |
+
*
|
350 |
+
* @access public
|
351 |
+
* @since 2.0
|
352 |
+
*/
|
353 |
+
function ot_type_export_data() {
|
354 |
+
|
355 |
+
// Format setting outer wrapper.
|
356 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
357 |
+
|
358 |
+
// Description.
|
359 |
+
echo '<div class="description">';
|
360 |
+
|
361 |
+
/* translators: %1$s: visual path to import, %2$s: visual path to theme options */
|
362 |
+
$string = esc_html__( 'Export your Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %2$s textarea on another web site.', 'option-tree' );
|
363 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Theme Options', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
364 |
+
|
365 |
+
echo '</div>';
|
366 |
+
|
367 |
+
// Get theme options data.
|
368 |
+
$data = get_option( ot_options_id(), array() );
|
369 |
+
$data = ! empty( $data ) ? ot_encode( $data ) : '';
|
370 |
+
|
371 |
+
echo '<div class="format-setting-inner">';
|
372 |
+
echo '<textarea rows="10" cols="40" name="export_data" id="export_data" class="textarea">' . $data . '</textarea>'; // phpcs:ignore
|
373 |
+
echo '</div>';
|
374 |
+
|
375 |
+
echo '</div>';
|
376 |
+
|
377 |
+
}
|
378 |
}
|
379 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
if ( ! function_exists( 'ot_type_export_layouts' ) ) {
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Export Layouts option type.
|
384 |
+
*
|
385 |
+
* @access public
|
386 |
+
* @since 2.0
|
387 |
+
*/
|
388 |
+
function ot_type_export_layouts() {
|
389 |
+
|
390 |
+
// Format setting outer wrapper.
|
391 |
+
echo '<div class="format-setting type-textarea simple has-desc">';
|
392 |
+
|
393 |
+
// Description.
|
394 |
+
echo '<div class="description">';
|
395 |
+
|
396 |
+
/* translators: %1$s: visual path to import, %2$s: visual path to layouts */
|
397 |
+
$string = esc_html__( 'Export your Layouts by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %2$s textarea on another web site.', 'option-tree' );
|
398 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '</code>', '<code>' . esc_html__( 'Layouts', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
399 |
+
|
400 |
+
echo '</div>';
|
401 |
+
|
402 |
+
// Get layout data.
|
403 |
+
$layouts = get_option( ot_layouts_id(), array() );
|
404 |
+
$layouts = ! empty( $layouts ) ? ot_encode( $layouts ) : '';
|
405 |
+
|
406 |
+
echo '<div class="format-setting-inner">';
|
407 |
+
echo '<textarea rows="10" cols="40" name="export_layouts" id="export_layouts" class="textarea">' . $layouts . '</textarea>'; // phpcs:ignore
|
408 |
+
echo '</div>';
|
409 |
+
|
410 |
+
echo '</div>';
|
411 |
+
}
|
412 |
}
|
413 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
if ( ! function_exists( 'ot_type_modify_layouts' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
|
416 |
+
/**
|
417 |
+
* Modify Layouts option type.
|
418 |
+
*
|
419 |
+
* @access public
|
420 |
+
* @since 2.0
|
421 |
+
*/
|
422 |
+
function ot_type_modify_layouts() {
|
423 |
+
|
424 |
+
echo '<form method="post" id="option-tree-settings-form">';
|
425 |
+
|
426 |
+
// Form nonce.
|
427 |
+
wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' );
|
428 |
+
|
429 |
+
// Format setting outer wrapper.
|
430 |
+
echo '<div class="format-setting type-textarea has-desc">';
|
431 |
+
|
432 |
+
// Description.
|
433 |
+
echo '<div class="description">';
|
434 |
+
|
435 |
+
echo '<p>' . esc_html__( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '</p>';
|
436 |
+
echo '<p>' . esc_html__( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '</p>';
|
437 |
+
echo '<p>' . esc_html__( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '</p>';
|
438 |
+
|
439 |
+
if ( OT_SHOW_DOCS ) {
|
440 |
+
/* translators: %s: visual path to layouts overview */
|
441 |
+
$string = esc_html__( 'Visit %s to see a more in-depth description of what layouts are and how to use them.', 'option-tree' );
|
442 |
+
echo '<p>' . sprintf( $string, '<code>' . esc_html__( 'OptionTree->Documentation->Layouts Overview', 'option-tree' ) . '</code>' ) . '</p>'; // phpcs:ignore
|
443 |
+
}
|
444 |
+
|
445 |
+
echo '</div>';
|
446 |
+
|
447 |
+
echo '<div class="format-setting-inner">';
|
448 |
+
|
449 |
+
// Get the saved layouts.
|
450 |
+
$layouts = get_option( ot_layouts_id() );
|
451 |
+
|
452 |
+
// Set active layout.
|
453 |
+
$active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : '';
|
454 |
+
|
455 |
+
echo '<input type="hidden" name="' . esc_attr( ot_layouts_id() ) . '[active_layout]" value="' . esc_attr( $active_layout ) . '" class="active-layout-input" />';
|
456 |
+
|
457 |
+
// Add new layout.
|
458 |
+
echo '<input type="text" name="' . esc_attr( ot_layouts_id() ) . '[_add_new_layout_]" value="" class="widefat option-tree-ui-input" autocomplete="off" />';
|
459 |
+
|
460 |
+
// Loop through each layout.
|
461 |
+
echo '<ul class="option-tree-setting-wrap option-tree-sortable" id="option_tree_layouts">';
|
462 |
+
|
463 |
+
if ( is_array( $layouts ) && ! empty( $layouts ) ) {
|
464 |
+
|
465 |
+
foreach ( $layouts as $key => $data ) {
|
466 |
+
|
467 |
+
// Skip active layout array.
|
468 |
+
if ( 'active_layout' === $key ) {
|
469 |
+
continue;
|
470 |
+
}
|
471 |
+
|
472 |
+
// Content.
|
473 |
+
echo '<li class="ui-state-default list-layouts">' . ot_layout_view( $key, $data, $active_layout ) . '</li>'; // phpcs:ignore
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
echo '</ul>';
|
478 |
+
|
479 |
+
echo '<button class="option-tree-ui-button button button-primary right hug-right">' . esc_html__( 'Save Layouts', 'option-tree' ) . '</button>';
|
480 |
+
|
481 |
+
echo '</div>';
|
482 |
+
|
483 |
+
echo '</div>';
|
484 |
+
|
485 |
+
echo '</form>';
|
486 |
+
}
|
487 |
+
}
|
includes/ot-functions.php
CHANGED
@@ -1,397 +1,363 @@
|
|
1 |
-
<?php
|
2 |
/**
|
3 |
-
* OptionTree
|
4 |
*
|
5 |
-
* @package
|
6 |
-
* @author Derek Herman <derek@valendesigns.com>
|
7 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
8 |
-
* @since 2.0
|
9 |
*/
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
*
|
16 |
-
* @access public
|
17 |
-
* @since 2.3.0
|
18 |
-
*/
|
19 |
if ( ! function_exists( 'ot_options_id' ) ) {
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
-
/**
|
30 |
-
* Theme Settings ID
|
31 |
-
*
|
32 |
-
* @return string
|
33 |
-
*
|
34 |
-
* @access public
|
35 |
-
* @since 2.3.0
|
36 |
-
*/
|
37 |
if ( ! function_exists( 'ot_settings_id' ) ) {
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
-
/**
|
48 |
-
* Theme Layouts ID
|
49 |
-
*
|
50 |
-
* @return string
|
51 |
-
*
|
52 |
-
* @access public
|
53 |
-
* @since 2.3.0
|
54 |
-
*/
|
55 |
if ( ! function_exists( 'ot_layouts_id' ) ) {
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
-
/**
|
66 |
-
* Get Option.
|
67 |
-
*
|
68 |
-
* Helper function to return the option value.
|
69 |
-
* If no value has been saved, it returns $default.
|
70 |
-
*
|
71 |
-
* @param string The option ID.
|
72 |
-
* @param string The default option value.
|
73 |
-
* @return mixed
|
74 |
-
*
|
75 |
-
* @access public
|
76 |
-
* @since 2.0
|
77 |
-
*/
|
78 |
if ( ! function_exists( 'ot_get_option' ) ) {
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
-
/**
|
99 |
-
* Echo Option.
|
100 |
-
*
|
101 |
-
* Helper function to echo the option value.
|
102 |
-
* If no value has been saved, it echos $default.
|
103 |
-
*
|
104 |
-
* @param string The option ID.
|
105 |
-
* @param string The default option value.
|
106 |
-
* @return mixed
|
107 |
-
*
|
108 |
-
* @access public
|
109 |
-
* @since 2.2.0
|
110 |
-
*/
|
111 |
if ( ! function_exists( 'ot_echo_option' ) ) {
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
-
/**
|
122 |
-
* Filter the return values through WPML
|
123 |
-
*
|
124 |
-
* @param array $options The current options
|
125 |
-
* @param string $option_id The option ID
|
126 |
-
* @return mixed
|
127 |
-
*
|
128 |
-
* @access public
|
129 |
-
* @since 2.1
|
130 |
-
*/
|
131 |
if ( ! function_exists( 'ot_wpml_filter' ) ) {
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
// List Item & Slider
|
145 |
-
if ( $option_id == $setting['id'] && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) {
|
146 |
-
|
147 |
-
foreach( $options[$option_id] as $key => $value ) {
|
148 |
-
|
149 |
-
foreach( $value as $ckey => $cvalue ) {
|
150 |
-
|
151 |
-
$id = $option_id . '_' . $ckey . '_' . $key;
|
152 |
-
$_string = icl_t( 'Theme Options', $id, $cvalue );
|
153 |
-
|
154 |
-
if ( ! empty( $_string ) ) {
|
155 |
-
|
156 |
-
$options[$option_id][$key][$ckey] = $_string;
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
// List Item & Slider
|
165 |
-
} else if ( $option_id == $setting['id'] && $setting['type'] == 'social-links' ) {
|
166 |
-
|
167 |
-
foreach( $options[$option_id] as $key => $value ) {
|
168 |
-
|
169 |
-
foreach( $value as $ckey => $cvalue ) {
|
170 |
-
|
171 |
-
$id = $option_id . '_' . $ckey . '_' . $key;
|
172 |
-
$_string = icl_t( 'Theme Options', $id, $cvalue );
|
173 |
-
|
174 |
-
if ( ! empty( $_string ) ) {
|
175 |
-
|
176 |
-
$options[$option_id][$key][$ckey] = $_string;
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
}
|
181 |
-
|
182 |
-
}
|
183 |
-
|
184 |
-
// All other acceptable option types
|
185 |
-
} else if ( $option_id == $setting['id'] && in_array( $setting['type'], apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ) ) ) {
|
186 |
-
|
187 |
-
$_string = icl_t( 'Theme Options', $option_id, $options[$option_id] );
|
188 |
-
|
189 |
-
if ( ! empty( $_string ) ) {
|
190 |
-
|
191 |
-
$options[$option_id] = $_string;
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
196 |
-
|
197 |
-
}
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
return $options[$option_id];
|
204 |
-
|
205 |
-
}
|
206 |
|
207 |
-
|
|
|
208 |
|
209 |
-
|
210 |
-
* Enqueue the dynamic CSS.
|
211 |
-
*
|
212 |
-
* @return void
|
213 |
-
*
|
214 |
-
* @access public
|
215 |
-
* @since 2.0
|
216 |
-
*/
|
217 |
-
if ( ! function_exists( 'ot_load_dynamic_css' ) ) {
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
/* don't load in the admin */
|
222 |
-
if ( is_admin() ) {
|
223 |
-
return;
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Filter whether or not to enqueue a `dynamic.css` file at the theme level.
|
228 |
-
*
|
229 |
-
* By filtering this to `false` OptionTree will not attempt to enqueue any CSS files.
|
230 |
-
*
|
231 |
-
* Example: add_filter( 'ot_load_dynamic_css', '__return_false' );
|
232 |
-
*
|
233 |
-
* @since 2.5.5
|
234 |
-
*
|
235 |
-
* @param bool $load_dynamic_css Default is `true`.
|
236 |
-
* @return bool
|
237 |
-
*/
|
238 |
-
if ( false === (bool) apply_filters( 'ot_load_dynamic_css', true ) ) {
|
239 |
-
return;
|
240 |
-
}
|
241 |
-
|
242 |
-
/* grab a copy of the paths */
|
243 |
-
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
244 |
-
if ( is_multisite() ) {
|
245 |
-
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
246 |
-
}
|
247 |
-
|
248 |
-
if ( ! empty( $ot_css_file_paths ) ) {
|
249 |
-
|
250 |
-
$last_css = '';
|
251 |
-
|
252 |
-
/* loop through paths */
|
253 |
-
foreach( $ot_css_file_paths as $key => $path ) {
|
254 |
-
|
255 |
-
if ( '' != $path && file_exists( $path ) ) {
|
256 |
-
|
257 |
-
$parts = explode( '/wp-content', $path );
|
258 |
-
|
259 |
-
if ( isset( $parts[1] ) ) {
|
260 |
-
|
261 |
-
$sub_parts = explode( '/', $parts[1] );
|
262 |
-
|
263 |
-
if ( isset( $sub_parts[1] ) && isset( $sub_parts[2] ) ) {
|
264 |
-
if ( $sub_parts[1] == 'themes' && $sub_parts[2] != get_stylesheet() ) {
|
265 |
-
continue;
|
266 |
-
}
|
267 |
-
}
|
268 |
-
|
269 |
-
$css = set_url_scheme( WP_CONTENT_URL ) . $parts[1];
|
270 |
-
|
271 |
-
if ( $last_css !== $css ) {
|
272 |
-
|
273 |
-
/* enqueue filtered file */
|
274 |
-
wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION );
|
275 |
-
|
276 |
-
$last_css = $css;
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
}
|
281 |
-
|
282 |
-
}
|
283 |
-
|
284 |
-
}
|
285 |
-
|
286 |
-
}
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
}
|
291 |
|
292 |
-
|
293 |
-
* Enqueue the Google Fonts CSS.
|
294 |
-
*
|
295 |
-
* @return void
|
296 |
-
*
|
297 |
-
* @access public
|
298 |
-
* @since 2.5.0
|
299 |
-
*/
|
300 |
-
if ( ! function_exists( 'ot_load_google_fonts_css' ) ) {
|
301 |
|
302 |
-
|
|
|
303 |
|
304 |
-
|
305 |
-
if ( is_admin() )
|
306 |
-
return;
|
307 |
|
308 |
-
|
309 |
-
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
310 |
-
$families = array();
|
311 |
-
$subsets = array();
|
312 |
-
$append = '';
|
313 |
|
314 |
-
|
|
|
315 |
|
316 |
-
|
317 |
|
318 |
-
|
|
|
|
|
|
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
continue;
|
323 |
-
}
|
324 |
|
325 |
-
|
326 |
-
if ( ! empty( $font['variants'] ) && is_array( $font['variants'] ) ) {
|
327 |
|
328 |
-
|
329 |
-
$variants = ':' . implode( ',', $font['variants'] );
|
330 |
|
331 |
-
|
332 |
-
|
333 |
-
foreach( $font['subsets'] as $subset ) {
|
334 |
-
$subsets[] = $subset;
|
335 |
-
}
|
336 |
-
}
|
337 |
|
338 |
-
|
339 |
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
|
345 |
-
|
|
|
346 |
|
347 |
-
|
348 |
|
349 |
-
|
350 |
|
351 |
-
|
|
|
|
|
|
|
|
|
|
|
352 |
|
353 |
-
|
|
|
|
|
354 |
|
355 |
-
|
356 |
-
if ( ! empty( $subsets ) ) {
|
357 |
-
$subsets = implode( ',', array_unique( $subsets ) );
|
358 |
-
if ( $subsets != 'latin' ) {
|
359 |
-
$append = '&subset=' . $subsets;
|
360 |
-
}
|
361 |
-
}
|
362 |
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
-
|
367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
|
370 |
-
/**
|
371 |
-
* Registers the Theme Option page link for the admin bar.
|
372 |
-
*
|
373 |
-
* @return void
|
374 |
-
*
|
375 |
-
* @access public
|
376 |
-
* @since 2.1
|
377 |
-
*/
|
378 |
if ( ! function_exists( 'ot_register_theme_options_admin_bar_menu' ) ) {
|
379 |
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
}
|
395 |
-
|
396 |
-
/* End of file ot-functions.php */
|
397 |
-
/* Location: ./includes/ot-functions.php */
|
1 |
+
<?php
|
2 |
/**
|
3 |
+
* OptionTree Function.
|
4 |
*
|
5 |
+
* @package OptionTree
|
|
|
|
|
|
|
6 |
*/
|
7 |
|
8 |
+
if ( ! defined( 'OT_VERSION' ) ) {
|
9 |
+
exit( 'No direct script access allowed' );
|
10 |
+
}
|
11 |
+
|
|
|
|
|
|
|
|
|
12 |
if ( ! function_exists( 'ot_options_id' ) ) {
|
13 |
|
14 |
+
/**
|
15 |
+
* Theme Options ID
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*
|
19 |
+
* @access public
|
20 |
+
* @since 2.3.0
|
21 |
+
*/
|
22 |
+
function ot_options_id() {
|
23 |
+
|
24 |
+
return apply_filters( 'ot_options_id', 'option_tree' );
|
25 |
+
|
26 |
+
}
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
if ( ! function_exists( 'ot_settings_id' ) ) {
|
30 |
|
31 |
+
/**
|
32 |
+
* Theme Settings ID
|
33 |
+
*
|
34 |
+
* @return string
|
35 |
+
*
|
36 |
+
* @access public
|
37 |
+
* @since 2.3.0
|
38 |
+
*/
|
39 |
+
function ot_settings_id() {
|
40 |
+
|
41 |
+
return apply_filters( 'ot_settings_id', 'option_tree_settings' );
|
42 |
+
|
43 |
+
}
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
if ( ! function_exists( 'ot_layouts_id' ) ) {
|
47 |
|
48 |
+
/**
|
49 |
+
* Theme Layouts ID
|
50 |
+
*
|
51 |
+
* @return string
|
52 |
+
*
|
53 |
+
* @access public
|
54 |
+
* @since 2.3.0
|
55 |
+
*/
|
56 |
+
function ot_layouts_id() {
|
57 |
+
|
58 |
+
return apply_filters( 'ot_layouts_id', 'option_tree_layouts' );
|
59 |
+
|
60 |
+
}
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
if ( ! function_exists( 'ot_get_option' ) ) {
|
64 |
|
65 |
+
/**
|
66 |
+
* Get Option.
|
67 |
+
*
|
68 |
+
* Helper function to return the option value.
|
69 |
+
* If no value has been saved, it returns $default.
|
70 |
+
*
|
71 |
+
* @param string $option_id The option ID.
|
72 |
+
* @param string $default The default option value.
|
73 |
+
* @return mixed
|
74 |
+
*
|
75 |
+
* @access public
|
76 |
+
* @since 2.0
|
77 |
+
*/
|
78 |
+
function ot_get_option( $option_id, $default = '' ) {
|
79 |
+
|
80 |
+
// Get the saved options.
|
81 |
+
$options = get_option( ot_options_id() );
|
82 |
+
|
83 |
+
// Look for the saved value.
|
84 |
+
if ( isset( $options[ $option_id ] ) && '' !== $options[ $option_id ] ) {
|
85 |
+
|
86 |
+
return ot_wpml_filter( $options, $option_id );
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
return $default;
|
91 |
+
|
92 |
+
}
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
if ( ! function_exists( 'ot_echo_option' ) ) {
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Echo Option.
|
99 |
+
*
|
100 |
+
* Helper function to echo the option value.
|
101 |
+
* If no value has been saved, it echos $default.
|
102 |
+
*
|
103 |
+
* @param string $option_id The option ID.
|
104 |
+
* @param string $default The default option value.
|
105 |
+
* @return mixed
|
106 |
+
*
|
107 |
+
* @access public
|
108 |
+
* @since 2.2.0
|
109 |
+
*/
|
110 |
+
function ot_echo_option( $option_id, $default = '' ) {
|
111 |
+
|
112 |
+
echo ot_get_option( $option_id, $default ); // phpcs:ignore
|
113 |
+
|
114 |
+
}
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
if ( ! function_exists( 'ot_wpml_filter' ) ) {
|
118 |
|
119 |
+
/**
|
120 |
+
* Filter the return values through WPML
|
121 |
+
*
|
122 |
+
* @param array $options The current options.
|
123 |
+
* @param string $option_id The option ID.
|
124 |
+
* @return mixed
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @since 2.1
|
128 |
+
*/
|
129 |
+
function ot_wpml_filter( $options, $option_id ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
+
// Return translated strings using WMPL.
|
132 |
+
if ( function_exists( 'icl_t' ) ) {
|
133 |
|
134 |
+
$settings = get_option( ot_settings_id() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
+
if ( isset( $settings['settings'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
foreach ( $settings['settings'] as $setting ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
+
// List Item & Slider.
|
141 |
+
if ( $option_id === $setting['id'] && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) {
|
142 |
|
143 |
+
foreach ( $options[ $option_id ] as $key => $value ) {
|
|
|
|
|
144 |
|
145 |
+
foreach ( $value as $ckey => $cvalue ) {
|
|
|
|
|
|
|
|
|
146 |
|
147 |
+
$id = $option_id . '_' . $ckey . '_' . $key;
|
148 |
+
$_string = icl_t( 'Theme Options', $id, $cvalue );
|
149 |
|
150 |
+
if ( ! empty( $_string ) ) {
|
151 |
|
152 |
+
$options[ $option_id ][ $key ][ $ckey ] = $_string;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
|
157 |
+
// List Item & Slider.
|
158 |
+
} elseif ( $option_id === $setting['id'] && 'social-links' === $setting['type'] ) {
|
|
|
|
|
159 |
|
160 |
+
foreach ( $options[ $option_id ] as $key => $value ) {
|
|
|
161 |
|
162 |
+
foreach ( $value as $ckey => $cvalue ) {
|
|
|
163 |
|
164 |
+
$id = $option_id . '_' . $ckey . '_' . $key;
|
165 |
+
$_string = icl_t( 'Theme Options', $id, $cvalue );
|
|
|
|
|
|
|
|
|
166 |
|
167 |
+
if ( ! empty( $_string ) ) {
|
168 |
|
169 |
+
$options[ $option_id ][ $key ][ $ckey ] = $_string;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
|
174 |
+
// All other acceptable option types.
|
175 |
+
} elseif ( $option_id === $setting['id'] && in_array( $setting['type'], apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ), true ) ) {
|
176 |
|
177 |
+
$_string = icl_t( 'Theme Options', $option_id, $options[ $option_id ] );
|
178 |
|
179 |
+
if ( ! empty( $_string ) ) {
|
180 |
|
181 |
+
$options[ $option_id ] = $_string;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
|
188 |
+
return $options[ $option_id ];
|
189 |
+
}
|
190 |
+
}
|
191 |
|
192 |
+
if ( ! function_exists( 'ot_load_dynamic_css' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
|
194 |
+
/**
|
195 |
+
* Enqueue the dynamic CSS.
|
196 |
+
*
|
197 |
+
* @access public
|
198 |
+
* @since 2.0
|
199 |
+
*/
|
200 |
+
function ot_load_dynamic_css() {
|
201 |
+
|
202 |
+
// Don't load in the admin.
|
203 |
+
if ( is_admin() ) {
|
204 |
+
return;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Filter whether or not to enqueue a `dynamic.css` file at the theme level.
|
209 |
+
*
|
210 |
+
* By filtering this to `false` OptionTree will not attempt to enqueue any CSS files.
|
211 |
+
*
|
212 |
+
* Example: add_filter( 'ot_load_dynamic_css', '__return_false' );
|
213 |
+
*
|
214 |
+
* @since 2.5.5
|
215 |
+
*
|
216 |
+
* @param bool $load_dynamic_css Default is `true`.
|
217 |
+
* @return bool
|
218 |
+
*/
|
219 |
+
if ( false === (bool) apply_filters( 'ot_load_dynamic_css', true ) ) {
|
220 |
+
return;
|
221 |
+
}
|
222 |
+
|
223 |
+
// Grab a copy of the paths.
|
224 |
+
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
|
225 |
+
if ( is_multisite() ) {
|
226 |
+
$ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths );
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( ! empty( $ot_css_file_paths ) ) {
|
230 |
+
|
231 |
+
$last_css = '';
|
232 |
+
|
233 |
+
// Loop through paths.
|
234 |
+
foreach ( $ot_css_file_paths as $key => $path ) {
|
235 |
+
|
236 |
+
if ( '' !== $path && file_exists( $path ) ) {
|
237 |
+
|
238 |
+
$parts = explode( '/wp-content', $path );
|
239 |
+
|
240 |
+
if ( isset( $parts[1] ) ) {
|
241 |
+
|
242 |
+
$sub_parts = explode( '/', $parts[1] );
|
243 |
+
|
244 |
+
if ( isset( $sub_parts[1] ) && isset( $sub_parts[2] ) ) {
|
245 |
+
if ( 'themes' !== $sub_parts[1] && get_stylesheet() !== $sub_parts[2] ) {
|
246 |
+
continue;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
$css = set_url_scheme( WP_CONTENT_URL ) . $parts[1];
|
251 |
+
|
252 |
+
if ( $last_css !== $css ) {
|
253 |
+
|
254 |
+
// Enqueue filtered file.
|
255 |
+
wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION );
|
256 |
+
|
257 |
+
$last_css = $css;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
265 |
+
}
|
266 |
|
267 |
+
if ( ! function_exists( 'ot_load_google_fonts_css' ) ) {
|
268 |
|
269 |
+
/**
|
270 |
+
* Enqueue the Google Fonts CSS.
|
271 |
+
*
|
272 |
+
* @access public
|
273 |
+
* @since 2.5.0
|
274 |
+
*/
|
275 |
+
function ot_load_google_fonts_css() {
|
276 |
+
|
277 |
+
/* don't load in the admin */
|
278 |
+
if ( is_admin() ) {
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
|
282 |
+
$ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() );
|
283 |
+
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
|
284 |
+
$families = array();
|
285 |
+
$subsets = array();
|
286 |
+
$append = '';
|
287 |
+
|
288 |
+
if ( ! empty( $ot_set_google_fonts ) ) {
|
289 |
+
|
290 |
+
foreach ( $ot_set_google_fonts as $id => $fonts ) {
|
291 |
+
|
292 |
+
foreach ( $fonts as $font ) {
|
293 |
+
|
294 |
+
// Can't find the font, bail!
|
295 |
+
if ( ! isset( $ot_google_fonts[ $font['family'] ]['family'] ) ) {
|
296 |
+
continue;
|
297 |
+
}
|
298 |
+
|
299 |
+
// Set variants & subsets.
|
300 |
+
if ( ! empty( $font['variants'] ) && is_array( $font['variants'] ) ) {
|
301 |
+
|
302 |
+
// Variants string.
|
303 |
+
$variants = ':' . implode( ',', $font['variants'] );
|
304 |
+
|
305 |
+
// Add subsets to array.
|
306 |
+
if ( ! empty( $font['subsets'] ) && is_array( $font['subsets'] ) ) {
|
307 |
+
foreach ( $font['subsets'] as $subset ) {
|
308 |
+
$subsets[] = $subset;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
}
|
312 |
+
|
313 |
+
// Add family & variants to array.
|
314 |
+
if ( isset( $variants ) ) {
|
315 |
+
$families[] = str_replace( ' ', '+', $ot_google_fonts[ $font['family'] ]['family'] ) . $variants;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
if ( ! empty( $families ) ) {
|
322 |
+
|
323 |
+
$families = array_unique( $families );
|
324 |
+
|
325 |
+
// Append all subsets to the path, unless the only subset is latin.
|
326 |
+
if ( ! empty( $subsets ) ) {
|
327 |
+
$subsets = implode( ',', array_unique( $subsets ) );
|
328 |
+
if ( 'latin' !== $subsets ) {
|
329 |
+
$append = '&subset=' . $subsets;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
wp_enqueue_style( 'ot-google-fonts', esc_url( '//fonts.googleapis.com/css?family=' . implode( '%7C', $families ) ) . $append, false, null ); // phpcs:ignore
|
334 |
+
}
|
335 |
+
}
|
336 |
}
|
337 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
if ( ! function_exists( 'ot_register_theme_options_admin_bar_menu' ) ) {
|
339 |
|
340 |
+
/**
|
341 |
+
* Registers the Theme Option page link for the admin bar.
|
342 |
+
*
|
343 |
+
* @access public
|
344 |
+
* @since 2.1
|
345 |
+
*
|
346 |
+
* @param object $wp_admin_bar The WP_Admin_Bar object.
|
347 |
+
*/
|
348 |
+
function ot_register_theme_options_admin_bar_menu( $wp_admin_bar ) {
|
349 |
+
|
350 |
+
if ( ! current_user_can( apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ) ) || ! is_admin_bar_showing() ) {
|
351 |
+
return;
|
352 |
+
}
|
353 |
+
|
354 |
+
$wp_admin_bar->add_node(
|
355 |
+
array(
|
356 |
+
'parent' => 'appearance',
|
357 |
+
'id' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ),
|
358 |
+
'title' => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ),
|
359 |
+
'href' => admin_url( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ),
|
360 |
+
)
|
361 |
+
);
|
362 |
+
}
|
363 |
}
|
|
|
|
|
|
includes/ot-meta-box-api.php
DELETED
@@ -1,363 +0,0 @@
|
|
1 |
-
<?php if ( ! defined( 'OT_VERSION' ) ) exit( 'No direct script access allowed' );
|
2 |
-
/**
|
3 |
-
* OptionTree Meta Box API
|
4 |
-
*
|
5 |
-
* This class loads all the methods and helpers specific to build a meta box.
|
6 |
-
*
|
7 |
-
* @package OptionTree
|
8 |
-
* @author Derek Herman <derek@valendesigns.com>
|
9 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
10 |
-
*/
|
11 |
-
if ( ! class_exists( 'OT_Meta_Box' ) ) {
|
12 |
-
|
13 |
-
class OT_Meta_Box {
|
14 |
-
|
15 |
-
/* variable to store the meta box array */
|
16 |
-
private $meta_box;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* PHP5 constructor method.
|
20 |
-
*
|
21 |
-
* This method adds other methods of the class to specific hooks within WordPress.
|
22 |
-
*
|
23 |
-
* @uses add_action()
|
24 |
-
*
|
25 |
-
* @return void
|
26 |
-
*
|
27 |
-
* @access public
|
28 |
-
* @since 1.0
|
29 |
-
*/
|
30 |
-
function __construct( $meta_box ) {
|
31 |
-
if ( ! is_admin() )
|
32 |
-
return;
|
33 |
-
|
34 |
-
global $ot_meta_boxes;
|
35 |
-
|
36 |
-
if ( ! isset( $ot_meta_boxes ) ) {
|
37 |
-
$ot_meta_boxes = array();
|
38 |
-
}
|
39 |
-
|
40 |
-
$ot_meta_boxes[] = $meta_box;
|
41 |
-
|
42 |
-
$this->meta_box = $meta_box;
|
43 |
-
|
44 |
-
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
|
45 |
-
|
46 |
-
add_action( 'save_post', array( $this, 'save_meta_box' ), 1, 2 );
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Adds meta box to any post type
|
52 |
-
*
|
53 |
-
* @uses add_meta_box()
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
*
|
57 |
-
* @access public
|
58 |
-
* @since 1.0
|
59 |
-
*/
|
60 |
-
function add_meta_boxes() {
|
61 |
-
foreach ( (array) $this->meta_box['pages'] as $page ) {
|
62 |
-
add_meta_box( $this->meta_box['id'], $this->meta_box['title'], array( $this, 'build_meta_box' ), $page, $this->meta_box['context'], $this->meta_box['priority'], $this->meta_box['fields'] );
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Meta box view
|
68 |
-
*
|
69 |
-
* @return string
|
70 |
-
*
|
71 |
-
* @access public
|
72 |
-
* @since 1.0
|
73 |
-
*/
|
74 |
-
function build_meta_box( $post, $metabox ) {
|
75 |
-
|
76 |
-
echo '<div class="ot-metabox-wrapper">';
|
77 |
-
|
78 |
-
/* Use nonce for verification */
|
79 |
-
echo '<input type="hidden" name="' . $this->meta_box['id'] . '_nonce" value="' . wp_create_nonce( $this->meta_box['id'] ) . '" />';
|
80 |
-
|
81 |
-
/* meta box description */
|
82 |
-
echo isset( $this->meta_box['desc'] ) && ! empty( $this->meta_box['desc'] ) ? '<div class="description" style="padding-top:10px;">' . htmlspecialchars_decode( $this->meta_box['desc'] ) . '</div>' : '';
|
83 |
-
|
84 |
-
/* loop through meta box fields */
|
85 |
-
foreach ( $this->meta_box['fields'] as $field ) {
|
86 |
-
|
87 |
-
/* get current post meta data */
|
88 |
-
$field_value = get_post_meta( $post->ID, $field['id'], true );
|
89 |
-
|
90 |
-
/* set standard value */
|
91 |
-
if ( isset( $field['std'] ) ) {
|
92 |
-
$field_value = ot_filter_std_value( $field_value, $field['std'] );
|
93 |
-
}
|
94 |
-
|
95 |
-
/* build the arguments array */
|
96 |
-
$_args = array(
|
97 |
-
'type' => $field['type'],
|
98 |
-
'field_id' => $field['id'],
|
99 |
-
'field_name' => $field['id'],
|
100 |
-
'field_value' => $field_value,
|
101 |
-
'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '',
|
102 |
-
'field_std' => isset( $field['std'] ) ? $field['std'] : '',
|
103 |
-
'field_rows' => isset( $field['rows'] ) && ! empty( $field['rows'] ) ? $field['rows'] : 10,
|
104 |
-
'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post',
|
105 |
-
'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category',
|
106 |
-
'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1',
|
107 |
-
'field_class' => isset( $field['class'] ) ? $field['class'] : '',
|
108 |
-
'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '',
|
109 |
-
'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and',
|
110 |
-
'field_choices' => isset( $field['choices'] ) ? $field['choices'] : array(),
|
111 |
-
'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(),
|
112 |
-
'post_id' => $post->ID,
|
113 |
-
'meta' => true
|
114 |
-
);
|
115 |
-
|
116 |
-
$conditions = '';
|
117 |
-
|
118 |
-
/* setup the conditions */
|
119 |
-
if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) {
|
120 |
-
|
121 |
-
$conditions = ' data-condition="' . $field['condition'] . '"';
|
122 |
-
$conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : '';
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
/* only allow simple textarea due to DOM issues with wp_editor() */
|
127 |
-
if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' )
|
128 |
-
$_args['type'] = 'textarea-simple';
|
129 |
-
|
130 |
-
// Build the setting CSS class
|
131 |
-
if ( ! empty( $_args['field_class'] ) ) {
|
132 |
-
|
133 |
-
$classes = explode( ' ', $_args['field_class'] );
|
134 |
-
|
135 |
-
foreach( $classes as $key => $value ) {
|
136 |
-
|
137 |
-
$classes[$key] = $value . '-wrap';
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
$class = 'format-settings ' . implode( ' ', $classes );
|
142 |
-
|
143 |
-
} else {
|
144 |
-
|
145 |
-
$class = 'format-settings';
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
/* option label */
|
150 |
-
echo '<div id="setting_' . $field['id'] . '" class="' . $class . '"' . $conditions . '>';
|
151 |
-
|
152 |
-
echo '<div class="format-setting-wrap">';
|
153 |
-
|
154 |
-
/* don't show title with textblocks */
|
155 |
-
if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) {
|
156 |
-
echo '<div class="format-setting-label">';
|
157 |
-
echo '<label for="' . $field['id'] . '" class="label">' . $field['label'] . '</label>';
|
158 |
-
echo '</div>';
|
159 |
-
}
|
160 |
-
|
161 |
-
/* get the option HTML */
|
162 |
-
echo ot_display_by_type( $_args );
|
163 |
-
|
164 |
-
echo '</div>';
|
165 |
-
|
166 |
-
echo '</div>';
|
167 |
-
|
168 |
-
}
|
169 |
-
|
170 |
-
echo '<div class="clear"></div>';
|
171 |
-
|
172 |
-
echo '</div>';
|
173 |
-
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Saves the meta box values
|
178 |
-
*
|
179 |
-
* @return void
|
180 |
-
*
|
181 |
-
* @access public
|
182 |
-
* @since 1.0
|
183 |
-
*/
|
184 |
-
function save_meta_box( $post_id, $post_object ) {
|
185 |
-
global $pagenow;
|
186 |
-
|
187 |
-
/* don't save if $_POST is empty */
|
188 |
-
if ( empty( $_POST ) || ( isset( $_POST['vc_inline'] ) && $_POST['vc_inline'] == true ) )
|
189 |
-
return $post_id;
|
190 |
-
|
191 |
-
/* don't save during quick edit */
|
192 |
-
if ( $pagenow == 'admin-ajax.php' )
|
193 |
-
return $post_id;
|
194 |
-
|
195 |
-
/* don't save during autosave */
|
196 |
-
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
197 |
-
return $post_id;
|
198 |
-
|
199 |
-
/* don't save if viewing a revision */
|
200 |
-
if ( $post_object->post_type == 'revision' || $pagenow == 'revision.php' )
|
201 |
-
return $post_id;
|
202 |
-
|
203 |
-
/* verify nonce */
|
204 |
-
if ( isset( $_POST[ $this->meta_box['id'] . '_nonce'] ) && ! wp_verify_nonce( $_POST[ $this->meta_box['id'] . '_nonce'], $this->meta_box['id'] ) )
|
205 |
-
return $post_id;
|
206 |
-
|
207 |
-
/* check permissions */
|
208 |
-
if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
|
209 |
-
if ( ! current_user_can( 'edit_page', $post_id ) )
|
210 |
-
return $post_id;
|
211 |
-
} else {
|
212 |
-
if ( ! current_user_can( 'edit_post', $post_id ) )
|
213 |
-
return $post_id;
|
214 |
-
}
|
215 |
-
|
216 |
-
foreach ( $this->meta_box['fields'] as $field ) {
|
217 |
-
|
218 |
-
$old = get_post_meta( $post_id, $field['id'], true );
|
219 |
-
$new = '';
|
220 |
-
|
221 |
-
/* there is data to validate */
|
222 |
-
if ( isset( $_POST[$field['id']] ) ) {
|
223 |
-
|
224 |
-
/* slider and list item */
|
225 |
-
if ( in_array( $field['type'], array( 'list-item', 'slider' ) ) ) {
|
226 |
-
|
227 |
-
/* required title setting */
|
228 |
-
$required_setting = array(
|
229 |
-
array(
|
230 |
-
'id' => 'title',
|
231 |
-
'label' => __( 'Title', 'option-tree' ),
|
232 |
-
'desc' => '',
|
233 |
-
'std' => '',
|
234 |
-
'type' => 'text',
|
235 |
-
'rows' => '',
|
236 |
-
'class' => 'option-tree-setting-title',
|
237 |
-
'post_type' => '',
|
238 |
-
'choices' => array()
|
239 |
-
)
|
240 |
-
);
|
241 |
-
|
242 |
-
/* get the settings array */
|
243 |
-
$settings = isset( $_POST[$field['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$field['id'] . '_settings_array'] ) ) : array();
|
244 |
-
|
245 |
-
/* settings are empty for some odd ass reason get the defaults */
|
246 |
-
if ( empty( $settings ) ) {
|
247 |
-
$settings = 'slider' == $field['type'] ?
|
248 |
-
ot_slider_settings( $field['id'] ) :
|
249 |
-
ot_list_item_settings( $field['id'] );
|
250 |
-
}
|
251 |
-
|
252 |
-
/* merge the two settings array */
|
253 |
-
$settings = array_merge( $required_setting, $settings );
|
254 |
-
|
255 |
-
foreach( $_POST[$field['id']] as $k => $setting_array ) {
|
256 |
-
|
257 |
-
foreach( $settings as $sub_setting ) {
|
258 |
-
|
259 |
-
/* verify sub setting has a type & value */
|
260 |
-
if ( isset( $sub_setting['type'] ) && isset( $_POST[$field['id']][$k][$sub_setting['id']] ) ) {
|
261 |
-
|
262 |
-
$_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting( $_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] );
|
263 |
-
|
264 |
-
}
|
265 |
-
|
266 |
-
}
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
/* set up new data with validated data */
|
271 |
-
$new = $_POST[$field['id']];
|
272 |
-
|
273 |
-
} else if ( $field['type'] == 'social-links' ) {
|
274 |
-
|
275 |
-
/* get the settings array */
|
276 |
-
$settings = isset( $_POST[$field['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$field['id'] . '_settings_array'] ) ) : array();
|
277 |
-
|
278 |
-
/* settings are empty get the defaults */
|
279 |
-
if ( empty( $settings ) ) {
|
280 |
-
$settings = ot_social_links_settings( $field['id'] );
|
281 |
-
}
|
282 |
-
|
283 |
-
foreach( $_POST[$field['id']] as $k => $setting_array ) {
|
284 |
-
|
285 |
-
foreach( $settings as $sub_setting ) {
|
286 |
-
|
287 |
-
/* verify sub setting has a type & value */
|
288 |
-
if ( isset( $sub_setting['type'] ) && isset( $_POST[$field['id']][$k][$sub_setting['id']] ) ) {
|
289 |
-
|
290 |
-
$_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting( $_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] );
|
291 |
-
|
292 |
-
}
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
}
|
297 |
-
|
298 |
-
/* set up new data with validated data */
|
299 |
-
$new = $_POST[$field['id']];
|
300 |
-
|
301 |
-
} else {
|
302 |
-
|
303 |
-
/* run through validattion */
|
304 |
-
$new = ot_validate_setting( $_POST[$field['id']], $field['type'], $field['id'] );
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
/* insert CSS */
|
309 |
-
if ( $field['type'] == 'css' ) {
|
310 |
-
|
311 |
-
/* insert CSS into dynamic.css */
|
312 |
-
if ( '' !== $new ) {
|
313 |
-
|
314 |
-
ot_insert_css_with_markers( $field['id'], $new, true );
|
315 |
-
|
316 |
-
/* remove old CSS from dynamic.css */
|
317 |
-
} else {
|
318 |
-
|
319 |
-
ot_remove_old_css( $field['id'] );
|
320 |
-
|
321 |
-
}
|
322 |
-
|
323 |
-
}
|
324 |
-
|
325 |
-
}
|
326 |
-
|
327 |
-
if ( isset( $new ) && $new !== $old ) {
|
328 |
-
update_post_meta( $post_id, $field['id'], $new );
|
329 |
-
} else if ( '' == $new && $old ) {
|
330 |
-
delete_post_meta( $post_id, $field['id'], $old );
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
}
|
335 |
-
|
336 |
-
}
|
337 |
-
|
338 |
-
}
|
339 |
-
|
340 |
-
/**
|
341 |
-
* This method instantiates the meta box class & builds the UI.
|
342 |
-
*
|
343 |
-
* @uses OT_Meta_Box()
|
344 |
-
*
|
345 |
-
* @param array Array of arguments to create a meta box
|
346 |
-
* @return void
|
347 |
-
*
|
348 |
-
* @access public
|
349 |
-
* @since 2.0
|
350 |
-
*/
|
351 |
-
if ( ! function_exists( 'ot_register_meta_box' ) ) {
|
352 |
-
|
353 |
-
function ot_register_meta_box( $args ) {
|
354 |
-
if ( ! $args )
|
355 |
-
return;
|
356 |
-
|
357 |
-
$ot_meta_box = new OT_Meta_Box( $args );
|
358 |
-
}
|
359 |
-
|
360 |
-
}
|
361 |
-
|
362 |
-
/* End of file ot-meta-box-api.php */
|
363 |
-
/* Location: ./includes/ot-meta-box-api.php */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/ot-post-formats-api.php
DELETED
@@ -1,131 +0,0 @@
|
|
1 |
-
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
|
2 |
-
/**
|
3 |
-
* OptionTree Post Formats API
|
4 |
-
*
|
5 |
-
* This class loads all the methods and helpers specific to build a the post format metaboxes.
|
6 |
-
*
|
7 |
-
* @package OptionTree
|
8 |
-
* @author Derek Herman <derek@valendesigns.com>
|
9 |
-
* @copyright Copyright (c) 2014, Derek Herman
|
10 |
-
*/
|
11 |
-
if ( ! class_exists( 'OT_Post_Formats' ) ) {
|
12 |
-
|
13 |
-
class OT_Post_Formats {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Class Constructor
|
17 |
-
*
|
18 |
-
* @return void
|
19 |
-
*
|
20 |
-
* @access public
|
21 |
-
* @since 2.3.0
|
22 |
-
*/
|
23 |
-
public function __construct() {
|
24 |
-
|
25 |
-
$this->setup_actions();
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Setup the default filters and actions
|
31 |
-
*
|
32 |
-
* @uses add_action() To add various actions
|
33 |
-
* @uses add_filter() To add various filters
|
34 |
-
*
|
35 |
-
* @return void
|
36 |
-
*
|
37 |
-
* @access private
|
38 |
-
* @since 2.3.0
|
39 |
-
*/
|
40 |
-
private function setup_actions() {
|
41 |
-
|
42 |
-
// Initialize the meta boxes
|
43 |
-
add_action( 'admin_init', array( $this, 'meta_boxes' ), 2 );
|
44 |
-
|
45 |
-
// Setup pings for the link & quote URLs
|
46 |
-
add_filter( 'pre_ping', array( $this, 'pre_ping_post_links' ), 10, 3 );
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Builds the default Meta Boxes.
|
52 |
-
*
|
53 |
-
* @return void
|
54 |
-
*
|
55 |
-
* @access private
|
56 |
-
* @since 2.3.0
|
57 |
-
*/
|
58 |
-
public function meta_boxes() {
|
59 |
-
|
60 |
-
// Exit if called outside of WP admin
|
61 |
-
if ( ! is_admin() )
|
62 |
-
return false;
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Filter the post formats meta boxes.
|
66 |
-
*
|
67 |
-
* @since 2.6.0
|
68 |
-
*
|
69 |
-
* @param array $meta_boxes The meta boxes being registered.
|
70 |
-
* @return array
|
71 |
-
*/
|
72 |
-
$meta_boxes = apply_filters( 'ot_recognized_post_format_meta_boxes', array(
|
73 |
-
ot_meta_box_post_format_gallery(),
|
74 |
-
ot_meta_box_post_format_link(),
|
75 |
-
ot_meta_box_post_format_quote(),
|
76 |
-
ot_meta_box_post_format_video(),
|
77 |
-
ot_meta_box_post_format_audio(),
|
78 |
-
) );
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Register our meta boxes using the
|
82 |
-
* ot_register_meta_box() function.
|
83 |
-
*/
|
84 |
-
foreach( $meta_boxes as $meta_box ) {
|
85 |
-
|
86 |
-
ot_register_meta_box( $meta_box );
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Setup pings for the link & quote URLs
|
94 |
-
*
|
95 |
-
* @param array $post_links The URLs to ping
|
96 |
-
* @param array $pung Pinged URLs
|
97 |
-
* @param int $post_id Post ID
|
98 |
-
* @return array
|
99 |
-
*
|
100 |
-
* @access public
|
101 |
-
* @since 2.3.0
|
102 |
-
*/
|
103 |
-
public function pre_ping_post_links( $post_links, $pung, $post_id = null ) {
|
104 |
-
|
105 |
-
$_link = get_post_meta( $post_id, '_format_link_url', true );
|
106 |
-
if ( ! empty( $_link ) && ! in_array( $_link, $pung ) && ! in_array( $_link, $post_links ) )
|
107 |
-
$post_links[] = $_link;
|
108 |
-
|
109 |
-
$_quote = get_post_meta( $post_id, '_format_quote_source_url', true );
|
110 |
-
if ( ! empty( $_quote ) && ! in_array( $_quote, $pung ) && ! in_array( $_quote, $post_links ) )
|
111 |
-
$post_links[] = $_quote;
|
112 |
-
|
113 |
-
}
|
114 |
-
|
115 |
-
}
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Instantiate The Class
|
121 |
-
*
|
122 |
-
* @since 1.0
|
123 |
-
*/
|
124 |
-
if ( function_exists( 'ot_register_meta_box' ) ) {
|
125 |
-
|
126 |
-
new OT_Post_Formats();
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
/* End of file ot-post-formats-api.php */
|
131 |
-
/* Location: ./includes/ot-post-formats-api.php */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/ot-settings-api.php
DELETED
@@ -1,1052 +0,0 @@
|
|
1 |
-
<?php if ( ! defined( 'OT_VERSION') ) exit( 'No direct script access allowed' );
|
2 |
-
/**
|
3 |
-
* OptionTree Settings API
|
4 |
-
*
|
5 |
-
* This class loads all the methods and helpers specific to a Settings page.
|
6 |
-
*
|
7 |
-
* @package OptionTree
|
8 |
-
* @author Derek Herman <derek@valendesigns.com>
|
9 |
-
* @copyright Copyright (c) 2013, Derek Herman
|
10 |
-
*/
|
11 |
-
if ( ! class_exists( 'OT_Settings' ) ) {
|
12 |
-
|
13 |
-
class OT_Settings {
|
14 |
-
|
15 |
-
/* the options array */
|
16 |
-
private $options;
|
17 |
-
|
18 |
-
/* hooks for targeting admin pages */
|
19 |
-
private $page_hook;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Constructor
|
23 |
-
*
|
24 |
-
* @param array An array of options
|
25 |
-
* @return void
|
26 |
-
*
|
27 |
-
* @access public
|
28 |
-
* @since 2.0
|
29 |
-
*/
|
30 |
-
public function __construct( $args ) {
|
31 |
-
|
32 |
-
$this->options = $args;
|
33 |
-
|
34 |
-
/* return early if not viewing an admin page or no options */
|
35 |
-
if ( ! is_admin() || ! is_array( $this->options ) )
|
36 |
-
return false;
|
37 |
-
|
38 |
-
/* load everything */
|
39 |
-
$this->hooks();
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Execute the WordPress Hooks
|
45 |
-
*
|
46 |
-
* @return void
|
47 |
-
*
|
48 |
-
* @access public
|
49 |
-
* @since 2.0
|
50 |
-
*/
|
51 |
-
public function hooks() {
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Filter the `admin_menu` action hook priority.
|
55 |
-
*
|
56 |
-
* @since 2.5.0
|
57 |
-
*
|
58 |
-
* @param int $priority The priority. Default '10'.
|
59 |
-
*/
|
60 |
-
$priority = apply_filters( 'ot_admin_menu_priority', 10 );
|
61 |
-
|
62 |
-
/* add pages & menu items */
|
63 |
-
add_action( 'admin_menu', array( $this, 'add_page' ), $priority );
|
64 |
-
|
65 |
-
/* register sections */
|
66 |
-
add_action( 'admin_init', array( $this, 'add_sections' ) );
|
67 |
-
|
68 |
-
/* register settings */
|
69 |
-
add_action( 'admin_init', array( $this, 'add_settings' ) );
|
70 |
-
|
71 |
-
/* reset options */
|
72 |
-
add_action( 'admin_init', array( $this, 'reset_options' ), 10 );
|
73 |
-
|
74 |
-
/* initialize settings */
|
75 |
-
add_action( 'admin_init', array( $this, 'initialize_settings' ), 11 );
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Loads each admin page
|
81 |
-
*
|
82 |
-
* @return void
|
83 |
-
*
|
84 |
-
* @access public
|
85 |
-
* @since 2.0
|
86 |
-
*/
|
87 |
-
public function add_page() {
|
88 |
-
|
89 |
-
/* loop through options */
|
90 |
-
foreach( (array) $this->options as $option ) {
|
91 |
-
|
92 |
-
/* loop through pages */
|
93 |
-
foreach( (array) $this->get_pages( $option ) as $page ) {
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Theme Check... stop nagging me about this kind of stuff.
|
97 |
-
* The damn admin pages are required for OT to function, duh!
|
98 |
-
*/
|
99 |
-
$theme_check_bs = 'add_menu_' . 'page';
|
100 |
-
$theme_check_bs2 = 'add_submenu_' . 'page';
|
101 |
-
|
102 |
-
/* load page in WP top level menu */
|
103 |
-
if ( ! isset( $page['parent_slug'] ) || empty( $page['parent_slug'] ) ) {
|
104 |
-
$page_hook = $theme_check_bs(
|
105 |
-
$page['page_title'],
|
106 |
-
$page['menu_title'],
|
107 |
-
$page['capability'],
|
108 |
-
$page['menu_slug'],
|
109 |
-
array( $this, 'display_page' ),
|
110 |
-
$page['icon_url'],
|
111 |
-
$page['position']
|
112 |
-
);
|
113 |
-
/* load page in WP sub menu */
|
114 |
-
} else {
|
115 |
-
$page_hook = $theme_check_bs2(
|
116 |
-
$page['parent_slug'],
|
117 |
-
$page['page_title'],
|
118 |
-
$page['menu_title'],
|
119 |
-
$page['capability'],
|
120 |
-
$page['menu_slug'],
|
121 |
-
array( $this, 'display_page' )
|
122 |
-
);
|
123 |
-
}
|
124 |
-
|
125 |
-
/* only load if not a hidden page */
|
126 |
-
if ( ! isset( $page['hidden_page'] ) ) {
|
127 |
-
|
128 |
-
/* associate $page_hook with page id */
|
129 |
-
$this->page_hook[$page['id']] = $page_hook;
|
130 |
-
|
131 |
-
/* add scripts */
|
132 |
-
add_action( 'admin_print_scripts-' . $page_hook, array( $this, 'scripts' ) );
|
133 |
-
|
134 |
-
/* add styles */
|
135 |
-
add_action( 'admin_print_styles-' . $page_hook, array( $this, 'styles' ) );
|
136 |
-
|
137 |
-
/* add contextual help */
|
138 |
-
add_action( 'load-' . $page_hook, array( $this, 'help' ) );
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
return false;
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Loads the scripts
|
151 |
-
*
|
152 |
-
* @return void
|
153 |
-
*
|
154 |
-
* @access public
|
155 |
-
* @since 2.0
|
156 |
-
*/
|
157 |
-
public function scripts() {
|
158 |
-
ot_admin_scripts();
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Loads the styles
|
163 |
-
*
|
164 |
-
* @return void
|
165 |
-
*
|
166 |
-
* @access public
|
167 |
-
* @since 2.0
|
168 |
-
*/
|
169 |
-
public function styles() {
|
170 |
-
ot_admin_styles();
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* Loads the contextual help for each page
|
175 |
-
*
|
176 |
-
* @return void
|
177 |
-
*
|
178 |
-
* @access public
|
179 |
-
* @since 2.0
|
180 |
-
*/
|
181 |
-
public function help() {
|
182 |
-
$screen = get_current_screen();
|
183 |
-
|
184 |
-
/* loop through options */
|
185 |
-
foreach( (array) $this->options as $option ) {
|
186 |
-
|
187 |
-
/* loop through pages */
|
188 |
-
foreach( (array) $this->get_pages( $option ) as $page ) {
|
189 |
-
|
190 |
-
/* verify page */
|
191 |
-
if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) {
|
192 |
-
|
193 |
-
/* set up the help tabs */
|
194 |
-
if ( ! empty( $page['contextual_help']['content'] ) ) {
|
195 |
-
foreach( $page['contextual_help']['content'] as $contextual_help ) {
|
196 |
-
$screen->add_help_tab(
|
197 |
-
array(
|
198 |
-
'id' => esc_attr( $contextual_help['id'] ),
|
199 |
-
'title' => esc_attr( $contextual_help['title'] ),
|
200 |
-
'content' => htmlspecialchars_decode( $contextual_help['content'] ),
|
201 |
-
)
|
202 |
-
);
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
/* set up the help sidebar */
|
207 |
-
if ( ! empty( $page['contextual_help']['sidebar'] ) ) {
|
208 |
-
$screen->set_help_sidebar( htmlspecialchars_decode( $page['contextual_help']['sidebar'] ) );
|
209 |
-
}
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
}
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
return false;
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Loads the content for each page
|
222 |
-
*
|
223 |
-
* @return string
|
224 |
-
*
|
225 |
-
* @access public
|
226 |
-
* @since 2.0
|
227 |
-
*/
|
228 |
-
public function display_page() {
|
229 |
-
$screen = get_current_screen();
|
230 |
-
|
231 |
-
/* loop through settings */
|
232 |
-
foreach( (array) $this->options as $option ) {
|
233 |
-
|
234 |
-
/* loop through pages */
|
235 |
-
foreach( (array) $this->get_pages( $option ) as $page ) {
|
236 |
-
|
237 |
-
/* verify page */
|
238 |
-
if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) {
|
239 |
-
|
240 |
-
$show_buttons = isset( $page['show_buttons'] ) && $page['show_buttons'] == false ? false : true;
|
241 |
-
|
242 |
-
/* update active layout content */
|
243 |
-
if ( isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ) {
|
244 |
-
|
245 |
-
$layouts = get_option( ot_layouts_id() );
|
246 |
-
|
247 |
-
/* has active layout */
|
248 |
-
if ( isset( $layouts['active_layout'] ) ) {
|
249 |
-
$option_tree = get_option( $option['id'] );
|
250 |
-
$layouts[$layouts['active_layout']] = ot_encode( serialize( $option_tree ) );
|
251 |
-
update_option( ot_layouts_id(), $layouts );
|
252 |
-
}
|
253 |
-
|
254 |
-
}
|
255 |
-
|
256 |
-
echo '<div class="wrap settings-wrap" id ="page-' . $page['id'] . '">';
|
257 |
-
|
258 |
-
echo '<h2>' . $page['page_title'] . '</h2>';
|
259 |
-
|
260 |
-
echo ot_alert_message( $page );
|
261 |
-
|
262 |
-
settings_errors( 'option-tree' );
|
263 |
-
|
264 |
-
/* Header */
|
265 |
-
echo '<div id="option-tree-header-wrap">';
|
266 |
-
|
267 |
-
echo '<ul id="option-tree-header">';
|
268 |
-
|
269 |
-
echo '<li id="option-tree-logo">' . apply_filters( 'ot_header_logo_link', '<a href="http://wordpress.org/extend/plugins/option-tree/" target="_blank">OptionTree</a>', $page['id'] ) . '</li>';
|
270 |
-
|
271 |
-
echo '<li id="option-tree-version"><span>' . apply_filters( 'ot_header_version_text', 'OptionTree ' . OT_VERSION, $page['id'] ) . '</span></li>';
|
272 |
-
|
273 |
-
// Add additional theme specific links here.
|
274 |
-
do_action( 'ot_header_list', $page['id'] );
|
275 |
-
|
276 |
-
echo '</ul>';
|
277 |
-
|
278 |
-
/* layouts form */
|
279 |
-
if ( $page['id'] == 'ot_theme_options' && OT_SHOW_NEW_LAYOUT == true )
|
280 |
-
ot_theme_options_layouts_form();
|
281 |
-
|
282 |
-
echo '</div>';
|
283 |
-
|
284 |
-
/* remove forms on the custom settings pages */
|
285 |
-
if ( $show_buttons ) {
|
286 |
-
|
287 |
-
echo '<form action="options.php" method="post" id="option-tree-settings-api">';
|
288 |
-
|
289 |
-
settings_fields( $option['id'] );
|
290 |
-
|
291 |
-
} else {
|
292 |
-
|
293 |
-
echo '<div id="option-tree-settings-api">';
|
294 |
-
|
295 |
-
}
|
296 |
-
|
297 |
-
/* Sub Header */
|
298 |
-
echo '<div id="option-tree-sub-header">';
|
299 |
-
|
300 |
-
if ( $show_buttons )
|
301 |
-
echo '<button class="option-tree-ui-button button button-primary right">' . $page['button_text'] . '</button>';
|
302 |
-
|
303 |
-
echo '</div>';
|
304 |
-
|
305 |
-
/* Navigation */
|
306 |
-
echo '<div class="ui-tabs">';
|
307 |
-
|
308 |
-
/* check for sections */
|
309 |
-
if ( isset( $page['sections'] ) && count( $page['sections'] ) > 0 ) {
|
310 |
-
|
311 |
-
echo '<ul class="ui-tabs-nav">';
|
312 |
-
|
313 |
-
/* loop through page sections */
|
314 |
-
foreach( (array) $page['sections'] as $section ) {
|
315 |
-
echo '<li id="tab_' . $section['id'] . '"><a href="#section_' . $section['id'] . '">' . $section['title'] . '</a></li>';
|
316 |
-
}
|
317 |
-
|
318 |
-
echo '</ul>';
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
/* sections */
|
323 |
-
echo '<div id="poststuff" class="metabox-holder">';
|
324 |
-
|
325 |
-
echo '<div id="post-body">';
|
326 |
-
|
327 |
-
echo '<div id="post-body-content">';
|
328 |
-
|
329 |
-
$this->do_settings_sections( $_GET['page'] );
|
330 |
-
|
331 |
-
echo '</div>';
|
332 |
-
|
333 |
-
echo '</div>';
|
334 |
-
|
335 |
-
echo '</div>';
|
336 |
-
|
337 |
-
echo '<div class="clear"></div>';
|
338 |
-
|
339 |
-
echo '</div>';
|
340 |
-
|
341 |
-
/* buttons */
|
342 |
-
if ( $show_buttons ) {
|
343 |
-
|
344 |
-
echo '<div class="option-tree-ui-buttons">';
|
345 |
-
|
346 |
-
echo '<button class="option-tree-ui-button button button-primary right">' . $page['button_text'] . '</button>';
|
347 |
-
|
348 |
-
echo '</div>';
|
349 |
-
|
350 |
-
}
|
351 |
-
|
352 |
-
echo $show_buttons ? '</form>' : '</div>';
|
353 |
-
|
354 |
-
/* reset button */
|
355 |
-
if ( $show_buttons ) {
|
356 |
-
|
357 |
-
echo '<form method="post" action="' . str_replace( '&settings-updated=true', '', $_SERVER["REQUEST_URI"] ) . '">';
|
358 |
-
|
359 |
-
/* form nonce */
|
360 |
-
wp_nonce_field( 'option_tree_reset_form', 'option_tree_reset_nonce' );
|
361 |
-
|
362 |
-
echo '<input type="hidden" name="action" value="reset" />';
|
363 |
-
|
364 |
-
echo '<button type="submit" class="option-tree-ui-button button button-secondary left reset-settings" title="' . __( 'Reset Options', 'option-tree' ) . '">' . __( 'Reset Options', 'option-tree' ) . '</button>';
|
365 |
-
|
366 |
-
echo '</form>';
|
367 |
-
|
368 |
-
}
|
369 |
-
|
370 |
-
echo '</div>';
|
371 |
-
|
372 |
-
}
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
}
|
377 |
-
|
378 |
-
return false;
|
379 |
-
}
|
380 |
-
|
381 |
-
/**
|
382 |
-
* Adds sections to the page
|
383 |
-
*
|
384 |
-
* @return void
|
385 |
-
*
|
386 |
-
* @access public
|
387 |
-
* @since 2.0
|
388 |
-
*/
|
389 |
-
public function add_sections() {
|
390 |
-
|
391 |
-
/* loop through options */
|
392 |
-
foreach( (array) $this->options as $option ) {
|
393 |
-
|
394 |
-
/* loop through pages */
|
395 |
-
foreach( (array) $this->get_pages( $option ) as $page ) {
|
396 |
-
|
397 |
-
/* loop through page sections */
|
398 |
-
foreach( (array) $this->get_sections( $page ) as $section ) {
|
399 |
-
|
400 |
-
/* add each section */
|
401 |
-
add_settings_section(
|
402 |
-
$section['id'],
|
403 |
-
$section['title'],
|
404 |
-
array( $this, 'display_section' ),
|
405 |
-
$page['menu_slug']
|
406 |
-
);
|
407 |
-
|
408 |
-
}
|
409 |
-
|
410 |
-
}
|
411 |
-
|
412 |
-
}
|
413 |
-
|
414 |
-
return false;
|
415 |
-
}
|
416 |
-
|
417 |
-
/**
|
418 |
-
* Callback for add_settings_section()
|
419 |
-
*
|
420 |
-
* @return string
|
421 |
-
*
|
422 |
-
* @access public
|
423 |
-
* @since 2.0
|
424 |
-
*/
|
425 |
-
public function display_section() {
|
426 |
-
/* currently pointless */
|
427 |
-
}
|
428 |
-
|
429 |
-
/**
|
430 |
-
* Add settings the the page
|
431 |
-
*
|
432 |
-
* @return void
|
433 |
-
*
|
434 |
-
* @access public
|
435 |
-
* @since 2.0
|
436 |
-
*/
|
437 |
-
public function add_settings() {
|
438 |
-
|
439 |
-
/* loop through options */
|
440 |
-
foreach( (array) $this->options as $option ) {
|
441 |
-
|
442 |
-
register_setting( $option['id'], $option['id'], array ( $this, 'sanitize_callback' ) );
|
443 |
-
|
444 |
-
/* loop through pages */
|
445 |
-
foreach( (array) $this->get_pages( $option ) as $page ) {
|
446 |
-
|
447 |
-
/* loop through page settings */
|
448 |
-
foreach( (array) $this->get_the_settings( $page ) as $setting ) {
|
449 |
-
|
450 |
-
/* skip if no setting ID */
|
451 |
-
if ( ! isset( $setting['id'] ) )
|
452 |
-
continue;
|
453 |
-
|
454 |
-
/* add get_option param to the array */
|
455 |
-
$setting['get_option'] = $option['id'];
|
456 |
-
|
457 |
-
/* add each setting */
|
458 |
-
add_settings_field(
|
459 |
-
$setting['id'],
|
460 |
-
$setting['label'],
|
461 |
-
array( $this, 'display_setting' ),
|
462 |
-
$page['menu_slug'],
|
463 |
-
$setting['section'],
|
464 |
-
$setting
|
465 |
-
);
|
466 |
-
|
467 |
-
}
|
468 |
-
|
469 |
-
}
|
470 |
-
|
471 |
-
}
|
472 |
-
|
473 |
-
return false;
|
474 |
-
}
|
475 |
-
|
476 |
-
/**
|
477 |
-
* Callback for add_settings_field() to build each setting by type
|
478 |
-
*
|
479 |
-
* @param array Setting object array
|
480 |
-
* @return string
|
481 |
-
*
|
482 |
-
* @access public
|
483 |
-
* @since 2.0
|
484 |
-
*/
|
485 |
-
public function display_setting( $args = array() ) {
|
486 |
-
|
487 |
-
extract( $args );
|
488 |
-
|
489 |
-
/* get current saved data */
|
490 |
-
$options = get_option( $get_option, false );
|
491 |
-
|
492 |
-
// Set field value
|
493 |
-
$field_value = isset( $options[$id] ) ? $options[$id] : '';
|
494 |
-
|
495 |
-
/* set standard value */
|
496 |
-
if ( isset( $std ) ) {
|
497 |
-
$field_value = ot_filter_std_value( $field_value, $std );
|
498 |
-
}
|
499 |
-
|
500 |
-
// Allow the descriptions to be filtered before being displayed
|
501 |
-
$desc = apply_filters( 'ot_filter_description', ( isset( $desc ) ? $desc : '' ), $id );
|
502 |
-
|
503 |
-
/* build the arguments array */
|
504 |
-
$_args = array(
|
505 |
-
'type' => $type,
|
506 |
-
'field_id' => $id,
|
507 |
-
'field_name' => $get_option . '[' . $id . ']',
|
508 |
-
'field_value' => $field_value,
|
509 |
-
'field_desc' => $desc,
|
510 |
-
'field_std' => isset( $std ) ? $std : '',
|
511 |
-
'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15,
|
512 |
-
'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post',
|
513 |
-
'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category',
|
514 |
-
'field_min_max_step'=> isset( $min_max_step ) && ! empty( $min_max_step ) ? $min_max_step : '0,100,1',
|
515 |
-
'field_condition' => isset( $condition ) && ! empty( $condition ) ? $condition : '',
|
516 |
-
'field_operator' => isset( $operator ) && ! empty( $operator ) ? $operator : 'and',
|
517 |
-
'field_class' => isset( $class ) ? $class : '',
|
518 |
-
'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(),
|
519 |
-
'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(),
|
520 |
-
'post_id' => ot_get_media_post_ID(),
|
521 |
-
'get_option' => $get_option,
|
522 |
-
);
|
523 |
-
|
524 |
-
// Limit DB queries for Google Fonts.
|
525 |
-
if ( $type == 'google-fonts' ) {
|
526 |
-
ot_fetch_google_fonts();
|
527 |
-
ot_set_google_fonts( $id, $field_value );
|
528 |
-
}
|
529 |
-
|
530 |
-
/* get the option HTML */
|
531 |
-
echo ot_display_by_type( $_args );
|
532 |
-
}
|
533 |
-
|
534 |
-
/**
|
535 |
-
* Sets the option standards if nothing yet exists.
|
536 |
-
*
|
537 |
-
* @return void
|
538 |
-
*
|
539 |
-
* @access public
|
540 |
-
* @since 2.0
|
541 |
-
*/
|
542 |
-
public function initialize_settings() {
|
543 |
-
|
544 |
-
/* loop through options */
|
545 |
-
foreach( (array) $this->options as $option ) {
|
546 |
-
|
547 |
-
/* skip if option is already set */
|
548 |
-
if ( isset( $option['id'] ) && get_option( $option['id'], false ) ) {
|
549 |
-
return false;
|
550 |
-
}
|
551 |
-
|
552 |
-
$defaults = array();
|
553 |
-
|
554 |
-
/* loop through pages */
|
555 |
-
foreach( (array) $this->get_pages( $option ) as $page ) {
|
556 |
-
|
557 |
-
/* loop through page settings */
|
558 |
-
foreach( (array) $this->get_the_settings( $page ) as $setting ) {
|
559 |
-
|
560 |
-
if ( isset( $setting['std'] ) ) {
|
561 |
-
|
562 |
-
$defaults[$setting['id']] = ot_validate_setting( $setting['std'], $setting['type'], $setting['id'] );
|
563 |
-
|
564 |
-
}
|
565 |
-
|
566 |
-
}
|
567 |
-
|
568 |
-
}
|
569 |
-
|
570 |
-
update_option( $option['id'], $defaults );
|
571 |
-
|
572 |
-
}
|
573 |
-
|
574 |
-
return false;
|
575 |
-
}
|
576 |
-
|
577 |
-
/**
|
578 |
-
* Sanitize callback for register_setting()
|
579 |
-
*
|
580 |
-
* @return string
|
581 |
-
*
|
582 |
-
* @access public
|
583 |
-
* @since 2.0
|
584 |
-
*/
|
585 |
-
public function sanitize_callback( $input ) {
|
586 |
-
|
587 |
-
/* loop through options */
|
588 |
-
foreach( (array) $this->options as $option ) {
|
589 |
-
|
590 |
-
/* loop through pages */
|
591 |
-
foreach( (array) $this->get_pages( $option ) as $page ) {
|
592 |
-
|
593 |
-
/* loop through page settings */
|
594 |
-
foreach( (array) $this->get_the_settings( $page ) as $setting ) {
|
595 |
-
|
596 |
-
/* verify setting has a type & value */
|
597 |
-
if ( isset( $setting['type'] ) && isset( $input[$setting['id']] ) ) {
|
598 |
-
|
599 |
-
/* get the defaults */
|
600 |
-
$current_settings = get_option( ot_settings_id() );
|
601 |
-
$current_options = get_option( $option['id'] );
|
602 |
-
|
603 |
-
/* validate setting */
|
604 |
-
if ( is_array( $input[$setting['id']] ) && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) {
|
605 |
-
|
606 |
-
/* required title setting */
|
607 |
-
$required_setting = array(
|
608 |
-
array(
|
609 |
-
'id' => 'title',
|
610 |
-
'label' => __( 'Title', 'option-tree' ),
|
611 |
-
'desc' => '',
|
612 |
-
'std' => '',
|
613 |
-
'type' => 'text',
|
614 |
-
'rows' => '',
|
615 |
-
'class' => 'option-tree-setting-title',
|
616 |
-
'post_type' => '',
|
617 |
-
'choices' => array()
|
618 |
-
)
|
619 |
-
);
|
620 |
-
|
621 |
-
/* get the settings array */
|
622 |
-
$settings = isset( $_POST[$setting['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$setting['id'] . '_settings_array'] ) ) : array();
|
623 |
-
|
624 |
-
/* settings are empty for some odd ass reason get the defaults */
|
625 |
-
if ( empty( $settings ) ) {
|
626 |
-
$settings = 'slider' == $setting['type'] ?
|
627 |
-
ot_slider_settings( $setting['id'] ) :
|
628 |
-
ot_list_item_settings( $setting['id'] );
|
629 |
-
}
|
630 |
-
|
631 |
-
/* merge the two settings array */
|
632 |
-
$settings = array_merge( $required_setting, $settings );
|
633 |
-
|
634 |
-
/* create an empty WPML id array */
|
635 |
-
$wpml_ids = array();
|
636 |
-
|
637 |
-
foreach( $input[$setting['id']] as $k => $setting_array ) {
|
638 |
-
|
639 |
-
foreach( $settings as $sub_setting ) {
|
640 |
-
|
641 |
-
/* setup the WPML ID */
|
642 |
-
$wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
|
643 |
-
|
644 |
-
/* add id to array */
|
645 |
-
$wpml_ids[] = $wpml_id;
|
646 |
-
|
647 |
-
/* verify sub setting has a type & value */
|
648 |
-
if ( isset( $sub_setting['type'] ) && isset( $input[$setting['id']][$k][$sub_setting['id']] ) ) {
|
649 |
-
|
650 |
-
/* validate setting */
|
651 |
-
$input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting( $input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id );
|
652 |
-
|
653 |
-
}
|
654 |
-
|
655 |
-
}
|
656 |
-
|
657 |
-
}
|
658 |
-
|
659 |
-
} else if ( is_array( $input[$setting['id']] ) && $setting['type'] == 'social-links' ) {
|
660 |
-
|
661 |
-
/* get the settings array */
|
662 |
-
$settings = isset( $_POST[$setting['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$setting['id'] . '_settings_array'] ) ) : array();
|
663 |
-
|
664 |
-
/* settings are empty get the defaults */
|
665 |
-
if ( empty( $settings ) ) {
|
666 |
-
$settings = ot_social_links_settings( $setting['id'] );
|
667 |
-
}
|
668 |
-
|
669 |
-
/* create an empty WPML id array */
|
670 |
-
$wpml_ids = array();
|
671 |
-
|
672 |
-
foreach( $input[$setting['id']] as $k => $setting_array ) {
|
673 |
-
|
674 |
-
foreach( $settings as $sub_setting ) {
|
675 |
-
|
676 |
-
/* setup the WPML ID */
|
677 |
-
$wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
|
678 |
-
|
679 |
-
/* add id to array */
|
680 |
-
$wpml_ids[] = $wpml_id;
|
681 |
-
|
682 |
-
/* verify sub setting has a type & value */
|
683 |
-
if ( isset( $sub_setting['type'] ) && isset( $input[$setting['id']][$k][$sub_setting['id']] ) ) {
|
684 |
-
|
685 |
-
/* validate setting */
|
686 |
-
$input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting( $input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id );
|
687 |
-
|
688 |
-
}
|
689 |
-
|
690 |
-
}
|
691 |
-
|
692 |
-
}
|
693 |
-
|
694 |
-
} else {
|
695 |
-
|
696 |
-
$input[$setting['id']] = ot_validate_setting( $input[$setting['id']], $setting['type'], $setting['id'], $setting['id'] );
|
697 |
-
|
698 |
-
}
|
699 |
-
|
700 |
-
}
|
701 |
-
|
702 |
-
/* unregister WPML strings that were deleted from lists and sliders */
|
703 |
-
if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) {
|
704 |
-
|
705 |
-
if ( ! isset( $wpml_ids ) )
|
706 |
-
$wpml_ids = array();
|
707 |
-
|
708 |
-
foreach( $current_settings['settings'] as $check_setting ) {
|
709 |
-
|
710 |
-
if ( $setting['id'] == $check_setting['id'] && ! empty( $current_options[$setting['id']] ) ) {
|
711 |
-
|
712 |
-
foreach( $current_options[$setting['id']] as $key => $value ) {
|
713 |
-
|
714 |
-
foreach( $value as $ckey => $cvalue ) {
|
715 |
-
|
716 |
-
$id = $setting['id'] . '_' . $ckey . '_' . $key;
|
717 |
-
|
718 |
-
if ( ! in_array( $id, $wpml_ids ) ) {
|
719 |
-
|
720 |
-
ot_wpml_unregister_string( $id );
|
721 |
-
|
722 |
-
}
|
723 |
-
|
724 |
-
}
|
725 |
-
|
726 |
-
}
|
727 |
-
|
728 |
-
}
|
729 |
-
|
730 |
-
}
|
731 |
-
|
732 |
-
}
|
733 |
-
|
734 |
-
/* unregister WPML strings that were deleted from social links */
|
735 |
-
if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && $setting['type'] == 'social-links' ) {
|
736 |
-
|
737 |
-
if ( ! isset( $wpml_ids ) )
|
738 |
-
$wpml_ids = array();
|
739 |
-
|
740 |
-
foreach( $current_settings['settings'] as $check_setting ) {
|
741 |
-
|
742 |
-
if ( $setting['id'] == $check_setting['id'] && ! empty( $current_options[$setting['id']] ) ) {
|
743 |
-
|
744 |
-
foreach( $current_options[$setting['id']] as $key => $value ) {
|
745 |
-
|
746 |
-
foreach( $value as $ckey => $cvalue ) {
|
747 |
-
|
748 |
-
$id = $setting['id'] . '_' . $ckey . '_' . $key;
|
749 |
-
|
750 |
-
if ( ! in_array( $id, $wpml_ids ) ) {
|
751 |
-
|
752 |
-
ot_wpml_unregister_string( $id );
|
753 |
-
|
754 |
-
}
|
755 |
-
|
756 |
-
}
|
757 |
-
|
758 |
-
}
|
759 |
-
|
760 |
-
}
|
761 |
-
|
762 |
-
}
|
763 |
-
|
764 |
-
}
|
765 |
-
|
766 |
-
}
|
767 |
-
|
768 |
-
}
|
769 |
-
|
770 |
-
}
|
771 |
-
|
772 |
-
return $input;
|
773 |
-
|
774 |
-
}
|
775 |
-
|
776 |
-
/**
|
777 |
-
* Helper function to get the pages array for an option
|
778 |
-
*
|
779 |
-
* @param array Option array
|
780 |
-
* @return mixed
|
781 |
-
*
|
782 |
-
* @access public
|
783 |
-
* @since 2.0
|
784 |
-
*/
|
785 |
-
public function get_pages( $option = array() ) {
|
786 |
-
|
787 |
-
if ( empty( $option ) )
|
788 |
-
return false;
|
789 |
-
|
790 |
-
/* check for pages */
|
791 |
-
if ( isset( $option['pages'] ) && ! empty( $option['pages'] ) ) {
|
792 |
-
|
793 |
-
/* return pages array */
|
794 |
-
return $option['pages'];
|
795 |
-
|
796 |
-
}
|
797 |
-
|
798 |
-
return false;
|
799 |
-
}
|
800 |
-
|
801 |
-
/**
|
802 |
-
* Helper function to get the sections array for a page
|
803 |
-
*
|
804 |
-
* @param array Page array
|
805 |
-
* @return mixed
|
806 |
-
*
|
807 |
-
* @access public
|
808 |
-
* @since 2.0
|
809 |
-
*/
|
810 |
-
public function get_sections( $page = array() ) {
|
811 |
-
|
812 |
-
if ( empty( $page ) )
|
813 |
-
return false;
|
814 |
-
|
815 |
-
/* check for sections */
|
816 |
-
if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) {
|
817 |
-
|
818 |
-
/* return sections array */
|
819 |
-
return $page['sections'];
|
820 |
-
|
821 |
-
}
|
822 |
-
|
823 |
-
return false;
|
824 |
-
}
|
825 |
-
|
826 |
-
/**
|
827 |
-
* Helper function to get the settings array for a page
|
828 |
-
*
|
829 |
-
* @param array Page array
|
830 |
-
* @return mixed
|
831 |
-
*
|
832 |
-
* @access public
|
833 |
-
* @since 2.0
|
834 |
-
*/
|
835 |
-
public function get_the_settings( $page = array() ) {
|
836 |
-
|
837 |
-
if ( empty( $page ) )
|
838 |
-
return false;
|
839 |
-
|
840 |
-
/* check for settings */
|
841 |
-
if ( isset( $page['settings'] ) && ! empty( $page['settings'] ) ) {
|
842 |
-
|
843 |
-
/* return settings array */
|
844 |
-
return $page['settings'];
|
845 |
-
|
846 |
-
}
|
847 |
-
|
848 |
-
return false;
|
849 |
-
}
|
850 |
-
|
851 |
-
/**
|
852 |
-
* Prints out all settings sections added to a particular settings page
|
853 |
-
*
|
854 |
-
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
|
855 |
-
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
|
856 |
-
*
|
857 |
-
* @param string The slug name of the page whos settings sections you want to output
|
858 |
-
* @return string
|
859 |
-
*
|
860 |
-
* @access public
|
861 |
-
* @since 2.0
|
862 |
-
*/
|
863 |
-
public function do_settings_sections( $page ) {
|
864 |
-
global $wp_settings_sections, $wp_settings_fields;
|
865 |
-
|
866 |
-
if ( ! isset( $wp_settings_sections ) || ! isset( $wp_settings_sections[$page] ) ) {
|
867 |
-
return false;
|
868 |
-
}
|
869 |
-
|
870 |
-
foreach ( (array) $wp_settings_sections[$page] as $section ) {
|
871 |
-
|
872 |
-
if ( ! isset( $section['id'] ) )
|
873 |
-
continue;
|
874 |
-
|
875 |
-
$section_id = $section['id'];
|
876 |
-
|
877 |
-
echo '<div id="section_' . $section_id . '" class="postbox ui-tabs-panel">';
|
878 |
-
|
879 |
-
call_user_func( $section['callback'], $section );
|
880 |
-
|
881 |
-
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[$page] ) || ! isset( $wp_settings_fields[$page][$section_id] ) )
|
882 |
-
continue;
|
883 |
-
|
884 |
-
echo '<div class="inside">';
|
885 |
-
|
886 |
-
/**
|
887 |
-
* Hook to insert arbitrary markup before the `do_settings_fields` method.
|
888 |
-
*
|
889 |
-
* @since 2.6.0
|
890 |
-
*
|
891 |
-
* @param string $page The page slug.
|
892 |
-
* @param string $section_id The section ID.
|
893 |
-
*/
|
894 |
-
do_action( 'ot_do_settings_fields_before', $page, $section_id );
|
895 |
-
|
896 |
-
$this->do_settings_fields( $page, $section_id );
|
897 |
-
|
898 |
-
/**
|
899 |
-
* Hook to i
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|