AMP for WP – Accelerated Mobile Pages - Version 0.9.58

Version Description

(9th August 2017) = * View more details on https://ampforwp.com/new/ * Genesis SEO for AMP support added * AMP 0.4.2 Vendor Bundled for making it crash proof * Archive desc only on 1st page #1029 * Ads are not working after 0.9.6 #1030 * Fixed the Post 0.9.57 Update Bugs #1025 * All Images are aligned on left side in design 3 #1031 * Custom frontpage title issue in Design 3 fixed

Download this release

Release Info

Developer mohammed_kaludi
Plugin Icon 128x128 AMP for WP – Accelerated Mobile Pages
Version 0.9.58
Comparing to
See all releases

Code changes from version 0.9.57.3 to 0.9.58

Files changed (78) hide show
  1. LICENSE +340 -21
  2. accelerated-moblie-pages.php +102 -8
  3. classes/class-ampforwp-youtube-embed.php +2 -3
  4. feeds/instant-article-feed.php +2 -3
  5. includes/includes.php +0 -1
  6. includes/modules/ampforwp-blurb.php +1 -4
  7. includes/modules/ampforwp-button.php +1 -3
  8. includes/newsletter.php +2 -3
  9. includes/options/admin-config.php +1 -3
  10. includes/options/redux-core/templates/panel/header_stickybar.tpl.php +1 -13
  11. includes/redirect.php +1 -2
  12. includes/vendor/amp/LICENSE +340 -0
  13. includes/vendor/amp/amp.php +117 -0
  14. includes/vendor/amp/assets/images/placeholder-icon.png +0 -0
  15. includes/vendor/amp/assets/js/amp-customizer-design-preview.js +40 -0
  16. includes/vendor/amp/assets/js/amp-customizer-preview.js +15 -0
  17. includes/vendor/amp/back-compat/back-compat.php +12 -0
  18. includes/vendor/amp/back-compat/templates-v0-3/header-bar.php +13 -0
  19. includes/vendor/amp/back-compat/templates-v0-3/meta-author.php +9 -0
  20. includes/vendor/amp/back-compat/templates-v0-3/meta-taxonomy.php +15 -0
  21. includes/vendor/amp/back-compat/templates-v0-3/meta-time.php +12 -0
  22. includes/vendor/amp/back-compat/templates-v0-3/single.php +24 -0
  23. includes/vendor/amp/back-compat/templates-v0-3/style.php +242 -0
  24. includes/vendor/amp/includes/admin/class-amp-customizer.php +170 -0
  25. includes/vendor/amp/includes/admin/functions.php +71 -0
  26. includes/vendor/amp/includes/amp-frontend-actions.php +13 -0
  27. includes/vendor/amp/includes/amp-helper-functions.php +47 -0
  28. includes/vendor/amp/includes/amp-post-template-actions.php +98 -0
  29. includes/vendor/amp/includes/amp-post-template-functions.php +15 -0
  30. includes/vendor/amp/includes/class-amp-content.php +123 -0
  31. includes/vendor/amp/includes/class-amp-post-template.php +413 -0
  32. includes/vendor/amp/includes/embeds/class-amp-base-embed-handler.php +26 -0
  33. includes/vendor/amp/includes/embeds/class-amp-facebook-embed.php +55 -0
  34. includes/vendor/amp/includes/embeds/class-amp-gallery-embed.php +139 -0
  35. includes/vendor/amp/includes/embeds/class-amp-instagram-embed.php +90 -0
  36. includes/vendor/amp/includes/embeds/class-amp-twitter-embed.php +79 -0
  37. includes/vendor/amp/includes/embeds/class-amp-vine-embed.php +56 -0
  38. includes/vendor/amp/includes/embeds/class-amp-youtube-embed.php +132 -0
  39. includes/vendor/amp/includes/lib/class-fastimage.php +253 -0
  40. includes/vendor/amp/includes/sanitizers/class-amp-audio-sanitizer.php +93 -0
  41. includes/vendor/amp/includes/sanitizers/class-amp-base-sanitizer.php +124 -0
  42. includes/vendor/amp/includes/sanitizers/class-amp-blacklist-sanitizer.php +240 -0
  43. includes/vendor/amp/includes/sanitizers/class-amp-iframe-sanitizer.php +135 -0
  44. includes/vendor/amp/includes/sanitizers/class-amp-img-sanitizer.php +109 -0
  45. includes/vendor/amp/includes/sanitizers/class-amp-style-sanitizer.php +108 -0
  46. includes/vendor/amp/includes/sanitizers/class-amp-video-sanitizer.php +92 -0
  47. includes/vendor/amp/includes/settings/class-amp-customizer-design-settings.php +156 -0
  48. includes/vendor/amp/includes/settings/class-amp-customizer-settings.php +13 -0
  49. includes/vendor/amp/includes/utils/class-amp-dom-utils.php +104 -0
  50. includes/vendor/amp/includes/utils/class-amp-html-utils.php +20 -0
  51. includes/vendor/amp/includes/utils/class-amp-image-dimension-extractor.php +119 -0
  52. includes/vendor/amp/includes/utils/class-amp-string-utils.php +9 -0
  53. includes/vendor/amp/jetpack-helper.php +71 -0
  54. includes/vendor/amp/readme.md +591 -0
  55. includes/vendor/amp/readme.txt +165 -0
  56. includes/vendor/amp/templates/featured-image.php +18 -0
  57. includes/vendor/amp/templates/footer.php +9 -0
  58. includes/vendor/amp/templates/header-bar.php +11 -0
  59. includes/vendor/amp/templates/meta-author.php +10 -0
  60. includes/vendor/amp/templates/meta-comments-link.php +11 -0
  61. includes/vendor/amp/templates/meta-taxonomy.php +19 -0
  62. includes/vendor/amp/templates/meta-time.php +12 -0
  63. includes/vendor/amp/templates/single.php +41 -0
  64. includes/vendor/amp/templates/style.php +379 -0
  65. includes/welcome.php +127 -124
  66. readme.txt +11 -1
  67. templates/custom-amp-content.php +0 -1
  68. templates/custom-sanitizer.php +1 -2
  69. templates/design-manager/design-1/archive.php +8 -6
  70. templates/design-manager/design-1/elements/content.php +15 -16
  71. templates/design-manager/design-2/archive.php +7 -5
  72. templates/design-manager/design-2/elements/content.php +14 -15
  73. templates/design-manager/design-3/archive.php +7 -5
  74. templates/design-manager/design-3/elements/content.php +15 -18
  75. templates/design-manager/design-3/style.php +7 -11
  76. templates/features.php +105 -64
  77. templates/frontpage-elements.php +2 -2
  78. templates/search-functions.php +0 -1
LICENSE CHANGED
@@ -1,21 +1,340 @@
1
- MIT License
2
-
3
- Copyright (c) 2016 Mohammed Kaludi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
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
+ {description}
294
+ Copyright (C) {year} {fullname}
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.
340
+
accelerated-moblie-pages.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
- Version: 0.9.57.3
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
@@ -18,7 +18,7 @@ define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
18
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.php');
19
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
20
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
21
- define('AMPFORWP_VERSION','0.9.57.3');
22
  // any changes to AMP_QUERY_VAR should be refelected here
23
  define('AMPFORWP_AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
24
 
@@ -165,8 +165,18 @@ add_action( 'init', 'ampforwp_add_custom_rewrite_rules' );
165
  register_activation_hook( __FILE__, 'ampforwp_rewrite_activation', 20 );
166
  function ampforwp_rewrite_activation() {
167
 
 
 
 
 
 
 
 
 
 
168
  ampforwp_add_custom_post_support();
169
  ampforwp_add_custom_rewrite_rules();
 
170
  // Flushing rewrite urls ONLY on activation
171
  global $wp_rewrite;
172
  $wp_rewrite->flush_rules();
@@ -180,6 +190,16 @@ register_deactivation_hook( __FILE__, 'ampforwp_rewrite_deactivate', 20 );
180
  function ampforwp_rewrite_deactivate() {
181
  // Flushing rewrite urls ONLY on deactivation
182
  global $wp_rewrite;
 
 
 
 
 
 
 
 
 
 
183
  $wp_rewrite->flush_rules();
184
 
185
  // Remove transient for Welcome page
@@ -220,8 +240,6 @@ function ampforwp_add_module_files() {
220
  }
221
  }
222
 
223
-
224
-
225
  /*
226
  * Load Files only in the backend
227
  * As we don't need plugin activation code to run everytime the site loads
@@ -231,7 +249,8 @@ if ( is_admin() ) {
231
  // Include Welcome page only on Admin pages
232
  require AMPFORWP_PLUGIN_DIR .'/includes/welcome.php';
233
 
234
- add_action('init','ampforwp_plugin_notice');
 
235
  function ampforwp_plugin_notice() {
236
 
237
  if ( ! defined( 'AMP__FILE__' ) ) {
@@ -309,8 +328,9 @@ if ( is_admin() ) {
309
 
310
  // Add Settings Button in Plugin backend
311
  if ( ! function_exists( 'ampforwp_plugin_settings_link' ) ) {
312
-
313
- add_filter( 'plugin_action_links', 'ampforwp_plugin_settings_link', 10, 5 );
 
314
 
315
  function ampforwp_plugin_settings_link( $actions, $plugin_file ) {
316
  static $plugin;
@@ -365,6 +385,7 @@ if ( ! class_exists( 'Ampforwp_Init', false ) ) {
365
  * Gentlemen start your engines
366
  */
367
  function ampforwp_plugin_init() {
 
368
  if ( defined( 'AMP__FILE__' ) && defined('AMPFORWP_PLUGIN_DIR') ) {
369
  new Ampforwp_Init;
370
  }
@@ -376,4 +397,77 @@ add_action('init','ampforwp_plugin_init',9);
376
  * to be used be used in before or after Loop
377
  */
378
  require AMPFORWP_PLUGIN_DIR.'/templates/category-widget.php';
379
- require AMPFORWP_PLUGIN_DIR.'/templates/woo-widget.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: Accelerated Mobile Pages
4
  Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
5
  Description: AMP for WP - Accelerated Mobile Pages for WordPress
6
+ Version: 0.9.58
7
  Author: Ahmed Kaludi, Mohammed Kaludi
8
  Author URI: https://ampforwp.com/
9
  Donate link: https://www.paypal.me/Kaludi/25
18
  define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.php');
19
  define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
20
  define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
21
+ define('AMPFORWP_VERSION','0.9.58');
22
  // any changes to AMP_QUERY_VAR should be refelected here
23
  define('AMPFORWP_AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
24
 
165
  register_activation_hook( __FILE__, 'ampforwp_rewrite_activation', 20 );
166
  function ampforwp_rewrite_activation() {
167
 
168
+ // Run AMP deactivation code while activation
169
+ ampforwp_deactivate_amp_plugin();
170
+
171
+ if ( ! did_action( 'ampforwp_init' ) ) {
172
+ ampforwp_init();
173
+ }
174
+
175
+ flush_rewrite_rules();
176
+
177
  ampforwp_add_custom_post_support();
178
  ampforwp_add_custom_rewrite_rules();
179
+
180
  // Flushing rewrite urls ONLY on activation
181
  global $wp_rewrite;
182
  $wp_rewrite->flush_rules();
190
  function ampforwp_rewrite_deactivate() {
191
  // Flushing rewrite urls ONLY on deactivation
192
  global $wp_rewrite;
193
+
194
+ foreach ( $wp_rewrite->endpoints as $index => $endpoint ) {
195
+ if ( AMP_QUERY_VAR === $endpoint[1] ) {
196
+ unset( $wp_rewrite->endpoints[ $index ] );
197
+ break;
198
+ }
199
+ }
200
+
201
+ flush_rewrite_rules();
202
+
203
  $wp_rewrite->flush_rules();
204
 
205
  // Remove transient for Welcome page
240
  }
241
  }
242
 
 
 
243
  /*
244
  * Load Files only in the backend
245
  * As we don't need plugin activation code to run everytime the site loads
249
  // Include Welcome page only on Admin pages
250
  require AMPFORWP_PLUGIN_DIR .'/includes/welcome.php';
251
 
252
+ // Deactivate Parent Plugin notice
253
+ // add_action('init','ampforwp_plugin_notice');
254
  function ampforwp_plugin_notice() {
255
 
256
  if ( ! defined( 'AMP__FILE__' ) ) {
328
 
329
  // Add Settings Button in Plugin backend
330
  if ( ! function_exists( 'ampforwp_plugin_settings_link' ) ) {
331
+
332
+ // Deactivate Parent Plugin notice
333
+ // add_filter( 'plugin_action_links', 'ampforwp_plugin_settings_link', 10, 5 );
334
 
335
  function ampforwp_plugin_settings_link( $actions, $plugin_file ) {
336
  static $plugin;
385
  * Gentlemen start your engines
386
  */
387
  function ampforwp_plugin_init() {
388
+
389
  if ( defined( 'AMP__FILE__' ) && defined('AMPFORWP_PLUGIN_DIR') ) {
390
  new Ampforwp_Init;
391
  }
397
  * to be used be used in before or after Loop
398
  */
399
  require AMPFORWP_PLUGIN_DIR.'/templates/category-widget.php';
400
+ require AMPFORWP_PLUGIN_DIR.'/templates/woo-widget.php';
401
+
402
+
403
+ /*
404
+ * Including core AMP plugin files and removing any other things if necessary
405
+ */
406
+ function ampforwp_bundle_core_amp_files(){
407
+ // Bundling Default plugin
408
+ require_once AMPFORWP_PLUGIN_DIR .'/includes/vendor/amp/amp.php';
409
+
410
+ define( 'AMP__FILE__', __FILE__ );
411
+ define( 'AMP__DIR__', plugin_dir_path(__FILE__) . 'includes/vendor/amp/' );
412
+ define( 'AMP__VERSION', '0.4.2' );
413
+
414
+ require_once( AMP__DIR__ . '/back-compat/back-compat.php' );
415
+ require_once( AMP__DIR__ . '/includes/amp-helper-functions.php' );
416
+ require_once( AMP__DIR__ . '/includes/admin/functions.php' );
417
+ require_once( AMP__DIR__ . '/includes/settings/class-amp-customizer-settings.php' );
418
+ require_once( AMP__DIR__ . '/includes/settings/class-amp-customizer-design-settings.php' );
419
+ }
420
+ add_action('plugins_loaded','ampforwp_bundle_core_amp_files', 8);
421
+
422
+ function ampforwp_deactivate_amp_plugin() {
423
+
424
+ if ( version_compare( floatval( get_bloginfo( 'version' ) ), '3.5', '>=' ) ) {
425
+
426
+ if ( current_user_can( 'activate_plugins' ) ) {
427
+
428
+ add_action( 'admin_init', 'ampforwp_deactivate_amp' );
429
+
430
+ function ampforwp_deactivate_amp() {
431
+ deactivate_plugins( AMPFORWP_MAIN_PLUGIN_DIR . 'amp/amp.php' );
432
+ }
433
+ }
434
+ }
435
+ }
436
+ add_action( 'plugins_loaded', 'ampforwp_deactivate_amp_plugin' );
437
+
438
+ function ampforwp_modify_amp_activatation_link( $actions, $plugin_file ) {
439
+ $plugin = '';
440
+
441
+ $plugin = 'amp/amp.php';
442
+ if ( $plugin == $plugin_file ) {
443
+ unset($actions['activate']);
444
+ }
445
+ return $actions;
446
+ }
447
+ add_filter( 'plugin_action_links', 'ampforwp_modify_amp_activatation_link', 10, 2 );
448
+
449
+
450
+ if ( ! function_exists('ampforwp_init') ) {
451
+ add_action( 'init', 'ampforwp_init' );
452
+ function ampforwp_init() {
453
+ if ( false === apply_filters( 'amp_is_enabled', true ) ) {
454
+ return;
455
+ }
456
+
457
+ define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
458
+
459
+ do_action( 'amp_init' );
460
+
461
+ load_plugin_textdomain( 'amp', false, plugin_basename( AMP__DIR__ ) . '/languages' );
462
+
463
+ add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK );
464
+ add_post_type_support( 'post', AMP_QUERY_VAR );
465
+
466
+ add_filter( 'request', 'amp_force_query_var_value' );
467
+ add_action( 'wp', 'amp_maybe_add_actions' );
468
+
469
+ if ( class_exists( 'Jetpack' ) && ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
470
+ require_once( AMP__DIR__ . '/jetpack-helper.php' );
471
+ }
472
+ }
473
+ }
classes/class-ampforwp-youtube-embed.php CHANGED
@@ -1,5 +1,4 @@
1
- <?php #971
2
- require_once AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' ;
3
 
4
  // Much of this class is borrowed from Jetpack embeds
5
  class AMPforWP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
@@ -129,4 +128,4 @@ class AMPforWP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
129
 
130
  return $value;
131
  }
132
- }
1
+ <?php require_once AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php';
 
2
 
3
  // Much of this class is borrowed from Jetpack embeds
4
  class AMPforWP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
128
 
129
  return $value;
130
  }
131
+ }
feeds/instant-article-feed.php CHANGED
@@ -1,5 +1,4 @@
1
- <?php
2
- header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
3
  $more = 1;
4
 
5
  echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
@@ -52,4 +51,4 @@
52
 
53
  <?php endwhile; ?>
54
  </channel>
55
- </rss>
1
+ <?php header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
 
2
  $more = 1;
3
 
4
  echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
51
 
52
  <?php endwhile; ?>
53
  </channel>
54
+ </rss>
includes/includes.php CHANGED
@@ -47,5 +47,4 @@
47
  wp_register_style( 'ampforwp_admin_css', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-style.css', false, '1.0.0' );
48
  wp_enqueue_style( 'ampforwp_admin_css' );
49
  }
50
-
51
  ?>
47
  wp_register_style( 'ampforwp_admin_css', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-style.css', false, '1.0.0' );
48
  wp_enqueue_style( 'ampforwp_admin_css' );
49
  }
 
50
  ?>
includes/modules/ampforwp-blurb.php CHANGED
@@ -1,7 +1,4 @@
1
- <?php
2
-
3
- class AMPFORWP_Blurb_Widget extends WP_Widget {
4
-
5
  /*--------------------------------------------------*/
6
  /* Constructor
7
  /*--------------------------------------------------*/
1
+ <?php class AMPFORWP_Blurb_Widget extends WP_Widget {
 
 
 
2
  /*--------------------------------------------------*/
3
  /* Constructor
4
  /*--------------------------------------------------*/
includes/modules/ampforwp-button.php CHANGED
@@ -1,6 +1,4 @@
1
- <?php
2
-
3
- class AMPFORWP_Button_Widget extends WP_Widget {
4
 
5
  /*--------------------------------------------------*/
6
  /* Constructor
1
+ <?php class AMPFORWP_Button_Widget extends WP_Widget {
 
 
2
 
3
  /*--------------------------------------------------*/
4
  /* Constructor
includes/newsletter.php CHANGED
@@ -1,5 +1,4 @@
1
- <?php
2
- class ampforwp_pointers {
3
  const DISPLAY_VERSION = 'v1.0';
4
  function __construct () {
5
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
@@ -130,4 +129,4 @@ class ampforwp_pointers {
130
  }
131
  }
132
  $ampforwp_pointers = new ampforwp_pointers();
133
- ?>
1
+ <?php class ampforwp_pointers {
 
2
  const DISPLAY_VERSION = 'v1.0';
3
  function __construct () {
4
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
129
  }
130
  }
131
  $ampforwp_pointers = new ampforwp_pointers();
132
+ ?>
includes/options/admin-config.php CHANGED
@@ -1,10 +1,8 @@
1
  <?php
2
  // Admin Panel Options
3
-
4
  if ( ! class_exists( 'Redux' ) ) {
5
  return;
6
  }
7
-
8
  // Option name where all the Redux data is stored.
9
  $opt_name = "redux_builder_amp";
10
  $comment_AD_URL = "http://ampforwp.com/amp-comments/#utm_source=options-panel&utm_medium=comments-tab&utm_campaign=AMP%20Plugin";
@@ -2573,4 +2571,4 @@ Redux::setSection( $opt_name, array(
2573
  ) );
2574
  /*
2575
  * <--- END SECTIONS
2576
- */
1
  <?php
2
  // Admin Panel Options
 
3
  if ( ! class_exists( 'Redux' ) ) {
4
  return;
5
  }
 
6
  // Option name where all the Redux data is stored.
7
  $opt_name = "redux_builder_amp";
8
  $comment_AD_URL = "http://ampforwp.com/amp-comments/#utm_source=options-panel&utm_medium=comments-tab&utm_campaign=AMP%20Plugin";
2571
  ) );
2572
  /*
2573
  * <--- END SECTIONS
2574
+ */
includes/options/redux-core/templates/panel/header_stickybar.tpl.php CHANGED
@@ -14,19 +14,7 @@
14
  <a href="javascript:void(0);" class="expand_options<?php echo esc_attr(( $this->parent->args['open_expanded'] ) ? ' expanded' : ''); ?>"<?php echo $this->parent->args['hide_expand'] ? ' style="display: none;"' : '' ?>>
15
  <?php esc_attr_e( 'Expand', 'redux-framework' ); ?>
16
  </a>
17
-
18
- <?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
19
- if ( is_plugin_inactive( 'amp/amp.php' ) ) {?>
20
-
21
- <p style=" text-align: left;
22
- margin-left: 50px;
23
- margin-top: 7px;">
24
- <a style="color: #e91e63;text-decoration: none;font-size: 15px;line-height: 1;" href="index.php?page=ampforwp-welcome-page">Action Required
25
- <span style="box-shadow: 0px 1px 13px rgba(0, 0, 0, 0.2);border-radius: 40px;padding: 6px 18px 8px 20px;margin-left: 12px;color: #fff;background: #e91e63;font-size: 13px;">Finish Installation</span>
26
- </a>
27
- </p>
28
- <?php } ?>
29
-
30
  <div class="redux-action_bar">
31
  <span class="spinner"></span>
32
  <?php if ( false === $this->parent->args['hide_save'] ) { ?>
14
  <a href="javascript:void(0);" class="expand_options<?php echo esc_attr(( $this->parent->args['open_expanded'] ) ? ' expanded' : ''); ?>"<?php echo $this->parent->args['hide_expand'] ? ' style="display: none;"' : '' ?>>
15
  <?php esc_attr_e( 'Expand', 'redux-framework' ); ?>
16
  </a>
17
+
 
 
 
 
 
 
 
 
 
 
 
 
18
  <div class="redux-action_bar">
19
  <span class="spinner"></span>
20
  <?php if ( false === $this->parent->args['hide_save'] ) { ?>
includes/redirect.php CHANGED
@@ -113,7 +113,6 @@ function ampforwp_page_template_redirect_archive() {
113
  }
114
  }
115
  }
116
-
117
  // Redirection code is not working properly. Need fix
118
  //add_action( 'template_redirect', 'ampforwp_page_template_redirect_non_amp', 10 );
119
  // function ampforwp_page_template_redirect_non_amp() {
@@ -134,4 +133,4 @@ function ampforwp_page_template_redirect_archive() {
134
  // wp_redirect( esc_url( $current_view_nonamp_url) , 301 );
135
  // exit();
136
  // }
137
- // }
113
  }
114
  }
115
  }
 
116
  // Redirection code is not working properly. Need fix
117
  //add_action( 'template_redirect', 'ampforwp_page_template_redirect_non_amp', 10 );
118
  // function ampforwp_page_template_redirect_non_amp() {
133
  // wp_redirect( esc_url( $current_view_nonamp_url) , 301 );
134
  // exit();
135
  // }
136
+ // }
includes/vendor/amp/LICENSE ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
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
+ {description}
294
+ Copyright (C) {year} {fullname}
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.
340
+
includes/vendor/amp/amp.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: AMP
4
+ * Description: Add AMP support to your WordPress site.
5
+ * Plugin URI: https://github.com/automattic/amp-wp
6
+ * Author: Automattic
7
+ * Author URI: https://automattic.com
8
+ * Version: 0.4.2
9
+ * Text Domain: amp
10
+ * Domain Path: /languages/
11
+ * License: GPLv2 or later
12
+ */
13
+ // Make sure the `amp` query var has an explicit value.
14
+ // Avoids issues when filtering the deprecated `query_string` hook.
15
+ if ( ! function_exists('amp_force_query_var_value') ) {
16
+ function amp_force_query_var_value( $query_vars ) {
17
+ if ( isset( $query_vars[ AMP_QUERY_VAR ] ) && '' === $query_vars[ AMP_QUERY_VAR ] ) {
18
+ $query_vars[ AMP_QUERY_VAR ] = 1;
19
+ }
20
+ return $query_vars;
21
+ }
22
+ }
23
+
24
+
25
+ if ( ! function_exists('amp_maybe_add_actions') ) {
26
+ function amp_maybe_add_actions() {
27
+ if ( ! is_singular() || is_feed() ) {
28
+ return;
29
+ }
30
+
31
+ $is_amp_endpoint = is_amp_endpoint();
32
+
33
+ // Cannot use `get_queried_object` before canonical redirect; see https://core.trac.wordpress.org/ticket/35344
34
+ global $wp_query;
35
+ $post = $wp_query->post;
36
+
37
+ $supports = post_supports_amp( $post );
38
+
39
+ if ( ! $supports ) {
40
+ if ( $is_amp_endpoint ) {
41
+ wp_safe_redirect( get_permalink( $post->ID ) );
42
+ exit;
43
+ }
44
+ return;
45
+ }
46
+
47
+ if ( $is_amp_endpoint ) {
48
+ amp_prepare_render();
49
+ } else {
50
+ amp_add_frontend_actions();
51
+ }
52
+ }
53
+ }
54
+
55
+ if ( ! function_exists('amp_load_classes') ) {
56
+ function amp_load_classes() {
57
+ require_once( AMP__DIR__ . '/includes/class-amp-post-template.php' ); // this loads everything else
58
+ }
59
+ }
60
+
61
+ if ( ! function_exists('amp_add_frontend_actions') ) {
62
+ function amp_add_frontend_actions() {
63
+ require_once( AMP__DIR__ . '/includes/amp-frontend-actions.php' );
64
+ }
65
+ }
66
+
67
+ if ( ! function_exists('amp_add_post_template_actions') ) {
68
+ function amp_add_post_template_actions() {
69
+ require_once( AMP__DIR__ . '/includes/amp-post-template-actions.php' );
70
+ require_once( AMP__DIR__ . '/includes/amp-post-template-functions.php' );
71
+ }
72
+ }
73
+ if ( ! function_exists('amp_prepare_render') ) {
74
+ function amp_prepare_render() {
75
+ add_action( 'template_redirect', 'amp_render' );
76
+ }
77
+ }
78
+ if ( ! function_exists('amp_render') ) {
79
+ function amp_render() {
80
+ amp_load_classes();
81
+
82
+ $post_id = get_queried_object_id();
83
+ do_action( 'pre_amp_render_post', $post_id );
84
+
85
+ amp_add_post_template_actions();
86
+ $template = new AMP_Post_Template( $post_id );
87
+ $template->load();
88
+ exit;
89
+ }
90
+ }
91
+ /**
92
+ * Bootstraps the AMP customizer.
93
+ *
94
+ * If the AMP customizer is enabled, initially drop the core widgets and menus panels. If the current
95
+ * preview page isn't flagged as an AMP template, the core panels will be re-added and the AMP panel
96
+ * hidden.
97
+ *
98
+ * @internal This callback must be hooked before priority 10 on 'plugins_loaded' to properly unhook
99
+ * the core panels.
100
+ *
101
+ * @since 0.4
102
+ */
103
+ if ( ! function_exists('_amp_bootstrap_customizer') ) {
104
+ function _amp_bootstrap_customizer() {
105
+ /**
106
+ * Filter whether to enable the AMP template customizer functionality.
107
+ *
108
+ * @param bool $enable Whether to enable the AMP customizer. Default true.
109
+ */
110
+ $amp_customizer_enabled = apply_filters( 'amp_customizer_is_enabled', true );
111
+
112
+ if ( true === $amp_customizer_enabled ) {
113
+ amp_init_customizer();
114
+ }
115
+ }
116
+ add_action( 'plugins_loaded', '_amp_bootstrap_customizer', 9 );
117
+ }
includes/vendor/amp/assets/images/placeholder-icon.png ADDED
Binary file
includes/vendor/amp/assets/js/amp-customizer-design-preview.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function( $ ) {
2
+ 'use strict';
3
+
4
+ // Nav bar text color.
5
+ wp.customize( 'amp_customizer[header_color]', function( value ) {
6
+ value.bind( function( to ) {
7
+ $( '.amp-wp-header a' ).css( 'color', to );
8
+ $( '.amp-wp-header div' ).css( 'color', to );
9
+ $( '.amp-wp-header .amp-wp-site-icon' ).css( 'border-color', to ).css( 'background-color', to );
10
+ } );
11
+ } );
12
+
13
+ // Nav bar background color.
14
+ wp.customize( 'amp_customizer[header_background_color]', function( value ) {
15
+ value.bind( function( to ) {
16
+ $( 'html, .amp-wp-header' ).css( 'background-color', to );
17
+ $( '.amp-wp-article a, .amp-wp-article a:visited, .amp-wp-footer a, .amp-wp-footer a:visited' ).css( 'color', to );
18
+ $( 'blockquote, .amp-wp-byline amp-img' ).css( 'border-color', to );
19
+ } );
20
+ } );
21
+
22
+ // AMP background color scheme.
23
+ wp.customize( 'amp_customizer[color_scheme]', function( value ) {
24
+ value.bind( function( to ) {
25
+ var colors = amp_customizer_design.color_schemes[ to ];
26
+
27
+ if ( ! colors ) {
28
+ console.error( 'Selected color scheme "%s" not registered.', to );
29
+ return;
30
+ }
31
+
32
+ $( 'body' ).css( 'background-color', colors.theme_color );
33
+ $( 'body, a:hover, a:active, a:focus, blockquote, .amp-wp-article, .amp-wp-title' ).css( 'color', colors.text_color );
34
+ $( '.amp-wp-meta, .wp-caption .wp-caption-text, .amp-wp-tax-category, .amp-wp-tax-tag, .amp-wp-footer p' ).css( 'color', colors.muted_text_color );
35
+ $( '.wp-caption .wp-caption-text, .amp-wp-comments-link a, .amp-wp-footer' ).css( 'border-color', colors.border_color );
36
+ $( '.amp-wp-iframe-placeholder, amp-carousel, amp-iframe, amp-youtube, amp-instagram, amp-vine' ).css( 'background-color', colors.border_color );
37
+ } );
38
+ } );
39
+
40
+ } )( jQuery );
includes/vendor/amp/assets/js/amp-customizer-preview.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function( $ ) {
2
+ 'use strict';
3
+
4
+ // Don't allow navigation away from the AMP page in the preview.
5
+ // The Customizer breaks pretty spectacularly when that happens as it's only meant to work for AMP pages.
6
+ $( 'a' ).click( function( e ) {
7
+ var href = this.getAttribute( 'href' );
8
+ if ( href && href.indexOf( '#' ) === 0 ) {
9
+ return true;
10
+ }
11
+
12
+ return false;
13
+ } );
14
+
15
+ } )( jQuery );
includes/vendor/amp/back-compat/back-compat.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // If you want to use the template that shipped with v0.3 and earlier, you can use this to force that.
4
+ // Note that this may not stick around forever, so use caution and `function_exists`.
5
+ function amp_backcompat_use_v03_templates() {
6
+ add_filter( 'amp_customizer_is_enabled', '__return_false' );
7
+ add_filter( 'amp_post_template_dir', '_amp_backcompat_use_v03_templates_callback', 0 ); // early in case there are other overrides
8
+ }
9
+
10
+ function _amp_backcompat_use_v03_templates_callback( $templates ) {
11
+ return AMP__DIR__ . '/back-compat/templates-v0-3';
12
+ }
includes/vendor/amp/back-compat/templates-v0-3/header-bar.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $site_icon_url = $this->get( 'site_icon_url' ); ?>
2
+
3
+ <nav class="amp-wp-title-bar">
4
+ <div>
5
+ <a href="<?php echo esc_url( $this->get( 'home_url' ) ); ?>">
6
+ <?php if ( $site_icon_url ) : ?>
7
+ <amp-img src="<?php echo esc_url( $site_icon_url ); ?>" width="32" height="32" class="amp-wp-site-icon"></amp-img>
8
+ <?php endif; ?>
9
+
10
+ <?php echo esc_html( $this->get( 'blog_name' ) ); ?>
11
+ </a>
12
+ </div>
13
+ </nav>
includes/vendor/amp/back-compat/templates-v0-3/meta-author.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php $post_author = $this->get( 'post_author' ); ?>
2
+ <li class="amp-wp-byline">
3
+ <?php if ( function_exists( 'get_avatar_url' ) ) : ?>
4
+ <amp-img src="<?php echo esc_url( get_avatar_url( $post_author->user_email, array(
5
+ 'size' => 24,
6
+ ) ) ); ?>" width="24" height="24" layout="fixed"></amp-img>
7
+ <?php endif; ?>
8
+ <span class="amp-wp-author"><?php echo esc_html( $post_author->display_name ); ?></span>
9
+ </li>
includes/vendor/amp/back-compat/templates-v0-3/meta-taxonomy.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $categories = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'amp' ) ); ?>
2
+ <?php if ( $categories ) : ?>
3
+ <li class="amp-wp-tax-category">
4
+ <span class="screen-reader-text">Categories:</span>
5
+ <?php echo $categories; ?>
6
+ </li>
7
+ <?php endif; ?>
8
+
9
+ <?php $tags = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'amp' ) ); ?>
10
+ <?php if ( $tags && ! is_wp_error( $tags ) ) : ?>
11
+ <li class="amp-wp-tax-tag">
12
+ <span class="screen-reader-text">Tags:</span>
13
+ <?php echo $tags; ?>
14
+ </li>
15
+ <?php endif; ?>
includes/vendor/amp/back-compat/templates-v0-3/meta-time.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <li class="amp-wp-posted-on">
2
+ <time datetime="<?php echo esc_attr( date( 'c', $this->get( 'post_publish_timestamp' ) ) ); ?>">
3
+ <?php
4
+ echo esc_html(
5
+ sprintf(
6
+ _x( '%s ago', '%s = human-readable time difference', 'amp' ),
7
+ human_time_diff( $this->get( 'post_publish_timestamp' ), current_time( 'timestamp' ) )
8
+ )
9
+ );
10
+ ?>
11
+ </time>
12
+ </li>
includes/vendor/amp/back-compat/templates-v0-3/single.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html amp <?php language_attributes(); ?>>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
6
+ <?php do_action( 'amp_post_template_head', $this ); ?>
7
+
8
+ <style amp-custom>
9
+ <?php $this->load_parts( array( 'style' ) ); ?>
10
+ <?php do_action( 'amp_post_template_css', $this ); ?>
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <?php $this->load_parts( array( 'header-bar' ) ); ?>
15
+ <div class="amp-wp-content">
16
+ <h1 class="amp-wp-title"><?php echo wp_kses_data( $this->get( 'post_title' ) ); ?></h1>
17
+ <ul class="amp-wp-meta">
18
+ <?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-author', 'meta-time', 'meta-taxonomy' ) ) ); ?>
19
+ </ul>
20
+ <?php echo $this->get( 'post_amp_content' ); // amphtml content; no kses ?>
21
+ </div>
22
+ <?php do_action( 'amp_post_template_footer', $this ); ?>
23
+ </body>
24
+ </html>
includes/vendor/amp/back-compat/templates-v0-3/style.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Merriweather fonts */
2
+ @font-face {
3
+ font-family:'Merriweather';
4
+ src:url('https://s1.wp.com/i/fonts/merriweather/merriweather-regular-webfont.woff2') format('woff2'),
5
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-regular-webfont.woff') format('woff'),
6
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-regular-webfont.ttf') format('truetype'),
7
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-regular-webfont.svg#merriweatherregular') format('svg');
8
+ font-weight:400;
9
+ font-style:normal;
10
+ }
11
+
12
+ @font-face {
13
+ font-family:'Merriweather';
14
+ src:url('https://s1.wp.com/i/fonts/merriweather/merriweather-italic-webfont.woff2') format('woff2'),
15
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-italic-webfont.woff') format('woff'),
16
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-italic-webfont.ttf') format('truetype'),
17
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-italic-webfont.svg#merriweatheritalic') format('svg');
18
+ font-weight:400;
19
+ font-style:italic;
20
+ }
21
+
22
+ @font-face {
23
+ font-family:'Merriweather';
24
+ src:url('https://s1.wp.com/i/fonts/merriweather/merriweather-bold-webfont.woff2') format('woff2'),
25
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-bold-webfont.woff') format('woff'),
26
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-bold-webfont.ttf') format('truetype'),
27
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-bold-webfont.svg#merriweatherbold') format('svg');
28
+ font-weight:700;
29
+ font-style:normal;
30
+ }
31
+
32
+ @font-face {
33
+ font-family:'Merriweather';
34
+ src:url('https://s1.wp.com/i/fonts/merriweather/merriweather-bolditalic-webfont.woff2') format('woff2'),
35
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-bolditalic-webfont.woff') format('woff'),
36
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-bolditalic-webfont.ttf') format('truetype'),
37
+ url('https://s1.wp.com/i/fonts/merriweather/merriweather-bolditalic-webfont.svg#merriweatherbold_italic') format('svg');
38
+ font-weight:700;
39
+ font-style:italic;
40
+ }
41
+
42
+ /* Generic WP styling */
43
+ amp-img.alignright { float: right; margin: 0 0 1em 1em; }
44
+ amp-img.alignleft { float: left; margin: 0 1em 1em 0; }
45
+ amp-img.aligncenter { display: block; margin-left: auto; margin-right: auto; }
46
+ .alignright { float: right; }
47
+ .alignleft { float: left; }
48
+ .aligncenter { display: block; margin-left: auto; margin-right: auto; }
49
+
50
+ .wp-caption.alignleft { margin-right: 1em; }
51
+ .wp-caption.alignright { margin-left: 1em; }
52
+
53
+ .amp-wp-enforced-sizes {
54
+ /** Our sizes fallback is 100vw, and we have a padding on the container; the max-width here prevents the element from overflowing. **/
55
+ max-width: 100%;
56
+ }
57
+
58
+ .amp-wp-unknown-size img {
59
+ /** Worst case scenario when we can't figure out dimensions for an image. **/
60
+ /** Force the image into a box of fixed dimensions and use object-fit to scale. **/
61
+ object-fit: contain;
62
+ }
63
+
64
+ /* Template Styles */
65
+ .amp-wp-content, .amp-wp-title-bar div {
66
+ <?php $content_max_width = absint( $this->get( 'content_max_width' ) ); ?>
67
+ <?php if ( $content_max_width > 0 ) : ?>
68
+ max-width: <?php echo sprintf( '%dpx', $content_max_width ); ?>;
69
+ margin: 0 auto;
70
+ <?php endif; ?>
71
+ }
72
+
73
+ body {
74
+ font-family: 'Merriweather', Serif;
75
+ font-size: 16px;
76
+ line-height: 1.8;
77
+ background: #fff;
78
+ color: #3d596d;
79
+ padding-bottom: 100px;
80
+ }
81
+
82
+ .amp-wp-content {
83
+ padding: 16px;
84
+ overflow-wrap: break-word;
85
+ word-wrap: break-word;
86
+ font-weight: 400;
87
+ color: #3d596d;
88
+ }
89
+
90
+ .amp-wp-title {
91
+ margin: 36px 0 0 0;
92
+ font-size: 36px;
93
+ line-height: 1.258;
94
+ font-weight: 700;
95
+ color: #2e4453;
96
+ }
97
+
98
+ .amp-wp-meta {
99
+ margin-bottom: 16px;
100
+ }
101
+
102
+ p,
103
+ ol,
104
+ ul,
105
+ figure {
106
+ margin: 0 0 24px 0;
107
+ }
108
+
109
+ a,
110
+ a:visited {
111
+ color: #0087be;
112
+ }
113
+
114
+ a:hover,
115
+ a:active,
116
+ a:focus {
117
+ color: #33bbe3;
118
+ }
119
+
120
+
121
+ /* UI Fonts */
122
+ .amp-wp-meta,
123
+ nav.amp-wp-title-bar,
124
+ .wp-caption-text {
125
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif;
126
+ font-size: 15px;
127
+ }
128
+
129
+
130
+ /* Meta */
131
+ ul.amp-wp-meta {
132
+ padding: 24px 0 0 0;
133
+ margin: 0 0 24px 0;
134
+ }
135
+
136
+ ul.amp-wp-meta li {
137
+ list-style: none;
138
+ display: inline-block;
139
+ margin: 0;
140
+ line-height: 24px;
141
+ white-space: nowrap;
142
+ overflow: hidden;
143
+ text-overflow: ellipsis;
144
+ max-width: 300px;
145
+ }
146
+
147
+ ul.amp-wp-meta li:before {
148
+ content: "\2022";
149
+ margin: 0 8px;
150
+ }
151
+
152
+ ul.amp-wp-meta li:first-child:before {
153
+ display: none;
154
+ }
155
+
156
+ .amp-wp-meta,
157
+ .amp-wp-meta a {
158
+ color: #4f748e;
159
+ }
160
+
161
+ .amp-wp-meta .screen-reader-text {
162
+ /* from twentyfifteen */
163
+ clip: rect(1px, 1px, 1px, 1px);
164
+ height: 1px;
165
+ overflow: hidden;
166
+ position: absolute;
167
+ width: 1px;
168
+ }
169
+
170
+ .amp-wp-byline amp-img {
171
+ border-radius: 50%;
172
+ border: 0;
173
+ background: #f3f6f8;
174
+ position: relative;
175
+ top: 6px;
176
+ margin-right: 6px;
177
+ }
178
+
179
+ /* Titlebar */
180
+ nav.amp-wp-title-bar {
181
+ background: <?php echo esc_html( $this->get_customizer_setting( 'navbar_background', self::DEFAULT_NAVBAR_BACKGROUND ) ); // not ideal for escaping here, but better than nothing? ?>;
182
+ padding: 0 16px;
183
+ }
184
+
185
+ nav.amp-wp-title-bar div {
186
+ line-height: 54px;
187
+ color: <?php echo esc_html( $this->get_customizer_setting( 'navbar_color', self::DEFAULT_NAVBAR_COLOR ) ); ?>;
188
+ }
189
+
190
+ nav.amp-wp-title-bar a {
191
+ color: <?php echo esc_html( $this->get_customizer_setting( 'navbar_color', self::DEFAULT_NAVBAR_COLOR ) ); ?>;
192
+ text-decoration: none;
193
+ }
194
+
195
+ nav.amp-wp-title-bar .amp-wp-site-icon {
196
+ /** site icon is 32px **/
197
+ float: left;
198
+ margin: 11px 8px 0 0;
199
+ border-radius: 50%;
200
+ }
201
+
202
+ /* Captions */
203
+ .wp-caption-text {
204
+ padding: 8px 16px;
205
+ font-style: italic;
206
+ }
207
+
208
+
209
+ /* Quotes */
210
+ blockquote {
211
+ padding: 16px;
212
+ margin: 8px 0 24px 0;
213
+ border-left: 2px solid #87a6bc;
214
+ color: #4f748e;
215
+ background: #e9eff3;
216
+ }
217
+
218
+ blockquote p:last-child {
219
+ margin-bottom: 0;
220
+ }
221
+
222
+ /* Other Elements */
223
+ amp-carousel {
224
+ background: #000;
225
+ }
226
+
227
+ amp-iframe,
228
+ amp-youtube,
229
+ amp-instagram,
230
+ amp-vine {
231
+ background: #f3f6f8;
232
+ }
233
+
234
+ amp-carousel > amp-img > img {
235
+ object-fit: contain;
236
+ }
237
+
238
+ .amp-wp-iframe-placeholder {
239
+ background: #f3f6f8 url( <?php echo esc_url( $this->get( 'placeholder_image_url' ) ); ?> ) no-repeat center 40%;
240
+ background-size: 48px 48px;
241
+ min-height: 48px;
242
+ }
includes/vendor/amp/includes/admin/class-amp-customizer.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * AMP class that implements a template style editor in the Customizer.
4
+ *
5
+ * A direct, formed link to the AMP editor in the Customizer is added via
6
+ * {@see amp_customizer_editor_link()} as a submenu to the Appearance menu.
7
+ *
8
+ * @since 0.4
9
+ */
10
+ class AMP_Template_Customizer {
11
+ /**
12
+ * AMP template editor panel ID.
13
+ *
14
+ * @since 0.4
15
+ * @var string
16
+ */
17
+ const PANEL_ID = 'amp_panel';
18
+
19
+ /**
20
+ * Customizer instance.
21
+ *
22
+ * @since 0.4
23
+ * @access protected
24
+ * @var WP_Customize_Manager $wp_customize
25
+ */
26
+ protected $wp_customize;
27
+
28
+ /**
29
+ * Initialize the template Customizer feature class.
30
+ *
31
+ * @static
32
+ * @since 0.4
33
+ * @access public
34
+ *
35
+ * @param WP_Customize_Manager $wp_customize Customizer instance.
36
+ */
37
+ public static function init( $wp_customize ) {
38
+ $self = new self();
39
+
40
+ $self->wp_customize = $wp_customize;
41
+
42
+ do_action( 'amp_customizer_init', $self );
43
+
44
+ // Settings need to be registered for regular customize requests as well (since save is handled there)
45
+ $self->register_settings();
46
+
47
+ // Our custom panels only need to go for AMP Customizer requests though
48
+ if ( self::is_amp_customizer() ) {
49
+ if ( empty( $_GET['url'] ) ) {
50
+ $wp_customize->set_preview_url( amp_admin_get_preview_permalink() );
51
+ }
52
+
53
+ $self->_unregister_core_ui();
54
+ $self->register_ui();
55
+ } elseif ( is_customize_preview() ) {
56
+ // Delay preview-specific actions until we're sure we're rendering an AMP page, since it's too early for `is_amp_endpoint()` here.
57
+ add_action( 'pre_amp_render_post', array( $self, 'init_preview' ) );
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Filters the core components to unhook the nav_menus and widgets panels.
63
+ *
64
+ * @since 0.4
65
+ * @access private
66
+ *
67
+ * @return array Array of core Customizer components to keep active.
68
+ */
69
+ public static function _unregister_core_panels( $panels ) {
70
+ if ( self::is_amp_customizer() ) {
71
+ $panels = array();
72
+ }
73
+ return $panels;
74
+ }
75
+
76
+ /**
77
+ * Removes all non-AMP sections and panels.
78
+ *
79
+ * Provides a clean, standalone instance-like experience by removing all non-AMP registered panels and sections.
80
+ *
81
+ * @since 0.4
82
+ * @access private
83
+ */
84
+ private function _unregister_core_ui() {
85
+ $panels = $this->wp_customize->panels();
86
+ $sections = $this->wp_customize->sections();
87
+
88
+ foreach ( $panels as $panel_id => $object ) {
89
+ $this->wp_customize->remove_panel( $panel_id );
90
+ }
91
+
92
+ foreach ( $sections as $section_id => $object ) {
93
+ $this->wp_customize->remove_section( $section_id );
94
+ }
95
+ }
96
+
97
+ public function init_preview() {
98
+ // Preview needs controls registered too for postMessage communication.
99
+ $this->register_ui();
100
+
101
+ add_action( 'amp_post_template_footer', array( $this, 'add_preview_scripts' ) );
102
+ }
103
+
104
+ /**
105
+ * Sets up the AMP Customizer preview.
106
+ */
107
+ public function register_ui() {
108
+ add_action( 'customize_controls_enqueue_scripts', array( $this, 'add_customizer_scripts' ) );
109
+ add_filter( 'customize_previewable_devices', array( $this, 'force_mobile_preview' ) );
110
+
111
+ $this->wp_customize->add_panel( self::PANEL_ID, array(
112
+ 'type' => 'amp',
113
+ 'title' => __( 'AMP', 'amp' ),
114
+ 'description' => sprintf( __( '<a href="%s" target="_blank">The AMP Project</a> is a Google-led initiative that dramatically improves loading speeds on phones and tablets. You can use the Customizer to preview changes to your AMP template before publishing them.', 'amp' ), 'https://ampproject.org' ),
115
+ ) );
116
+
117
+ do_action( 'amp_customizer_register_ui', $this->wp_customize );
118
+ }
119
+
120
+ /**
121
+ * Registers settings for customizing AMP templates.
122
+ *
123
+ * @since 0.4
124
+ * @access public
125
+ */
126
+ public function register_settings() {
127
+ do_action( 'amp_customizer_register_settings', $this->wp_customize );
128
+ }
129
+
130
+ public function add_customizer_scripts() {
131
+ wp_enqueue_script( 'wp-util' ); // fix `wp.template is not a function`
132
+ do_action( 'amp_customizer_enqueue_scripts' );
133
+ }
134
+
135
+ /**
136
+ * Enqueues scripts and fires the 'wp_footer' action so we can output customizer scripts.
137
+ *
138
+ * This breaks AMP validation in the customizer but is necessary for the live preview.
139
+ *
140
+ * @since 0.4
141
+ * @access public
142
+ */
143
+ public function add_preview_scripts() {
144
+ wp_enqueue_script(
145
+ 'amp-customizer',
146
+ amp_get_asset_url( 'js/amp-customizer-preview.js' ),
147
+ array( 'jquery', 'customize-preview', 'wp-util' ),
148
+ $version = false,
149
+ $footer = true
150
+ );
151
+
152
+ do_action( 'amp_customizer_enqueue_preview_scripts', $this->wp_customize );
153
+
154
+ /** This action is documented in wp-includes/general-template.php */
155
+ do_action( 'wp_footer' );
156
+ }
157
+
158
+ public function force_mobile_preview( $devices ) {
159
+ if ( isset( $devices[ 'mobile' ] ) ) {
160
+ $devices['mobile']['default'] = true;
161
+ unset( $devices['desktop']['default'] );
162
+ }
163
+
164
+ return $devices;
165
+ }
166
+
167
+ public static function is_amp_customizer() {
168
+ return ! empty( $_REQUEST[ AMP_CUSTOMIZER_QUERY_VAR ] );
169
+ }
170
+ }
includes/vendor/amp/includes/admin/functions.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Callbacks for adding AMP-related things to the admin.
3
+
4
+ define( 'AMP_CUSTOMIZER_QUERY_VAR', 'customize_amp' );
5
+
6
+ /**
7
+ * Sets up the AMP template editor for the Customizer.
8
+ */
9
+ function amp_init_customizer() {
10
+ require_once( AMP__DIR__ . '/includes/admin/class-amp-customizer.php' );
11
+
12
+ // Drop core panels (menus, widgets) from the AMP customizer
13
+ add_filter( 'customize_loaded_components', array( 'AMP_Template_Customizer', '_unregister_core_panels' ) );
14
+
15
+ // Fire up the AMP Customizer
16
+ add_action( 'customize_register', array( 'AMP_Template_Customizer', 'init' ), 500 );
17
+
18
+ // Add some basic design settings + controls to the Customizer
19
+ add_action( 'amp_init', array( 'AMP_Customizer_Design_Settings', 'init' ) );
20
+
21
+ // Add a link to the Customizer
22
+ add_action( 'admin_menu', 'amp_add_customizer_link' );
23
+ }
24
+
25
+ /**
26
+ * Registers a submenu page to access the AMP template editor panel in the Customizer.
27
+ */
28
+ function amp_add_customizer_link() {
29
+ // Teensy little hack on menu_slug, but it works. No redirect!
30
+ $menu_slug = add_query_arg( array(
31
+ 'autofocus[panel]' => AMP_Template_Customizer::PANEL_ID,
32
+ 'return' => rawurlencode( admin_url() ),
33
+ AMP_CUSTOMIZER_QUERY_VAR => true,
34
+ ), 'customize.php' );
35
+
36
+ // Add the theme page.
37
+ $page = add_theme_page(
38
+ __( 'AMP', 'amp' ),
39
+ __( 'AMP', 'amp' ),
40
+ 'edit_theme_options',
41
+ $menu_slug
42
+ );
43
+ }
44
+
45
+ function amp_admin_get_preview_permalink() {
46
+ /**
47
+ * Filter the post type to retrieve the latest of for use in the AMP template customizer.
48
+ *
49
+ * @param string $post_type Post type slug. Default 'post'.
50
+ */
51
+ $post_type = (string) apply_filters( 'amp_customizer_post_type', 'post' );
52
+
53
+ if ( ! post_type_supports( $post_type, 'amp' ) ) {
54
+ return;
55
+ }
56
+
57
+ $post_ids = get_posts( array(
58
+ 'post_status' => 'publish',
59
+ 'post_type' => $post_type,
60
+ 'posts_per_page' => 1,
61
+ 'fields' => 'ids',
62
+ ) );
63
+
64
+ if ( empty( $post_ids ) ) {
65
+ return false;
66
+ }
67
+
68
+ $post_id = $post_ids[0];
69
+
70
+ return amp_get_permalink( $post_id );
71
+ }
includes/vendor/amp/includes/amp-frontend-actions.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Callbacks for adding AMP-related things to the main theme
3
+
4
+ add_action( 'wp_head', 'amp_frontend_add_canonical' );
5
+
6
+ function amp_frontend_add_canonical() {
7
+ if ( false === apply_filters( 'amp_frontend_show_canonical', true ) ) {
8
+ return;
9
+ }
10
+
11
+ $amp_url = amp_get_permalink( get_queried_object_id() );
12
+ printf( '<link rel="amphtml" href="%s" />', esc_url( $amp_url ) );
13
+ }
includes/vendor/amp/includes/amp-helper-functions.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function amp_get_permalink( $post_id ) {
4
+ $pre_url = apply_filters( 'amp_pre_get_permalink', false, $post_id );
5
+
6
+ if ( false !== $pre_url ) {
7
+ return $pre_url;
8
+ }
9
+
10
+ if ( '' != get_option( 'permalink_structure' ) ) {
11
+ $amp_url = trailingslashit( get_permalink( $post_id ) ) . user_trailingslashit( AMP_QUERY_VAR, 'single_amp' );
12
+ } else {
13
+ $amp_url = add_query_arg( AMP_QUERY_VAR, 1, get_permalink( $post_id ) );
14
+ }
15
+
16
+ return apply_filters( 'amp_get_permalink', $amp_url, $post_id );
17
+ }
18
+
19
+ function post_supports_amp( $post ) {
20
+ // Because `add_rewrite_endpoint` doesn't let us target specific post_types :(
21
+ if ( ! post_type_supports( $post->post_type, AMP_QUERY_VAR ) ) {
22
+ return false;
23
+ }
24
+
25
+ if ( post_password_required( $post ) ) {
26
+ return false;
27
+ }
28
+
29
+ if ( true === apply_filters( 'amp_skip_post', false, $post->ID, $post ) ) {
30
+ return false;
31
+ }
32
+
33
+ return true;
34
+ }
35
+
36
+ /**
37
+ * Are we currently on an AMP URL?
38
+ *
39
+ * Note: will always return `false` if called before the `parse_query` hook.
40
+ */
41
+ function is_amp_endpoint() {
42
+ return false !== get_query_var( AMP_QUERY_VAR, false );
43
+ }
44
+
45
+ function amp_get_asset_url( $file ) {
46
+ return plugins_url( sprintf( 'assets/%s', $file ), AMP__FILE__ );
47
+ }
includes/vendor/amp/includes/amp-post-template-actions.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Callbacks for adding content to an AMP template
3
+
4
+ add_action( 'amp_post_template_head', 'amp_post_template_add_title' );
5
+ function amp_post_template_add_title( $amp_template ) {
6
+ ?>
7
+ <title><?php echo esc_html( $amp_template->get( 'document_title' ) ); ?></title>
8
+ <?php
9
+ }
10
+
11
+ add_action( 'amp_post_template_head', 'amp_post_template_add_canonical' );
12
+ function amp_post_template_add_canonical( $amp_template ) {
13
+ ?>
14
+ <link rel="canonical" href="<?php echo esc_url( $amp_template->get( 'canonical_url' ) ); ?>" />
15
+ <?php
16
+ }
17
+
18
+ add_action( 'amp_post_template_head', 'amp_post_template_add_scripts' );
19
+ function amp_post_template_add_scripts( $amp_template ) {
20
+ $scripts = $amp_template->get( 'amp_component_scripts', array() );
21
+ foreach ( $scripts as $element => $script ) : ?>
22
+ <script custom-element="<?php echo esc_attr( $element ); ?>" src="<?php echo esc_url( $script ); ?>" async></script>
23
+ <?php endforeach; ?>
24
+ <script src="<?php echo esc_url( $amp_template->get( 'amp_runtime_script' ) ); ?>" async></script>
25
+ <?php
26
+ }
27
+
28
+ add_action( 'amp_post_template_head', 'amp_post_template_add_fonts' );
29
+ function amp_post_template_add_fonts( $amp_template ) {
30
+ $font_urls = $amp_template->get( 'font_urls', array() );
31
+ foreach( $font_urls as $slug => $url ) : ?>
32
+ <link rel="stylesheet" href="<?php echo esc_url( $url ); ?>">
33
+ <?php endforeach;
34
+ }
35
+
36
+ add_action( 'amp_post_template_head', 'amp_post_template_add_boilerplate_css' );
37
+ function amp_post_template_add_boilerplate_css( $amp_template ) {
38
+ ?>
39
+ <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
40
+ <?php
41
+ }
42
+
43
+ add_action( 'amp_post_template_head', 'amp_post_template_add_schemaorg_metadata' );
44
+ function amp_post_template_add_schemaorg_metadata( $amp_template ) {
45
+ $metadata = $amp_template->get( 'metadata' );
46
+ if ( empty( $metadata ) ) {
47
+ return;
48
+ }
49
+ ?>
50
+ <script type="application/ld+json"><?php echo json_encode( $metadata ); ?></script>
51
+ <?php
52
+ }
53
+
54
+ add_action( 'amp_post_template_css', 'amp_post_template_add_styles', 99 );
55
+ function amp_post_template_add_styles( $amp_template ) {
56
+ $styles = $amp_template->get( 'post_amp_styles' );
57
+ if ( ! empty( $styles ) ) {
58
+ echo '/* Inline styles */' . PHP_EOL;
59
+ foreach ( $styles as $selector => $declarations ) {
60
+ $declarations = implode( ";", $declarations ) . ";";
61
+ printf( '%1$s{%2$s}', $selector, $declarations );
62
+ }
63
+ }
64
+ }
65
+
66
+ add_action( 'amp_post_template_data', 'amp_post_template_add_analytics_script' );
67
+ function amp_post_template_add_analytics_script( $data ) {
68
+ if ( ! empty( $data['amp_analytics'] ) ) {
69
+ $data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js';
70
+ }
71
+ return $data;
72
+ }
73
+
74
+ add_action( 'amp_post_template_footer', 'amp_post_template_add_analytics_data' );
75
+ function amp_post_template_add_analytics_data( $amp_template ) {
76
+ $analytics_entries = $amp_template->get( 'amp_analytics' );
77
+ if ( empty( $analytics_entries ) ) {
78
+ return;
79
+ }
80
+
81
+ foreach ( $analytics_entries as $id => $analytics_entry ) {
82
+ if ( ! isset( $analytics_entry['type'], $analytics_entry['attributes'], $analytics_entry['config_data'] ) ) {
83
+ _doing_it_wrong( __FUNCTION__, sprintf( __( 'Analytics entry for %s is missing one of the following keys: `type`, `attributes`, or `config_data` (array keys: %s)', 'amp' ), esc_html( $id ), esc_html( implode( ', ', array_keys( $analytics_entry ) ) ) ), '0.3.2' );
84
+ continue;
85
+ }
86
+
87
+ $script_element = AMP_HTML_Utils::build_tag( 'script', array(
88
+ 'type' => 'application/json',
89
+ ), json_encode( $analytics_entry['config_data'] ) );
90
+
91
+ $amp_analytics_attr = array_merge( array(
92
+ 'id' => $id,
93
+ 'type' => $analytics_entry['type'],
94
+ ), $analytics_entry['attributes'] );
95
+
96
+ echo AMP_HTML_Utils::build_tag( 'amp-analytics', $amp_analytics_attr, $script_element );
97
+ }
98
+ }
includes/vendor/amp/includes/amp-post-template-functions.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Was only available in Customizer > 4.6
4
+ if ( ! function_exists( 'sanitize_hex_color' ) ) {
5
+ function sanitize_hex_color( $color ) {
6
+ if ( '' === $color ) {
7
+ return '';
8
+ }
9
+
10
+ // 3 or 6 hex digits, or the empty string.
11
+ if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
12
+ return $color;
13
+ }
14
+ }
15
+ }
includes/vendor/amp/includes/class-amp-content.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php' );
4
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
5
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
6
+
7
+ class AMP_Content {
8
+ private $content;
9
+ private $amp_content = '';
10
+ private $amp_scripts = array();
11
+ private $amp_styles = array();
12
+ private $args = array();
13
+ private $embed_handler_classes = array();
14
+ private $sanitizer_classes = array();
15
+
16
+ public function __construct( $content, $embed_handler_classes, $sanitizer_classes, $args = array() ) {
17
+ $this->content = $content;
18
+ $this->args = $args;
19
+ $this->embed_handler_classes = $embed_handler_classes;
20
+ $this->sanitizer_classes = $sanitizer_classes;
21
+
22
+ $this->transform();
23
+ }
24
+
25
+ public function get_amp_content() {
26
+ return $this->amp_content;
27
+ }
28
+
29
+ public function get_amp_scripts() {
30
+ return $this->amp_scripts;
31
+ }
32
+
33
+ public function get_amp_styles() {
34
+ return $this->amp_styles;
35
+ }
36
+
37
+ private function transform() {
38
+ $content = $this->content;
39
+
40
+ // First, embeds + the_content filter
41
+ $embed_handlers = $this->register_embed_handlers();
42
+ $content = apply_filters( 'the_content', $content );
43
+ $this->unregister_embed_handlers( $embed_handlers );
44
+
45
+ // Then, sanitize to strip and/or convert non-amp content
46
+ $content = $this->sanitize( $content );
47
+
48
+ $this->amp_content = $content;
49
+ }
50
+
51
+ private function add_scripts( $scripts ) {
52
+ $this->amp_scripts = array_merge( $this->amp_scripts, $scripts );
53
+ }
54
+
55
+ private function add_styles( $styles ) {
56
+ $this->amp_styles = array_merge( $this->amp_styles, $styles );
57
+ }
58
+
59
+ private function register_embed_handlers() {
60
+ $embed_handlers = array();
61
+
62
+ foreach ( $this->embed_handler_classes as $embed_handler_class => $args ) {
63
+ $embed_handler = new $embed_handler_class( array_merge( $this->args, $args ) );
64
+
65
+ if ( ! is_subclass_of( $embed_handler, 'AMP_Base_Embed_Handler' ) ) {
66
+ _doing_it_wrong( __METHOD__, sprintf( __( 'Embed Handler (%s) must extend `AMP_Embed_Handler`', 'amp' ), $embed_handler_class ), '0.1' );
67
+ continue;
68
+ }
69
+
70
+ $embed_handler->register_embed();
71
+ $embed_handlers[] = $embed_handler;
72
+ }
73
+
74
+ return $embed_handlers;
75
+ }
76
+
77
+ private function unregister_embed_handlers( $embed_handlers ) {
78
+ foreach ( $embed_handlers as $embed_handler ) {
79
+ $this->add_scripts( $embed_handler->get_scripts() );
80
+ $embed_handler->unregister_embed();
81
+ }
82
+ }
83
+
84
+ private function sanitize( $content ) {
85
+ list( $sanitized_content, $scripts, $styles ) = AMP_Content_Sanitizer::sanitize( $content, $this->sanitizer_classes, $this->args );
86
+
87
+ $this->add_scripts( $scripts );
88
+ $this->add_styles( $styles );
89
+
90
+ return $sanitized_content;
91
+ }
92
+ }
93
+
94
+ class AMP_Content_Sanitizer {
95
+ public static function sanitize( $content, $sanitizer_classes, $global_args = array() ) {
96
+ $scripts = array();
97
+ $styles = array();
98
+ $dom = AMP_DOM_Utils::get_dom_from_content( $content );
99
+
100
+ foreach ( $sanitizer_classes as $sanitizer_class => $args ) {
101
+ if ( ! class_exists( $sanitizer_class ) ) {
102
+ _doing_it_wrong( __METHOD__, sprintf( __( 'Sanitizer (%s) class does not exist', 'amp' ), esc_html( $sanitizer_class ) ), '0.4.1' );
103
+ continue;
104
+ }
105
+
106
+ $sanitizer = new $sanitizer_class( $dom, array_merge( $global_args, $args ) );
107
+
108
+ if ( ! is_subclass_of( $sanitizer, 'AMP_Base_Sanitizer' ) ) {
109
+ _doing_it_wrong( __METHOD__, sprintf( __( 'Sanitizer (%s) must extend `AMP_Base_Sanitizer`', 'amp' ), esc_html( $sanitizer_class ) ), '0.1' );
110
+ continue;
111
+ }
112
+
113
+ $sanitizer->sanitize();
114
+
115
+ $scripts = array_merge( $scripts, $sanitizer->get_scripts() );
116
+ $styles = array_merge( $styles, $sanitizer->get_styles() );
117
+ }
118
+
119
+ $sanitized_content = AMP_DOM_Utils::get_content_from_dom( $dom );
120
+
121
+ return array( $sanitized_content, $scripts, $styles );
122
+ }
123
+ }
includes/vendor/amp/includes/class-amp-post-template.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php' );
4
+ require_once( AMP__DIR__ . '/includes/utils/class-amp-html-utils.php' );
5
+ require_once( AMP__DIR__ . '/includes/utils/class-amp-string-utils.php' );
6
+
7
+ require_once( AMP__DIR__ . '/includes/class-amp-content.php' );
8
+
9
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-style-sanitizer.php' );
10
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-blacklist-sanitizer.php' );
11
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-img-sanitizer.php' );
12
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-video-sanitizer.php' );
13
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-iframe-sanitizer.php' );
14
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-audio-sanitizer.php' );
15
+
16
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-twitter-embed.php' );
17
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-youtube-embed.php' );
18
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-gallery-embed.php' );
19
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-instagram-embed.php' );
20
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-vine-embed.php' );
21
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-facebook-embed.php' );
22
+
23
+ class AMP_Post_Template {
24
+ const SITE_ICON_SIZE = 32;
25
+ const CONTENT_MAX_WIDTH = 600;
26
+
27
+ // Needed for 0.3 back-compat
28
+ const DEFAULT_NAVBAR_BACKGROUND = '#0a89c0';
29
+ const DEFAULT_NAVBAR_COLOR = '#fff';
30
+
31
+ private $template_dir;
32
+ private $data;
33
+
34
+ public function __construct( $post_id ) {
35
+ $this->template_dir = apply_filters( 'amp_post_template_dir', AMP__DIR__ . '/templates' );
36
+
37
+ $this->ID = $post_id;
38
+ $this->post = get_post( $post_id );
39
+
40
+ $content_max_width = self::CONTENT_MAX_WIDTH;
41
+ if ( isset( $GLOBALS['content_width'] ) && $GLOBALS['content_width'] > 0 ) {
42
+ $content_max_width = $GLOBALS['content_width'];
43
+ }
44
+ $content_max_width = apply_filters( 'amp_content_max_width', $content_max_width );
45
+
46
+ $this->data = array(
47
+ 'content_max_width' => $content_max_width,
48
+
49
+ 'document_title' => function_exists( 'wp_get_document_title' ) ? wp_get_document_title() : wp_title( '', false ), // back-compat with 4.3
50
+ 'canonical_url' => get_permalink( $post_id ),
51
+ 'home_url' => home_url(),
52
+ 'blog_name' => get_bloginfo( 'name' ),
53
+
54
+ 'html_tag_attributes' => array(),
55
+ 'body_class' => '',
56
+
57
+ 'site_icon_url' => apply_filters( 'amp_site_icon_url', function_exists( 'get_site_icon_url' ) ? get_site_icon_url( self::SITE_ICON_SIZE ) : '' ),
58
+ 'placeholder_image_url' => amp_get_asset_url( 'images/placeholder-icon.png' ),
59
+
60
+ 'featured_image' => false,
61
+ 'comments_link_url' => false,
62
+ 'comments_link_text' => false,
63
+
64
+ 'amp_runtime_script' => 'https://cdn.ampproject.org/v0.js',
65
+ 'amp_component_scripts' => array(),
66
+
67
+ 'customizer_settings' => array(),
68
+
69
+ 'font_urls' => array(
70
+ 'merriweather' => 'https://fonts.googleapis.com/css?family=Merriweather:400,400italic,700,700italic',
71
+ ),
72
+
73
+ /**
74
+ * Add amp-analytics tags.
75
+ *
76
+ * This filter allows you to easily insert any amp-analytics tags without needing much heavy lifting.
77
+ *
78
+ * @since 0.4
79
+ *.
80
+ * @param array $analytics An associative array of the analytics entries we want to output. Each array entry must have a unique key, and the value should be an array with the following keys: `type`, `attributes`, `script_data`. See readme for more details.
81
+ * @param object $post The current post.
82
+ */
83
+ 'amp_analytics' => apply_filters( 'amp_post_template_analytics', array(), $this->post ),
84
+ );
85
+
86
+ $this->build_post_content();
87
+ $this->build_post_data();
88
+ $this->build_customizer_settings();
89
+ $this->build_html_tag_attributes();
90
+
91
+ $this->data = apply_filters( 'amp_post_template_data', $this->data, $this->post );
92
+ }
93
+
94
+ public function get( $property, $default = null ) {
95
+ if ( isset( $this->data[ $property ] ) ) {
96
+ return $this->data[ $property ];
97
+ } else {
98
+ _doing_it_wrong( __METHOD__, sprintf( __( 'Called for non-existant key ("%s").', 'amp' ), esc_html( $property ) ), '0.1' );
99
+ }
100
+
101
+ return $default;
102
+ }
103
+
104
+ public function get_customizer_setting( $name, $default = null ) {
105
+ $settings = $this->get( 'customizer_settings' );
106
+ if ( ! empty( $settings[ $name ] ) ) {
107
+ return $settings[ $name ];
108
+ }
109
+
110
+ return $default;
111
+ }
112
+
113
+ public function load() {
114
+ $this->load_parts( array( 'single' ) );
115
+ }
116
+
117
+ public function load_parts( $templates ) {
118
+ foreach ( $templates as $template ) {
119
+ $file = $this->get_template_path( $template );
120
+ $this->verify_and_include( $file, $template );
121
+ }
122
+ }
123
+
124
+ private function get_template_path( $template ) {
125
+ return sprintf( '%s/%s.php', $this->template_dir, $template );
126
+ }
127
+
128
+ private function add_data( $data ) {
129
+ $this->data = array_merge( $this->data, $data );
130
+ }
131
+
132
+ private function add_data_by_key( $key, $value ) {
133
+ $this->data[ $key ] = $value;
134
+ }
135
+
136
+ private function merge_data_for_key( $key, $value ) {
137
+ if ( is_array( $this->data[ $key ] ) ) {
138
+ $this->data[ $key ] = array_merge( $this->data[ $key ], $value );
139
+ } else {
140
+ $this->add_data_by_key( $key, $value );
141
+ }
142
+ }
143
+
144
+ private function build_post_data() {
145
+ $post_title = get_the_title( $this->ID );
146
+ $post_publish_timestamp = get_the_date( 'U', $this->ID );
147
+ $post_modified_timestamp = get_post_modified_time( 'U', false, $this->post );
148
+ $post_author = get_userdata( $this->post->post_author );
149
+
150
+ $this->add_data( array(
151
+ 'post' => $this->post,
152
+ 'post_id' => $this->ID,
153
+ 'post_title' => $post_title,
154
+ 'post_publish_timestamp' => $post_publish_timestamp,
155
+ 'post_modified_timestamp' => $post_modified_timestamp,
156
+ 'post_author' => $post_author,
157
+ ) );
158
+
159
+ $metadata = array(
160
+ '@context' => 'http://schema.org',
161
+ '@type' => 'BlogPosting',
162
+ 'mainEntityOfPage' => $this->get( 'canonical_url' ),
163
+ 'publisher' => array(
164
+ '@type' => 'Organization',
165
+ 'name' => $this->get( 'blog_name' ),
166
+ ),
167
+ 'headline' => $post_title,
168
+ 'datePublished' => date( 'c', $post_publish_timestamp ),
169
+ 'dateModified' => date( 'c', $post_modified_timestamp ),
170
+ 'author' => array(
171
+ '@type' => 'Person',
172
+ 'name' => $post_author->display_name,
173
+ ),
174
+ );
175
+
176
+ $site_icon_url = $this->get( 'site_icon_url' );
177
+ if ( $site_icon_url ) {
178
+ $metadata['publisher']['logo'] = array(
179
+ '@type' => 'ImageObject',
180
+ 'url' => $site_icon_url,
181
+ 'height' => self::SITE_ICON_SIZE,
182
+ 'width' => self::SITE_ICON_SIZE,
183
+ );
184
+ }
185
+
186
+ $image_metadata = $this->get_post_image_metadata();
187
+ if ( $image_metadata ) {
188
+ $metadata['image'] = $image_metadata;
189
+ }
190
+
191
+ $this->add_data_by_key( 'metadata', apply_filters( 'amp_post_template_metadata', $metadata, $this->post ) );
192
+
193
+ $this->build_post_featured_image();
194
+ $this->build_post_commments_data();
195
+ }
196
+
197
+ private function build_post_commments_data() {
198
+ if ( ! post_type_supports( $this->post->post_type, 'comments' ) ) {
199
+ return;
200
+ }
201
+
202
+ $comments_open = comments_open( $this->ID );
203
+
204
+ // Don't show link if close and no comments
205
+ if ( ! $comments_open
206
+ && ! $this->post->comment_count ) {
207
+ return;
208
+ }
209
+
210
+ $comments_link_url = get_comments_link( $this->ID );
211
+ $comments_link_text = $comments_open
212
+ ? __( 'Leave a Comment', 'amp' )
213
+ : __( 'View Comments', 'amp' );
214
+
215
+ $this->add_data( array(
216
+ 'comments_link_url' => $comments_link_url,
217
+ 'comments_link_text' => $comments_link_text,
218
+ ) );
219
+ }
220
+
221
+ private function build_post_content() {
222
+ $amp_content = new AMP_Content( $this->post->post_content,
223
+ apply_filters( 'amp_content_embed_handlers', array(
224
+ 'AMP_Twitter_Embed_Handler' => array(),
225
+ 'AMP_YouTube_Embed_Handler' => array(),
226
+ 'AMP_Instagram_Embed_Handler' => array(),
227
+ 'AMP_Vine_Embed_Handler' => array(),
228
+ 'AMP_Facebook_Embed_Handler' => array(),
229
+ 'AMP_Gallery_Embed_Handler' => array(),
230
+ ), $this->post ),
231
+ apply_filters( 'amp_content_sanitizers', array(
232
+ 'AMP_Style_Sanitizer' => array(),
233
+ 'AMP_Blacklist_Sanitizer' => array(),
234
+ 'AMP_Img_Sanitizer' => array(),
235
+ 'AMP_Video_Sanitizer' => array(),
236
+ 'AMP_Audio_Sanitizer' => array(),
237
+ 'AMP_Iframe_Sanitizer' => array(
238
+ 'add_placeholder' => true,
239
+ ),
240
+ ), $this->post ),
241
+ array(
242
+ 'content_max_width' => $this->get( 'content_max_width' ),
243
+ )
244
+ );
245
+
246
+ $this->add_data_by_key( 'post_amp_content', $amp_content->get_amp_content() );
247
+ $this->merge_data_for_key( 'amp_component_scripts', $amp_content->get_amp_scripts() );
248
+ $this->add_data_by_key( 'post_amp_styles', $amp_content->get_amp_styles() );
249
+ }
250
+
251
+ private function build_post_featured_image() {
252
+ $post_id = $this->ID;
253
+ $featured_html = get_the_post_thumbnail( $post_id, 'large' );
254
+
255
+ // Skip featured image if no featured image is available.
256
+ if ( ! $featured_html ) {
257
+ return;
258
+ }
259
+
260
+ $featured_id = get_post_thumbnail_id( $post_id );
261
+
262
+ // If an image with the same ID as the featured image exists in the content, skip the featured image markup.
263
+ // Prevents duplicate images, which is especially problematic for photo blogs.
264
+ // A bit crude but it's fast and should cover most cases.
265
+ $post_content = $this->post->post_content;
266
+ if ( false !== strpos( $post_content, 'wp-image-' . $featured_id )
267
+ || false !== strpos( $post_content, 'attachment_' . $featured_id ) ) {
268
+ return;
269
+ }
270
+
271
+ $featured_image = get_post( $featured_id );
272
+
273
+ list( $sanitized_html, $featured_scripts, $featured_styles ) = AMP_Content_Sanitizer::sanitize(
274
+ $featured_html,
275
+ array( 'AMP_Img_Sanitizer' => array() ),
276
+ array(
277
+ 'content_max_width' => $this->get( 'content_max_width' )
278
+ )
279
+ );
280
+
281
+ $this->add_data_by_key( 'featured_image', array(
282
+ 'amp_html' => $sanitized_html,
283
+ 'caption' => $featured_image->post_excerpt,
284
+ ) );
285
+
286
+ if ( $featured_scripts ) {
287
+ $this->merge_data_for_key( 'amp_component_scripts', $featured_scripts );
288
+ }
289
+
290
+ if ( $featured_styles ) {
291
+ $this->add_data_by_key( 'post_amp_styles', $featured_styles );
292
+ }
293
+ }
294
+
295
+ private function build_customizer_settings() {
296
+ $settings = AMP_Customizer_Settings::get_settings();
297
+
298
+ /**
299
+ * Filter AMP Customizer settings.
300
+ *
301
+ * Inject your Customizer settings here to make them accessible via the getter in your custom style.php template.
302
+ *
303
+ * Example:
304
+ *
305
+ * echo esc_html( $this->get_customizer_setting( 'your_setting_key', 'your_default_value' ) );
306
+ *
307
+ * @since 0.4
308
+ *
309
+ * @param array $settings Array of AMP Customizer settings.
310
+ * @param WP_Post $post Current post object.
311
+ */
312
+ $this->add_data_by_key( 'customizer_settings', apply_filters( 'amp_post_template_customizer_settings', $settings, $this->post ) );
313
+ }
314
+
315
+ /**
316
+ * Grabs featured image or the first attached image for the post
317
+ *
318
+ * TODO: move to a utils class?
319
+ */
320
+ private function get_post_image_metadata() {
321
+ $post_image_meta = null;
322
+ $post_image_id = false;
323
+
324
+ if ( has_post_thumbnail( $this->ID ) ) {
325
+ $post_image_id = get_post_thumbnail_id( $this->ID );
326
+ } else {
327
+ $attached_image_ids = get_posts( array(
328
+ 'post_parent' => $this->ID,
329
+ 'post_type' => 'attachment',
330
+ 'post_mime_type' => 'image',
331
+ 'posts_per_page' => 1,
332
+ 'orderby' => 'menu_order',
333
+ 'order' => 'ASC',
334
+ 'fields' => 'ids',
335
+ 'suppress_filters' => false,
336
+ ) );
337
+
338
+ if ( ! empty( $attached_image_ids ) ) {
339
+ $post_image_id = array_shift( $attached_image_ids );
340
+ }
341
+ }
342
+
343
+ if ( ! $post_image_id ) {
344
+ return false;
345
+ }
346
+
347
+ $post_image_src = wp_get_attachment_image_src( $post_image_id, 'full' );
348
+
349
+ if ( is_array( $post_image_src ) ) {
350
+ $post_image_meta = array(
351
+ '@type' => 'ImageObject',
352
+ 'url' => $post_image_src[0],
353
+ 'width' => $post_image_src[1],
354
+ 'height' => $post_image_src[2],
355
+ );
356
+ }
357
+
358
+ return $post_image_meta;
359
+ }
360
+
361
+ private function build_html_tag_attributes() {
362
+ $attributes = array();
363
+
364
+ if ( function_exists( 'is_rtl' ) && is_rtl() ) {
365
+ $attributes['dir'] = 'rtl';
366
+ }
367
+
368
+ $lang = get_bloginfo( 'language' );
369
+ if ( $lang ) {
370
+ $attributes['lang'] = $lang;
371
+ }
372
+
373
+ $this->add_data_by_key( 'html_tag_attributes', $attributes );
374
+ }
375
+
376
+ private function verify_and_include( $file, $template_type ) {
377
+ $located_file = $this->locate_template( $file );
378
+ if ( $located_file ) {
379
+ $file = $located_file;
380
+ }
381
+
382
+ $file = apply_filters( 'amp_post_template_file', $file, $template_type, $this->post );
383
+ if ( ! $this->is_valid_template( $file ) ) {
384
+ _doing_it_wrong( __METHOD__, sprintf( __( 'Path validation for template (%s) failed. Path cannot traverse and must be located in `%s`.', 'amp' ), esc_html( $file ), 'WP_CONTENT_DIR' ), '0.1' );
385
+ return;
386
+ }
387
+
388
+ do_action( 'amp_post_template_include_' . $template_type, $this );
389
+ include( $file );
390
+ }
391
+
392
+
393
+ private function locate_template( $file ) {
394
+ $search_file = sprintf( 'amp/%s', basename( $file ) );
395
+ return locate_template( array( $search_file ), false );
396
+ }
397
+
398
+ private function is_valid_template( $template ) {
399
+ if ( false !== strpos( $template, '..' ) ) {
400
+ return false;
401
+ }
402
+
403
+ if ( false !== strpos( $template, './' ) ) {
404
+ return false;
405
+ }
406
+
407
+ if ( ! file_exists( $template ) ) {
408
+ return false;
409
+ }
410
+
411
+ return true;
412
+ }
413
+ }
includes/vendor/amp/includes/embeds/class-amp-base-embed-handler.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Used by some children
4
+ require_once( AMP__DIR__ . '/includes/utils/class-amp-html-utils.php' );
5
+
6
+ abstract class AMP_Base_Embed_Handler {
7
+ protected $DEFAULT_WIDTH = 600;
8
+ protected $DEFAULT_HEIGHT = 480;
9
+
10
+ protected $args = array();
11
+ protected $did_convert_elements = false;
12
+
13
+ abstract function register_embed();
14
+ abstract function unregister_embed();
15
+
16
+ function __construct( $args = array() ) {
17
+ $this->args = wp_parse_args( $args, array(
18
+ 'width' => $this->DEFAULT_WIDTH,
19
+ 'height' => $this->DEFAULT_HEIGHT,
20
+ ) );
21
+ }
22
+
23
+ public function get_scripts() {
24
+ return array();
25
+ }
26
+ }
includes/vendor/amp/includes/embeds/class-amp-facebook-embed.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ class AMP_Facebook_Embed_Handler extends AMP_Base_Embed_Handler {
6
+ const URL_PATTERN = '#https?://(www\.)?facebook\.com/.*#i';
7
+
8
+ protected $DEFAULT_WIDTH = 600;
9
+ protected $DEFAULT_HEIGHT = 400;
10
+
11
+ private static $script_slug = 'amp-facebook';
12
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-facebook-0.1.js';
13
+
14
+ public function register_embed() {
15
+ wp_embed_register_handler( 'amp-facebook', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
16
+ }
17
+
18
+ public function unregister_embed() {
19
+ wp_embed_unregister_handler( 'amp-facebook', -1 );
20
+ }
21
+
22
+ public function get_scripts() {
23
+ if ( ! $this->did_convert_elements ) {
24
+ return array();
25
+ }
26
+
27
+ return array( self::$script_slug => self::$script_src );
28
+ }
29
+
30
+ public function oembed( $matches, $attr, $url, $rawattr ) {
31
+ return $this->render( array( 'url' => $url ) );
32
+ }
33
+
34
+ public function render( $args ) {
35
+ $args = wp_parse_args( $args, array(
36
+ 'url' => false,
37
+ ) );
38
+
39
+ if ( empty( $args['url'] ) ) {
40
+ return '';
41
+ }
42
+
43
+ $this->did_convert_elements = true;
44
+
45
+ return AMP_HTML_Utils::build_tag(
46
+ 'amp-facebook',
47
+ array(
48
+ 'data-href' => $args['url'],
49
+ 'layout' => 'responsive',
50
+ 'width' => $this->args['width'],
51
+ 'height' => $this->args['height'],
52
+ )
53
+ );
54
+ }
55
+ }
includes/vendor/amp/includes/embeds/class-amp-gallery-embed.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ class AMP_Gallery_Embed_Handler extends AMP_Base_Embed_Handler {
6
+ private static $script_slug = 'amp-carousel';
7
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-carousel-0.1.js';
8
+
9
+ public function register_embed() {
10
+ add_shortcode( 'gallery', array( $this, 'shortcode' ) );
11
+ }
12
+
13
+ public function unregister_embed() {
14
+ remove_shortcode( 'gallery' );
15
+ }
16
+
17
+ public function get_scripts() {
18
+ if ( ! $this->did_convert_elements ) {
19
+ return array();
20
+ }
21
+
22
+ return array( self::$script_slug => self::$script_src );
23
+ }
24
+
25
+ public function shortcode( $attr ) {
26
+ $post = get_post();
27
+
28
+ if ( ! empty( $attr['ids'] ) ) {
29
+ // 'ids' is explicitly ordered, unless you specify otherwise.
30
+ if ( empty( $attr['orderby'] ) ) {
31
+ $attr['orderby'] = 'post__in';
32
+ }
33
+ $attr['include'] = $attr['ids'];
34
+ }
35
+
36
+ $atts = shortcode_atts( array(
37
+ 'order' => 'ASC',
38
+ 'orderby' => 'menu_order ID',
39
+ 'id' => $post ? $post->ID : 0,
40
+ 'include' => '',
41
+ 'exclude' => '',
42
+ 'size' => array( $this->args['width'], $this->args['height'] )
43
+ ), $attr, 'gallery' );
44
+
45
+ $id = intval( $atts['id'] );
46
+
47
+ if ( ! empty( $atts['include'] ) ) {
48
+ $attachments = get_posts( array(
49
+ 'include' => $atts['include'],
50
+ 'post_status' => 'inherit',
51
+ 'post_type' => 'attachment',
52
+ 'post_mime_type' => 'image',
53
+ 'order' => $atts['order'],
54
+ 'orderby' => $atts['orderby'],
55
+ 'fields' => 'ids',
56
+ ) );
57
+ } elseif ( ! empty( $atts['exclude'] ) ) {
58
+ $attachments = get_children( array(
59
+ 'post_parent' => $id,
60
+ 'exclude' => $atts['exclude'],
61
+ 'post_status' => 'inherit',
62
+ 'post_type' => 'attachment',
63
+ 'post_mime_type' => 'image',
64
+ 'order' => $atts['order'],
65
+ 'orderby' => $atts['orderby'],
66
+ 'fields' => 'ids',
67
+ ) );
68
+ } else {
69
+ $attachments = get_children( array(
70
+ 'post_parent' => $id,
71
+ 'post_status' => 'inherit',
72
+ 'post_type' => 'attachment',
73
+ 'post_mime_type' => 'image',
74
+ 'order' => $atts['order'],
75
+ 'orderby' => $atts['orderby'],
76
+ 'fields' => 'ids',
77
+ ) );
78
+ }
79
+
80
+ if ( empty( $attachments ) ) {
81
+ return '';
82
+ }
83
+
84
+ $urls = array();
85
+ foreach ( $attachments as $attachment_id ) {
86
+ list( $url, $width, $height ) = wp_get_attachment_image_src( $attachment_id, $atts['size'], true );
87
+
88
+ if ( ! $url ) {
89
+ continue;
90
+ }
91
+
92
+ $urls[] = array(
93
+ 'url' => $url,
94
+ 'width' => $width,
95
+ 'height' => $height,
96
+ );
97
+ }
98
+
99
+ return $this->render( array(
100
+ 'images' => $urls,
101
+ ) );
102
+ }
103
+
104
+ public function render( $args ) {
105
+ $this->did_convert_elements = true;
106
+
107
+ $args = wp_parse_args( $args, array(
108
+ 'images' => false,
109
+ ) );
110
+
111
+ if ( empty( $args['images'] ) ) {
112
+ return '';
113
+ }
114
+
115
+ $images = array();
116
+ foreach ( $args['images'] as $image ) {
117
+ $images[] = AMP_HTML_Utils::build_tag(
118
+ 'amp-img',
119
+ array(
120
+ 'src' => $image['url'],
121
+ 'width' => $image['width'],
122
+ 'height' => $image['height'],
123
+ 'layout' => 'responsive',
124
+ )
125
+ );
126
+ }
127
+
128
+ return AMP_HTML_Utils::build_tag(
129
+ 'amp-carousel',
130
+ array(
131
+ 'width' => $this->args['width'],
132
+ 'height' => $this->args['height'],
133
+ 'type' => 'slides',
134
+ 'layout' => 'responsive',
135
+ ),
136
+ implode( PHP_EOL, $images )
137
+ );
138
+ }
139
+ }
includes/vendor/amp/includes/embeds/class-amp-instagram-embed.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ // Much of this class is borrowed from Jetpack embeds
6
+ class AMP_Instagram_Embed_Handler extends AMP_Base_Embed_Handler {
7
+ const SHORT_URL_HOST = 'instagr.am';
8
+ const URL_PATTERN = '#http(s?)://(www\.)?instagr(\.am|am\.com)/p/([^/?]+)#i';
9
+
10
+ protected $DEFAULT_WIDTH = 600;
11
+ protected $DEFAULT_HEIGHT = 600;
12
+
13
+ private static $script_slug = 'amp-instagram';
14
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-instagram-0.1.js';
15
+
16
+ public function register_embed() {
17
+ wp_embed_register_handler( 'amp-instagram', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
18
+ add_shortcode( 'instagram', array( $this, 'shortcode' ) );
19
+ }
20
+
21
+ public function unregister_embed() {
22
+ wp_embed_unregister_handler( 'amp-instagram', -1 );
23
+ remove_shortcode( 'instagram' );
24
+ }
25
+
26
+ public function get_scripts() {
27
+ if ( ! $this->did_convert_elements ) {
28
+ return array();
29
+ }
30
+
31
+ return array( self::$script_slug => self::$script_src );
32
+ }
33
+
34
+ public function shortcode( $attr ) {
35
+ $url = false;
36
+
37
+ $instagram_id = false;
38
+ if ( isset( $attr['url'] ) ) {
39
+ $url = trim( $attr['url'] );
40
+ }
41
+
42
+ if ( empty( $url ) ) {
43
+ return '';
44
+ }
45
+
46
+ $instagram_id = $this->get_instagram_id_from_url( $url );
47
+
48
+ return $this->render( array(
49
+ 'url' => $url,
50
+ 'instagram_id' => $instagram_id,
51
+ ) );
52
+ }
53
+
54
+ public function oembed( $matches, $attr, $url, $rawattr ) {
55
+ return $this->render( array( 'url' => $url, 'instagram_id' => end( $matches ) ) );
56
+ }
57
+
58
+ public function render( $args ) {
59
+ $args = wp_parse_args( $args, array(
60
+ 'url' => false,
61
+ 'instagram_id' => false,
62
+ ) );
63
+
64
+ if ( empty( $args['instagram_id'] ) ) {
65
+ return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
66
+ }
67
+
68
+ $this->did_convert_elements = true;
69
+
70
+ return AMP_HTML_Utils::build_tag(
71
+ 'amp-instagram',
72
+ array(
73
+ 'data-shortcode' => $args['instagram_id'],
74
+ 'layout' => 'responsive',
75
+ 'width' => $this->args['width'],
76
+ 'height' => $this->args['height'],
77
+ )
78
+ );
79
+ }
80
+
81
+ private function get_instagram_id_from_url( $url ) {
82
+ $found = preg_match( self::URL_PATTERN, $url, $matches );
83
+
84
+ if ( ! $found ) {
85
+ return false;
86
+ }
87
+
88
+ return end( $matches );
89
+ }
90
+ }
includes/vendor/amp/includes/embeds/class-amp-twitter-embed.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ // Much of this class is borrowed from Jetpack embeds
6
+ class AMP_Twitter_Embed_Handler extends AMP_Base_Embed_Handler {
7
+ const URL_PATTERN = '#http(s|):\/\/twitter\.com(\/\#\!\/|\/)([a-zA-Z0-9_]{1,20})\/status(es)*\/(\d+)#i';
8
+
9
+ private static $script_slug = 'amp-twitter';
10
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-twitter-0.1.js';
11
+
12
+ public function register_embed() {
13
+ add_shortcode( 'tweet', array( $this, 'shortcode' ) );
14
+ wp_embed_register_handler( 'amp-twitter', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
15
+ }
16
+
17
+ public function unregister_embed() {
18
+ remove_shortcode( 'tweet' );
19
+ wp_embed_unregister_handler( 'amp-twitter', -1 );
20
+ }
21
+
22
+ public function get_scripts() {
23
+ if ( ! $this->did_convert_elements ) {
24
+ return array();
25
+ }
26
+
27
+ return array( self::$script_slug => self::$script_src );
28
+ }
29
+
30
+ function shortcode( $attr ) {
31
+ $attr = wp_parse_args( $attr, array(
32
+ 'tweet' => false,
33
+ ) );
34
+
35
+ if ( empty( $attr['tweet'] ) && ! empty( $attr[0] ) ) {
36
+ $attr['tweet'] = $attr[0];
37
+ }
38
+
39
+ $id = false;
40
+ if ( is_numeric( $attr['tweet'] ) ) {
41
+ $id = $attr['tweet'];
42
+ } else {
43
+ preg_match( self::URL_PATTERN, $attr['tweet'], $matches );
44
+ if ( isset( $matches[5] ) && is_numeric( $matches[5] ) ) {
45
+ $id = $matches[5];
46
+ }
47
+
48
+ if ( empty( $id ) ) {
49
+ return '';
50
+ }
51
+ }
52
+
53
+ $this->did_convert_elements = true;
54
+
55
+ return AMP_HTML_Utils::build_tag(
56
+ 'amp-twitter',
57
+ array(
58
+ 'data-tweetid' => $id,
59
+ 'layout' => 'responsive',
60
+ 'width' => $this->args['width'],
61
+ 'height' => $this->args['height'],
62
+ )
63
+ );
64
+ }
65
+
66
+ function oembed( $matches, $attr, $url, $rawattr ) {
67
+ $id = false;
68
+
69
+ if ( isset( $matches[5] ) && is_numeric( $matches[5] ) ) {
70
+ $id = $matches[5];
71
+ }
72
+
73
+ if ( ! $id ) {
74
+ return '';
75
+ }
76
+
77
+ return $this->shortcode( array( 'tweet' => $id ) );
78
+ }
79
+ }
includes/vendor/amp/includes/embeds/class-amp-vine-embed.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ class AMP_Vine_Embed_Handler extends AMP_Base_Embed_Handler {
6
+ const URL_PATTERN = '#https?://vine\.co/v/([^/?]+)#i';
7
+
8
+ protected $DEFAULT_WIDTH = 400;
9
+ protected $DEFAULT_HEIGHT = 400;
10
+
11
+ private static $script_slug = 'amp-vine';
12
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-vine-0.1.js';
13
+
14
+ public function register_embed() {
15
+ wp_embed_register_handler( 'amp-vine', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
16
+ }
17
+
18
+ public function unregister_embed() {
19
+ wp_embed_unregister_handler( 'amp-vine', -1 );
20
+ }
21
+
22
+ public function get_scripts() {
23
+ if ( ! $this->did_convert_elements ) {
24
+ return array();
25
+ }
26
+
27
+ return array( self::$script_slug => self::$script_src );
28
+ }
29
+
30
+ public function oembed( $matches, $attr, $url, $rawattr ) {
31
+ return $this->render( array( 'url' => $url, 'vine_id' => end( $matches ) ) );
32
+ }
33
+
34
+ public function render( $args ) {
35
+ $args = wp_parse_args( $args, array(
36
+ 'url' => false,
37
+ 'vine_id' => false,
38
+ ) );
39
+
40
+ if ( empty( $args['vine_id'] ) ) {
41
+ return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
42
+ }
43
+
44
+ $this->did_convert_elements = true;
45
+
46
+ return AMP_HTML_Utils::build_tag(
47
+ 'amp-vine',
48
+ array(
49
+ 'data-vineid' => $args['vine_id'],
50
+ 'layout' => 'responsive',
51
+ 'width' => $this->args['width'],
52
+ 'height' => $this->args['height'],
53
+ )
54
+ );
55
+ }
56
+ }
includes/vendor/amp/includes/embeds/class-amp-youtube-embed.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
4
+
5
+ // Much of this class is borrowed from Jetpack embeds
6
+ class AMP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
7
+ const SHORT_URL_HOST = 'youtu.be';
8
+ // Only handling single videos. Playlists are handled elsewhere.
9
+ const URL_PATTERN = '#https?://(?:www\.)?(?:youtube.com/(?:v/|e/|embed/|watch[/\#?])|youtu\.be/).*#i';
10
+ const RATIO = 0.5625;
11
+
12
+ protected $DEFAULT_WIDTH = 600;
13
+ protected $DEFAULT_HEIGHT = 338;
14
+
15
+ private static $script_slug = 'amp-youtube';
16
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-youtube-0.1.js';
17
+
18
+ function __construct( $args = array() ) {
19
+ parent::__construct( $args );
20
+
21
+ if ( isset( $this->args['content_max_width'] ) ) {
22
+ $max_width = $this->args['content_max_width'];
23
+ $this->args['width'] = $max_width;
24
+ $this->args['height'] = round( $max_width * self::RATIO );
25
+ }
26
+ }
27
+
28
+ function register_embed() {
29
+ wp_embed_register_handler( 'amp-youtube', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
30
+ add_shortcode( 'youtube', array( $this, 'shortcode' ) );
31
+ }
32
+
33
+ public function unregister_embed() {
34
+ wp_embed_unregister_handler( 'amp-youtube', -1 );
35
+ remove_shortcode( 'youtube' );
36
+ }
37
+
38
+ public function get_scripts() {
39
+ if ( ! $this->did_convert_elements ) {
40
+ return array();
41
+ }
42
+
43
+ return array( self::$script_slug => self::$script_src );
44
+ }
45
+
46
+ public function shortcode( $attr ) {
47
+ $url = false;
48
+ $video_id = false;
49
+ if ( isset( $attr[0] ) ) {
50
+ $url = ltrim( $attr[0] , '=' );
51
+ } elseif ( function_exists ( 'shortcode_new_to_old_params' ) ) {
52
+ $url = shortcode_new_to_old_params( $attr );
53
+ }
54
+
55
+ if ( empty( $url ) ) {
56
+ return '';
57
+ }
58
+
59
+ $video_id = $this->get_video_id_from_url( $url );
60
+
61
+ return $this->render( array(
62
+ 'url' => $url,
63
+ 'video_id' => $video_id,
64
+ ) );
65
+ }
66
+
67
+ public function oembed( $matches, $attr, $url, $rawattr ) {
68
+ return $this->shortcode( array( $url ) );
69
+ }
70
+
71
+ public function render( $args ) {
72
+ $args = wp_parse_args( $args, array(
73
+ 'video_id' => false,
74
+ ) );
75
+
76
+ if ( empty( $args['video_id'] ) ) {
77
+ return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
78
+ }
79
+
80
+ $this->did_convert_elements = true;
81
+
82
+ return AMP_HTML_Utils::build_tag(
83
+ 'amp-youtube',
84
+ array(
85
+ 'data-videoid' => $args['video_id'],
86
+ 'layout' => 'responsive',
87
+ 'width' => $this->args['width'],
88
+ 'height' => $this->args['height'],
89
+ )
90
+ );
91
+ }
92
+
93
+ private function get_video_id_from_url( $url ) {
94
+ $video_id = false;
95
+ $parsed_url = parse_url( $url );
96
+
97
+ if ( self::SHORT_URL_HOST === substr( $parsed_url['host'], -strlen( self::SHORT_URL_HOST ) ) ) {
98
+ // youtu.be/{id}
99
+ $parts = explode( '/', $parsed_url['path'] );
100
+ if ( ! empty( $parts ) ) {
101
+ $video_id = $parts[1];
102
+ }
103
+ } else {
104
+ // ?v={id} or ?list={id}
105
+ parse_str( $parsed_url['query'], $query_args );
106
+
107
+ if ( isset( $query_args['v'] ) ) {
108
+ $video_id = $this->sanitize_v_arg( $query_args['v'] );
109
+ }
110
+ }
111
+
112
+ if ( empty( $video_id ) ) {
113
+ // /(v|e|embed)/{id}
114
+ $parts = explode( '/', $parsed_url['path'] );
115
+
116
+ if ( in_array( $parts[1], array( 'v', 'e', 'embed' ) ) ) {
117
+ $video_id = $parts[2];
118
+ }
119
+ }
120
+
121
+ return $video_id;
122
+ }
123
+
124
+ private function sanitize_v_arg( $value ) {
125
+ // Deal with broken params like `?v=123?rel=0`
126
+ if ( false !== strpos( $value, '?' ) ) {
127
+ $value = strtok( $value, '?' );
128
+ }
129
+
130
+ return $value;
131
+ }
132
+ }
includes/vendor/amp/includes/lib/class-fastimage.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * FastImage - Because sometimes you just want the size!
5
+ * Based on the Ruby Implementation by Steven Sykes (https://github.com/sdsykes/fastimage)
6
+ *
7
+ * Copyright (c) 2012 Tom Moor
8
+ * Tom Moor, http://tommoor.com
9
+ *
10
+ * MIT Licensed
11
+ * @version 0.1
12
+ */
13
+
14
+ class FastImage
15
+ {
16
+ private $strpos = 0;
17
+ private $str;
18
+ private $type;
19
+ private $handle;
20
+
21
+ public function __construct($uri = null)
22
+ {
23
+ if ($uri) $this->load($uri);
24
+ }
25
+
26
+
27
+ public function load($uri)
28
+ {
29
+ if ($this->handle) $this->close();
30
+
31
+ $this->handle = fopen($uri, 'r');
32
+ }
33
+
34
+
35
+ public function close()
36
+ {
37
+ if ($this->handle)
38
+ {
39
+ fclose($this->handle);
40
+ $this->handle = null;
41
+ $this->type = null;
42
+ $this->str = null;
43
+ }
44
+ }
45
+
46
+
47
+ public function getSize()
48
+ {
49
+ if (!$this->handle)
50
+ {
51
+ return false;
52
+ }
53
+
54
+ $this->strpos = 0;
55
+ if ($this->getType())
56
+ {
57
+ return array_values($this->parseSize());
58
+ }
59
+
60
+ return false;
61
+ }
62
+
63
+
64
+ public function getType()
65
+ {
66
+ if (!$this->handle)
67
+ {
68
+ return false;
69
+ }
70
+
71
+ $this->strpos = 0;
72
+
73
+ if (!$this->type)
74
+ {
75
+ switch ($this->getChars(2))
76
+ {
77
+ case "BM":
78
+ return $this->type = 'bmp';
79
+ case "GI":
80
+ return $this->type = 'gif';
81
+ case chr(0xFF).chr(0xd8):
82
+ return $this->type = 'jpeg';
83
+ case chr(0x89).'P':
84
+ return $this->type = 'png';
85
+ default:
86
+ return false;
87
+ }
88
+ }
89
+
90
+ return $this->type;
91
+ }
92
+
93
+
94
+ private function parseSize()
95
+ {
96
+ $this->strpos = 0;
97
+
98
+ switch ($this->type)
99
+ {
100
+ case 'png':
101
+ return $this->parseSizeForPNG();
102
+ case 'gif':
103
+ return $this->parseSizeForGIF();
104
+ case 'bmp':
105
+ return $this->parseSizeForBMP();
106
+ case 'jpeg':
107
+ return $this->parseSizeForJPEG();
108
+ }
109
+
110
+ return null;
111
+ }
112
+
113
+
114
+ private function parseSizeForPNG()
115
+ {
116
+ $chars = $this->getChars(25);
117
+
118
+ return unpack("N*", substr($chars, 16, 8));
119
+ }
120
+
121
+
122
+ private function parseSizeForGIF()
123
+ {
124
+ $chars = $this->getChars(11);
125
+
126
+ return unpack("S*", substr($chars, 6, 4));
127
+ }
128
+
129
+
130
+ private function parseSizeForBMP()
131
+ {
132
+ $chars = $this->getChars(29);
133
+ $chars = substr($chars, 14, 14);
134
+ $type = unpack('C', $chars);
135
+
136
+ return (reset($type) == 40) ? unpack('L*', substr($chars, 4)) : unpack('L*', substr($chars, 4, 8));
137
+ }
138
+
139
+
140
+ private function parseSizeForJPEG()
141
+ {
142
+ $state = null;
143
+ $i = 0;
144
+
145
+ while (true)
146
+ {
147
+ switch ($state)
148
+ {
149
+ default:
150
+ $this->getChars(2);
151
+ $state = 'started';
152
+ break;
153
+
154
+ case 'started':
155
+ $b = $this->getByte();
156
+ if ($b === false) return false;
157
+
158
+ $state = $b == 0xFF ? 'sof' : 'started';
159
+ break;
160
+
161
+ case 'sof':
162
+ $b = $this->getByte();
163
+ if (in_array($b, range(0xe0, 0xef)))
164
+ {
165
+ $state = 'skipframe';
166
+ }
167
+ elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF))))
168
+ {
169
+ $state = 'readsize';
170
+ }
171
+ elseif ($b == 0xFF)
172
+ {
173
+ $state = 'sof';
174
+ }
175
+ else
176
+ {
177
+ $state = 'skipframe';
178
+ }
179
+ break;
180
+
181
+ case 'skipframe':
182
+ $skip = $this->readInt($this->getChars(2)) - 2;
183
+ $state = 'doskip';
184
+ break;
185
+
186
+ case 'doskip':
187
+ $this->getChars($skip);
188
+ $state = 'started';
189
+ break;
190
+
191
+ case 'readsize':
192
+ $c = $this->getChars(7);
193
+
194
+ return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2)));
195
+ }
196
+ }
197
+ }
198
+
199
+
200
+ private function getChars($n)
201
+ {
202
+ $response = null;
203
+
204
+ // do we need more data?
205
+ if ($this->strpos + $n -1 >= strlen($this->str))
206
+ {
207
+ $end = ($this->strpos + $n);
208
+
209
+ while (strlen($this->str) < $end && $response !== false)
210
+ {
211
+ // read more from the file handle
212
+ $need = $end - ftell($this->handle);
213
+
214
+ if ($response = fread($this->handle, $need))
215
+ {
216
+ $this->str .= $response;
217
+ }
218
+ else
219
+ {
220
+ return false;
221
+ }
222
+ }
223
+ }
224
+
225
+ $result = substr($this->str, $this->strpos, $n);
226
+ $this->strpos += $n;
227
+
228
+ return $result;
229
+ }
230
+
231
+
232
+ private function getByte()
233
+ {
234
+ $c = $this->getChars(1);
235
+ $b = unpack("C", $c);
236
+
237
+ return reset($b);
238
+ }
239
+
240
+
241
+ private function readInt($str)
242
+ {
243
+ $size = unpack("C*", $str);
244
+
245
+ return ($size[1] << 8) + $size[2];
246
+ }
247
+
248
+
249
+ public function __destruct()
250
+ {
251
+ $this->close();
252
+ }
253
+ }
includes/vendor/amp/includes/sanitizers/class-amp-audio-sanitizer.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
+
5
+ class AMP_Audio_Sanitizer extends AMP_Base_Sanitizer {
6
+ public static $tag = 'audio';
7
+
8
+ private static $script_slug = 'amp-audio';
9
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-audio-0.1.js';
10
+
11
+ public function get_scripts() {
12
+ if ( ! $this->did_convert_elements ) {
13
+ return array();
14
+ }
15
+
16
+ return array( self::$script_slug => self::$script_src );
17
+ }
18
+
19
+ public function sanitize() {
20
+ $nodes = $this->dom->getElementsByTagName( self::$tag );
21
+ $num_nodes = $nodes->length;
22
+ if ( 0 === $num_nodes ) {
23
+ return;
24
+ }
25
+
26
+ for ( $i = $num_nodes - 1; $i >= 0; $i-- ) {
27
+ $node = $nodes->item( $i );
28
+ $old_attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $node );
29
+
30
+ $new_attributes = $this->filter_attributes( $old_attributes );
31
+
32
+ $new_node = AMP_DOM_Utils::create_node( $this->dom, 'amp-audio', $new_attributes );
33
+
34
+ // TODO: `source` does not have closing tag, and DOMDocument doesn't handle it well.
35
+ foreach ( $node->childNodes as $child_node ) {
36
+ $new_child_node = $child_node->cloneNode( true );
37
+ $old_child_attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $new_child_node );
38
+ $new_child_attributes = $this->filter_attributes( $old_child_attributes );
39
+
40
+ // Only append source tags with a valid src attribute
41
+ if ( ! empty( $new_child_attributes['src'] ) && 'source' === $new_child_node->tagName ) {
42
+ $new_node->appendChild( $new_child_node );
43
+ }
44
+ }
45
+
46
+ // If the node has at least one valid source, replace the old node with it.
47
+ // Otherwise, just remove the node.
48
+ //
49
+ // TODO: Add a fallback handler.
50
+ // See: https://github.com/ampproject/amphtml/issues/2261
51
+ if ( 0 === $new_node->childNodes->length && empty( $new_attributes['src'] ) ) {
52
+ $node->parentNode->removeChild( $node );
53
+ } else {
54
+ $node->parentNode->replaceChild( $new_node, $node );
55
+ }
56
+
57
+ $this->did_convert_elements = true;
58
+ }
59
+ }
60
+
61
+ private function filter_attributes( $attributes ) {
62
+ $out = array();
63
+
64
+ foreach ( $attributes as $name => $value ) {
65
+ switch ( $name ) {
66
+ case 'src':
67
+ $out[ $name ] = $this->maybe_enforce_https_src( $value );
68
+ break;
69
+
70
+ case 'width':
71
+ case 'height':
72
+ $out[ $name ] = $this->sanitize_dimension( $value, $name );
73
+ break;
74
+
75
+ case 'class':
76
+ $out[ $name ] = $value;
77
+ break;
78
+ case 'loop':
79
+ case 'muted':
80
+ case 'autoplay':
81
+ if ( 'false' !== $value ) {
82
+ $out[ $name ] = '';
83
+ }
84
+ break;
85
+
86
+ default;
87
+ break;
88
+ }
89
+ }
90
+
91
+ return $out;
92
+ }
93
+ }
includes/vendor/amp/includes/sanitizers/class-amp-base-sanitizer.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class AMP_Base_Sanitizer {
4
+ const FALLBACK_HEIGHT = 400;
5
+
6
+ protected $DEFAULT_ARGS = array();
7
+
8
+ protected $dom;
9
+ protected $args;
10
+ protected $did_convert_elements = false;
11
+
12
+ public function __construct( $dom, $args = array() ) {
13
+ $this->dom = $dom;
14
+ $this->args = array_merge( $this->DEFAULT_ARGS, $args );
15
+ }
16
+
17
+ abstract public function sanitize();
18
+
19
+ public function get_scripts() {
20
+ return array();
21
+ }
22
+
23
+ public function get_styles() {
24
+ return array();
25
+ }
26
+
27
+ protected function get_body_node() {
28
+ return $this->dom->getElementsByTagName( 'body' )->item( 0 );
29
+ }
30
+
31
+ public function sanitize_dimension( $value, $dimension ) {
32
+ if ( empty( $value ) ) {
33
+ return $value;
34
+ }
35
+
36
+ if ( false !== filter_var( $value, FILTER_VALIDATE_INT ) ) {
37
+ return absint( $value );
38
+ }
39
+
40
+ if ( AMP_String_Utils::endswith( $value, 'px' ) ) {
41
+ return absint( $value );
42
+ }
43
+
44
+ if ( AMP_String_Utils::endswith( $value, '%' ) ) {
45
+ if ( 'width' === $dimension && isset( $this->args[ 'content_max_width'] ) ) {
46
+ $percentage = absint( $value ) / 100;
47
+ return round( $percentage * $this->args[ 'content_max_width'] );
48
+ }
49
+ }
50
+
51
+ return '';
52
+ }
53
+
54
+ public function enforce_fixed_height( $attributes ) {
55
+ if ( empty( $attributes['height'] ) ) {
56
+ unset( $attributes['width'] );
57
+ $attributes['height'] = self::FALLBACK_HEIGHT;
58
+ }
59
+
60
+ if ( empty( $attributes['width'] ) ) {
61
+ $attributes['layout'] = 'fixed-height';
62
+ }
63
+
64
+ return $attributes;
65
+ }
66
+
67
+ /**
68
+ * This is our workaround to enforce max sizing with layout=responsive.
69
+ *
70
+ * We want elements to not grow beyond their width and shrink to fill the screen on viewports smaller than their width.
71
+ *
72
+ * See https://github.com/ampproject/amphtml/issues/1280#issuecomment-171533526
73
+ * See https://github.com/Automattic/amp-wp/issues/101
74
+ */
75
+ public function enforce_sizes_attribute( $attributes ) {
76
+ if ( ! isset( $attributes['width'], $attributes['height'] ) ) {
77
+ return $attributes;
78
+ }
79
+
80
+ $max_width = $attributes['width'];
81
+ if ( isset( $this->args['content_max_width'] ) && $max_width >= $this->args['content_max_width'] ) {
82
+ $max_width = $this->args['content_max_width'];
83
+ }
84
+
85
+ $attributes['sizes'] = sprintf( '(min-width: %1$dpx) %1$dpx, 100vw', absint( $max_width ) );
86
+
87
+ $this->add_or_append_attribute( $attributes, 'class', 'amp-wp-enforced-sizes' );
88
+
89
+ return $attributes;
90
+ }
91
+
92
+ public function add_or_append_attribute( &$attributes, $key, $value, $separator = ' ' ) {
93
+ if ( isset( $attributes[ $key ] ) ) {
94
+ $attributes[ $key ] .= $separator . $value;
95
+ } else {
96
+ $attributes[ $key ] = $value;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Decide if we should remove a src attribute if https is required.
102
+ * If not required, the implementing class may want to try and force https instead.
103
+ *
104
+ * @param string $src
105
+ * @param boolean $force_https
106
+ * @return string
107
+ */
108
+ public function maybe_enforce_https_src( $src, $force_https = false ) {
109
+ $protocol = strtok( $src, ':' );
110
+ if ( 'https' !== $protocol ) {
111
+ // Check if https is required
112
+ if ( isset( $this->args['require_https_src'] ) && true === $this->args['require_https_src'] ) {
113
+ // Remove the src. Let the implementing class decide what do from here.
114
+ $src = '';
115
+ } elseif ( ( ! isset( $this->args['require_https_src'] ) || false === $this->args['require_https_src'] )
116
+ && true === $force_https ) {
117
+ // Don't remove the src, but force https instead
118
+ $src = set_url_scheme( $src, 'https' );
119
+ }
120
+ }
121
+
122
+ return $src;
123
+ }
124
+ }
includes/vendor/amp/includes/sanitizers/class-amp-blacklist-sanitizer.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
+
5
+ /**
6
+ * Strips blacklisted tags and attributes from content.
7
+ *
8
+ * See following for blacklist:
9
+ * https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#html-tags
10
+ */
11
+ class AMP_Blacklist_Sanitizer extends AMP_Base_Sanitizer {
12
+ const PATTERN_REL_WP_ATTACHMENT = '#wp-att-([\d]+)#';
13
+
14
+ protected $DEFAULT_ARGS = array(
15
+ 'add_blacklisted_protocols' => array(),
16
+ 'add_blacklisted_tags' => array(),
17
+ 'add_blacklisted_attributes' => array(),
18
+ );
19
+
20
+ public function sanitize() {
21
+ $blacklisted_tags = $this->get_blacklisted_tags();
22
+ $blacklisted_attributes = $this->get_blacklisted_attributes();
23
+ $blacklisted_protocols = $this->get_blacklisted_protocols();
24
+
25
+ $body = $this->get_body_node();
26
+ $this->strip_tags( $body, $blacklisted_tags );
27
+ $this->strip_attributes_recursive( $body, $blacklisted_attributes, $blacklisted_protocols );
28
+ }
29
+
30
+ private function strip_attributes_recursive( $node, $bad_attributes, $bad_protocols ) {
31
+ if ( $node->nodeType !== XML_ELEMENT_NODE ) {
32
+ return;
33
+ }
34
+
35
+ $node_name = $node->nodeName;
36
+
37
+ // Some nodes may contain valid content but are themselves invalid.
38
+ // Remove the node but preserve the children.
39
+ if ( 'font' === $node_name ) {
40
+ $this->replace_node_with_children( $node, $bad_attributes, $bad_protocols );
41
+ return;
42
+ } elseif ( 'a' === $node_name && false === $this->validate_a_node( $node ) ) {
43
+ $this->replace_node_with_children( $node, $bad_attributes, $bad_protocols );
44
+ return;
45
+ }
46
+
47
+ if ( $node->hasAttributes() ) {
48
+ $length = $node->attributes->length;
49
+ for ( $i = $length - 1; $i >= 0; $i-- ) {
50
+ $attribute = $node->attributes->item( $i );
51
+ $attribute_name = strtolower( $attribute->name );
52
+ if ( in_array( $attribute_name, $bad_attributes ) ) {
53
+ $node->removeAttribute( $attribute_name );
54
+ continue;
55
+ }
56
+
57
+ // on* attributes (like onclick) are a special case
58
+ if ( 0 === stripos( $attribute_name, 'on' ) && $attribute_name != 'on' ) {
59
+ $node->removeAttribute( $attribute_name );
60
+ continue;
61
+ } elseif ( 'a' === $node_name ) {
62
+ $this->sanitize_a_attribute( $node, $attribute );
63
+ }
64
+ }
65
+ }
66
+
67
+ $length = $node->childNodes->length;
68
+ for ( $i = $length - 1; $i >= 0; $i-- ) {
69
+ $child_node = $node->childNodes->item( $i );
70
+
71
+ $this->strip_attributes_recursive( $child_node, $bad_attributes, $bad_protocols );
72
+ }
73
+ }
74
+
75
+ private function strip_tags( $node, $tag_names ) {
76
+ foreach ( $tag_names as $tag_name ) {
77
+ $elements = $node->getElementsByTagName( $tag_name );
78
+ $length = $elements->length;
79
+ if ( 0 === $length ) {
80
+ continue;
81
+ }
82
+
83
+ for ( $i = $length - 1; $i >= 0; $i-- ) {
84
+ $element = $elements->item( $i );
85
+ $parent_node = $element->parentNode;
86
+ $parent_node->removeChild( $element );
87
+
88
+ if ( 'body' !== $parent_node->nodeName && AMP_DOM_Utils::is_node_empty( $parent_node ) ) {
89
+ $parent_node->parentNode->removeChild( $parent_node );
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ private function sanitize_a_attribute( $node, $attribute ) {
96
+ $attribute_name = strtolower( $attribute->name );
97
+
98
+ if ( 'rel' === $attribute_name ) {
99
+ $old_value = $attribute->value;
100
+ $new_value = trim( preg_replace( self::PATTERN_REL_WP_ATTACHMENT, '', $old_value ) );
101
+ if ( empty( $new_value ) ) {
102
+ $node->removeAttribute( $attribute_name );
103
+ } elseif ( $old_value !== $new_value ) {
104
+ $node->setAttribute( $attribute_name, $new_value );
105
+ }
106
+ } elseif ( 'rev' === $attribute_name ) {
107
+ // rev removed from HTML5 spec, which was used by Jetpack Markdown.
108
+ $node->removeAttribute( $attribute_name );
109
+ } elseif ( 'target' === $attribute_name ) {
110
+ // _blank is the only allowed value and it must be lowercase.
111
+ // replace _new with _blank and others should simply be removed.
112
+ $old_value = strtolower( $attribute->value );
113
+ if ( '_blank' === $old_value || '_new' === $old_value ) {
114
+ // _new is not allowed; swap with _blank
115
+ $node->setAttribute( $attribute_name, '_blank' );
116
+ } else {
117
+ // only _blank is allowed
118
+ $node->removeAttribute( $attribute_name );
119
+ }
120
+ }
121
+ }
122
+
123
+ private function validate_a_node( $node ) {
124
+ // Get the href attribute
125
+ $href = $node->getAttribute( 'href' );
126
+
127
+ // If no href is set and this isn't an anchor, it's invalid
128
+ if ( empty( $href ) ) {
129
+ $name_attr = $node->getAttribute( 'name' );
130
+ if ( ! empty( $name_attr ) ) {
131
+ // No further validation is required
132
+ return true;
133
+ } else {
134
+ return false;
135
+ }
136
+ }
137
+
138
+ // If this is an anchor link, just return true
139
+ if ( 0 === strpos( $href, '#' ) ) {
140
+ return true;
141
+ }
142
+
143
+ // If the href starts with a '/', append the home_url to it for validation purposes.
144
+ if ( 0 === stripos( $href, '/' ) ) {
145
+ $href = untrailingslashit( get_home_url() ) . $href;
146
+ }
147
+
148
+ $valid_protocols = array( 'http', 'https', 'mailto', 'sms', 'tel', 'viber', 'whatsapp' );
149
+ $special_protocols = array( 'tel', 'sms' ); // these ones don't valid with `filter_var+FILTER_VALIDATE_URL`
150
+ $protocol = strtok( $href, ':' );
151
+
152
+ if ( false === filter_var( $href, FILTER_VALIDATE_URL )
153
+ && ! in_array( $protocol, $special_protocols ) ) {
154
+ return false;
155
+ }
156
+
157
+ if ( ! in_array( $protocol, $valid_protocols ) ) {
158
+ return false;
159
+ }
160
+
161
+ return true;
162
+ }
163
+
164
+ private function replace_node_with_children( $node, $bad_attributes, $bad_protocols ) {
165
+ // If the node has children and also has a parent node,
166
+ // clone and re-add all the children just before current node.
167
+ if ( $node->hasChildNodes() && $node->parentNode ) {
168
+ foreach ( $node->childNodes as $child_node ) {
169
+ $new_child = $child_node->cloneNode( true );
170
+ $this->strip_attributes_recursive( $new_child, $bad_attributes, $bad_protocols );
171
+ $node->parentNode->insertBefore( $new_child, $node );
172
+ }
173
+ }
174
+
175
+ // Remove the node from the parent, if defined.
176
+ if ( $node->parentNode ) {
177
+ $node->parentNode->removeChild( $node );
178
+ }
179
+ }
180
+
181
+ private function merge_defaults_with_args( $key, $values ) {
182
+ // Merge default values with user specified args
183
+ if ( ! empty( $this->args[ $key ] )
184
+ && is_array( $this->args[ $key ] ) ) {
185
+ $values = array_merge( $values, $this->args[ $key ] );
186
+ }
187
+
188
+ return $values;
189
+ }
190
+
191
+ private function get_blacklisted_protocols() {
192
+ return $this->merge_defaults_with_args( 'add_blacklisted_protocols', array(
193
+ 'javascript',
194
+ ) );
195
+ }
196
+
197
+ private function get_blacklisted_tags() {
198
+ return $this->merge_defaults_with_args( 'add_blacklisted_tags', array(
199
+ 'script',
200
+ 'noscript',
201
+ 'style',
202
+ 'frame',
203
+ 'frameset',
204
+ 'object',
205
+ 'param',
206
+ 'applet',
207
+ 'form',
208
+ 'label',
209
+ 'input',
210
+ 'textarea',
211
+ 'select',
212
+ 'option',
213
+ 'link',
214
+ 'picture',
215
+
216
+ // Sanitizers run after embed handlers, so if anything wasn't matched, it needs to be removed.
217
+ 'embed',
218
+ 'embedvideo',
219
+
220
+ // Other weird ones
221
+ 'comments-count',
222
+
223
+ // These are converted into amp-* versions
224
+ //'img',
225
+ //'video',
226
+ //'audio',
227
+ //'iframe',
228
+ ) );
229
+ }
230
+
231
+ private function get_blacklisted_attributes() {
232
+ return $this->merge_defaults_with_args( 'add_blacklisted_attributes', array(
233
+ 'style',
234
+ 'size',
235
+ 'clear',
236
+ 'align',
237
+ 'valign',
238
+ ) );
239
+ }
240
+ }
includes/vendor/amp/includes/sanitizers/class-amp-iframe-sanitizer.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
+
5
+ /**
6
+ * Converts <iframe> tags to <amp-iframe>
7
+ */
8
+ class AMP_Iframe_Sanitizer extends AMP_Base_Sanitizer {
9
+ const FALLBACK_HEIGHT = 400;
10
+ const SANDBOX_DEFAULTS = 'allow-scripts allow-same-origin';
11
+
12
+ public static $tag = 'iframe';
13
+
14
+ private static $script_slug = 'amp-iframe';
15
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
16
+
17
+ protected $DEFAULT_ARGS = array(
18
+ 'add_placeholder' => false,
19
+ );
20
+
21
+ public function get_scripts() {
22
+ if ( ! $this->did_convert_elements ) {
23
+ return array();
24
+ }
25
+
26
+ return array( self::$script_slug => self::$script_src );
27
+ }
28
+
29
+ public function sanitize() {
30
+ $nodes = $this->dom->getElementsByTagName( self::$tag );
31
+ $num_nodes = $nodes->length;
32
+ if ( 0 === $num_nodes ) {
33
+ return;
34
+ }
35
+
36
+ for ( $i = $num_nodes - 1; $i >= 0; $i-- ) {
37
+ $node = $nodes->item( $i );
38
+ $old_attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $node );
39
+
40
+ $new_attributes = $this->filter_attributes( $old_attributes );
41
+
42
+ // If the src doesn't exist, remove the node.
43
+ // This means that it never existed or was invalidated
44
+ // while filtering attributes above.
45
+ //
46
+ // TODO: add a filter to allow for a fallback element in this instance.
47
+ // See: https://github.com/ampproject/amphtml/issues/2261
48
+ if ( empty( $new_attributes['src'] ) ) {
49
+ $node->parentNode->removeChild( $node );
50
+ continue;
51
+ }
52
+
53
+ $this->did_convert_elements = true;
54
+
55
+ $new_attributes = $this->enforce_fixed_height( $new_attributes );
56
+ $new_attributes = $this->enforce_sizes_attribute( $new_attributes );
57
+
58
+ $new_node = AMP_DOM_Utils::create_node( $this->dom, 'amp-iframe', $new_attributes );
59
+
60
+ if ( true === $this->args['add_placeholder'] ) {
61
+ $placeholder_node = $this->build_placeholder( $new_attributes );
62
+ $new_node->appendChild( $placeholder_node );
63
+ }
64
+
65
+ $parent_node = $node->parentNode;
66
+ if ( 'p' === strtolower( $parent_node->tagName ) ) {
67
+ // AMP does not like iframes in p tags
68
+ $parent_node->removeChild( $node );
69
+ $parent_node->parentNode->insertBefore( $new_node, $parent_node->nextSibling );
70
+
71
+ if ( AMP_DOM_Utils::is_node_empty( $parent_node ) ) {
72
+ $parent_node->parentNode->removeChild( $parent_node );
73
+ }
74
+ } else {
75
+ $parent_node->replaceChild( $new_node, $node );
76
+ }
77
+ }
78
+ }
79
+
80
+ private function filter_attributes( $attributes ) {
81
+ $out = array();
82
+
83
+ foreach ( $attributes as $name => $value ) {
84
+ switch ( $name ) {
85
+ case 'sandbox':
86
+ case 'class':
87
+ case 'sizes':
88
+ $out[ $name ] = $value;
89
+ break;
90
+
91
+ case 'src':
92
+ $out[ $name ] = $this->maybe_enforce_https_src( $value, true );
93
+ break;
94
+
95
+ case 'width':
96
+ case 'height':
97
+ $out[ $name ] = $this->sanitize_dimension( $value, $name );
98
+ break;
99
+
100
+
101
+ case 'frameborder':
102
+ if ( '0' !== $value && '1' !== $value ) {
103
+ $value = '0';
104
+ }
105
+ $out[ $name ] = $value;
106
+ break;
107
+
108
+ case 'allowfullscreen':
109
+ case 'allowtransparency':
110
+ if ( 'false' !== $value ) {
111
+ $out[ $name ] = '';
112
+ }
113
+ break;
114
+
115
+ default;
116
+ break;
117
+ }
118
+ }
119
+
120
+ if ( ! isset( $out[ 'sandbox' ] ) ) {
121
+ $out[ 'sandbox' ] = self::SANDBOX_DEFAULTS;
122
+ }
123
+
124
+ return $out;
125
+ }
126
+
127
+ private function build_placeholder( $parent_attributes ) {
128
+ $placeholder_node = AMP_DOM_Utils::create_node( $this->dom, 'div', array(
129
+ 'placeholder' => '',
130
+ 'class' => 'amp-wp-iframe-placeholder',
131
+ ) );
132
+
133
+ return $placeholder_node;
134
+ }
135
+ }
includes/vendor/amp/includes/sanitizers/class-amp-img-sanitizer.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
+ require_once( AMP__DIR__ . '/includes/utils/class-amp-image-dimension-extractor.php' );
5
+
6
+ /**
7
+ * Converts <img> tags to <amp-img> or <amp-anim>
8
+ */
9
+ class AMP_Img_Sanitizer extends AMP_Base_Sanitizer {
10
+ const FALLBACK_WIDTH = 600;
11
+ const FALLBACK_HEIGHT = 400;
12
+
13
+ public static $tag = 'img';
14
+
15
+ private static $anim_extension = '.gif';
16
+
17
+ private static $script_slug = 'amp-anim';
18
+ private static $script_src = 'https://cdn.ampproject.org/v0/amp-anim-0.1.js';
19
+
20
+ public function sanitize() {
21
+ $nodes = $this->dom->getElementsByTagName( self::$tag );
22
+ $num_nodes = $nodes->length;
23
+ if ( 0 === $num_nodes ) {
24
+ return;
25
+ }
26
+
27
+ for ( $i = $num_nodes - 1; $i >= 0; $i-- ) {
28
+ $node = $nodes->item( $i );
29
+ $old_attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $node );
30
+
31
+ if ( empty( $old_attributes['src'] ) ) {
32
+ $node->parentNode->removeChild( $node );
33
+ continue;
34
+ }
35
+
36
+ $new_attributes = $this->filter_attributes( $old_attributes );
37
+
38
+ // Try to extract dimensions for the image, if not set.
39
+ if ( ! isset( $new_attributes['width'] ) || ! isset( $new_attributes['height'] ) ) {
40
+ $dimensions = AMP_Image_Dimension_Extractor::extract( $new_attributes['src'] );
41
+ if ( is_array( $dimensions ) ) {
42
+ $new_attributes['width'] = $dimensions[0];
43
+ $new_attributes['height'] = $dimensions[1];
44
+ }
45
+ }
46
+
47
+ // Final fallback when we have no dimensions.
48
+ if ( ! isset( $new_attributes['width'] ) || ! isset( $new_attributes['height'] ) ) {
49
+ $new_attributes['width'] = isset( $this->args['content_max_width'] ) ? $this->args['content_max_width'] : self::FALLBACK_WIDTH;
50
+ $new_attributes['height'] = self::FALLBACK_HEIGHT;
51
+
52
+ $this->add_or_append_attribute( $new_attributes, 'class', 'amp-wp-unknown-size' );
53
+ }
54
+
55
+ $new_attributes = $this->enforce_sizes_attribute( $new_attributes );
56
+
57
+ if ( $this->is_gif_url( $new_attributes['src'] ) ) {
58
+ $this->did_convert_elements = true;
59
+ $new_tag = 'amp-anim';
60
+ } else {
61
+ $new_tag = 'amp-img';
62
+ }
63
+
64
+ $new_node = AMP_DOM_Utils::create_node( $this->dom, $new_tag, $new_attributes );
65
+ $node->parentNode->replaceChild( $new_node, $node );
66
+ }
67
+ }
68
+
69
+ public function get_scripts() {
70
+ if ( ! $this->did_convert_elements ) {
71
+ return array();
72
+ }
73
+
74
+ return array( self::$script_slug => self::$script_src );
75
+ }
76
+
77
+ private function filter_attributes( $attributes ) {
78
+ $out = array();
79
+
80
+ foreach ( $attributes as $name => $value ) {
81
+ switch ( $name ) {
82
+ case 'src':
83
+ case 'alt':
84
+ case 'class':
85
+ case 'srcset':
86
+ case 'sizes':
87
+ case 'on':
88
+ $out[ $name ] = $value;
89
+ break;
90
+
91
+ case 'width':
92
+ case 'height':
93
+ $out[ $name ] = $this->sanitize_dimension( $value, $name );
94
+ break;
95
+
96
+ default;
97
+ break;
98
+ }
99
+ }
100
+
101
+ return $out;
102
+ }
103
+
104
+ private function is_gif_url( $url ) {
105
+ $ext = self::$anim_extension;
106
+ $path = parse_url( $url, PHP_URL_PATH );
107
+ return $ext === substr( $path, -strlen( $ext ) );
108
+ }
109
+ }
includes/vendor/amp/includes/sanitizers/class-amp-style-sanitizer.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
+
5
+ /**
6
+ * Collects inline styles and outputs them in the amp-custom stylesheet.
7
+ */
8
+ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
9
+ private $styles = array();
10
+
11
+ public function get_styles() {
12
+ return $this->styles;
13
+ }
14
+
15
+ public function sanitize() {
16
+ $body = $this->get_body_node();
17
+ $this->collect_styles_recursive( $body );
18
+ }
19
+
20
+ private function collect_styles_recursive( $node ) {
21
+ if ( $node->nodeType !== XML_ELEMENT_NODE ) {
22
+ return;
23
+ }
24
+
25
+ if ( $node->hasAttributes() && $node instanceof DOMElement ) {
26
+ $style = $node->getAttribute( 'style' );
27
+ $class = $node->getAttribute( 'class' );
28
+
29
+ if ( $style ) {
30
+ $style = $this->process_style( $style );
31
+ if ( ! empty( $style ) ) {
32
+ $class_name = $this->generate_class_name( $style );
33
+ $new_class = trim( $class . ' ' . $class_name );
34
+
35
+ $node->setAttribute( 'class', $new_class );
36
+ $this->styles[ '.' . $class_name ] = $style;
37
+ }
38
+
39
+ $node->removeAttribute( 'style' );
40
+ }
41
+ }
42
+
43
+ $length = $node->childNodes->length;
44
+ for ( $i = $length - 1; $i >= 0; $i -- ) {
45
+ $child_node = $node->childNodes->item( $i );
46
+
47
+ $this->collect_styles_recursive( $child_node );
48
+ }
49
+ }
50
+
51
+ private function process_style( $string ) {
52
+ // Filter properties
53
+ $string = safecss_filter_attr( esc_html( $string ) );
54
+
55
+ if ( ! $string ) {
56
+ return array();
57
+ }
58
+
59
+ // Normalize order
60
+ $styles = array_map( 'trim', explode( ';', $string ) );
61
+ sort( $styles );
62
+
63
+ $processed_styles = array();
64
+
65
+ // Normalize whitespace and filter rules
66
+ foreach ( $styles as $index => $rule ) {
67
+ $arr2 = array_map( 'trim', explode( ':', $rule, 2 ) );
68
+ if ( 2 !== count( $arr2 ) ) {
69
+ continue;
70
+ }
71
+
72
+ list( $property, $value ) = $this->filter_style( $arr2[0], $arr2[1] );
73
+ if ( empty( $property ) || empty( $value ) ) {
74
+ continue;
75
+ }
76
+
77
+ $processed_styles[ $index ] = $property . ':' . $value;
78
+ }
79
+
80
+ return $processed_styles;
81
+ }
82
+
83
+ private function filter_style( $property, $value ) {
84
+ // Handle overflow rule
85
+ // https://www.ampproject.org/docs/reference/spec.html#properties
86
+ if ( 0 === strpos( $property, 'overflow' )
87
+ && ( false !== strpos( $value, 'auto' ) || false !== strpos( $value, 'scroll' ) )
88
+ ) {
89
+ return false;
90
+ }
91
+
92
+ if ( 'width' === $property ) {
93
+ $property = 'max-width';
94
+ }
95
+
96
+ // !important is not allowed
97
+ if ( false !== strpos( $value, 'important' ) ) {
98
+ $value = preg_replace( '/\s*\!\s*important$/', '', $value );
99
+ }
100
+
101
+ return array( $property, $value );
102
+ }
103
+
104
+ private function generate_class_name( $data ) {
105
+ $string = maybe_serialize( $data );
106
+ return 'amp-wp-inline-' . md5( $string );
107
+ }
108
+ }
includes/vendor/amp/includes/sanitizers/class-amp-video-sanitizer.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
+
5
+ /**
6
+ * Converts <video> tags to <amp-video>
7
+ */
8
+ class AMP_Video_Sanitizer extends AMP_Base_Sanitizer {
9
+ const FALLBACK_HEIGHT = 400;
10
+
11
+ public static $tag = 'video';
12
+
13
+ public function sanitize() {
14
+ $nodes = $this->dom->getElementsByTagName( self::$tag );
15
+ $num_nodes = $nodes->length;
16
+ if ( 0 === $num_nodes ) {
17
+ return;
18
+ }
19
+
20
+ for ( $i = $num_nodes - 1; $i >= 0; $i-- ) {
21
+ $node = $nodes->item( $i );
22
+ $old_attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $node );
23
+
24
+ $new_attributes = $this->filter_attributes( $old_attributes );
25
+
26
+ $new_attributes = $this->enforce_fixed_height( $new_attributes );
27
+ $new_attributes = $this->enforce_sizes_attribute( $new_attributes );
28
+
29
+ $new_node = AMP_DOM_Utils::create_node( $this->dom, 'amp-video', $new_attributes );
30
+
31
+ // TODO: `source` does not have closing tag, and DOMDocument doesn't handle it well.
32
+ foreach ( $node->childNodes as $child_node ) {
33
+ $new_child_node = $child_node->cloneNode( true );
34
+ $old_child_attributes = AMP_DOM_Utils::get_node_attributes_as_assoc_array( $new_child_node );
35
+ $new_child_attributes = $this->filter_attributes( $old_child_attributes );
36
+
37
+ // Only append source tags with a valid src attribute
38
+ if ( ! empty( $new_child_attributes['src'] ) && 'source' === $new_child_node->tagName ) {
39
+ $new_node->appendChild( $new_child_node );
40
+ }
41
+ }
42
+
43
+ // If the node has at least one valid source, replace the old node with it.
44
+ // Otherwise, just remove the node.
45
+ //
46
+ // TODO: Add a fallback handler.
47
+ // See: https://github.com/ampproject/amphtml/issues/2261
48
+ if ( 0 === $new_node->childNodes->length && empty( $new_attributes['src'] ) ) {
49
+ $node->parentNode->removeChild( $node );
50
+ } else {
51
+ $node->parentNode->replaceChild( $new_node, $node );
52
+ }
53
+ }
54
+ }
55
+
56
+ private function filter_attributes( $attributes ) {
57
+ $out = array();
58
+
59
+ foreach ( $attributes as $name => $value ) {
60
+ switch ( $name ) {
61
+ case 'src':
62
+ $out[ $name ] = $this->maybe_enforce_https_src( $value );
63
+ break;
64
+
65
+ case 'width':
66
+ case 'height':
67
+ $out[ $name ] = $this->sanitize_dimension( $value, $name );
68
+ break;
69
+
70
+ case 'poster':
71
+ case 'class':
72
+ case 'sizes':
73
+ $out[ $name ] = $value;
74
+ break;
75
+
76
+ case 'controls':
77
+ case 'loop':
78
+ case 'muted':
79
+ case 'autoplay':
80
+ if ( 'false' !== $value ) {
81
+ $out[ $name ] = '';
82
+ }
83
+ break;
84
+
85
+ default;
86
+ break;
87
+ }
88
+ }
89
+
90
+ return $out;
91
+ }
92
+ }
includes/vendor/amp/includes/settings/class-amp-customizer-design-settings.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AMP_Customizer_Design_Settings {
4
+ const DEFAULT_HEADER_COLOR = '#fff';
5
+ const DEFAULT_HEADER_BACKGROUND_COLOR = '#0a89c0';
6
+ const DEFAULT_COLOR_SCHEME = 'light';
7
+
8
+ public static function init() {
9
+ add_action( 'amp_customizer_init', array( __CLASS__, 'init_customizer' ) );
10
+
11
+ add_filter( 'amp_customizer_get_settings', array( __CLASS__, 'append_settings' ) );
12
+ }
13
+
14
+ public static function init_customizer() {
15
+ add_action( 'amp_customizer_register_settings', array( __CLASS__, 'register_customizer_settings' ) );
16
+ add_action( 'amp_customizer_register_ui', array( __CLASS__, 'register_customizer_ui' ) );
17
+ add_action( 'amp_customizer_enqueue_preview_scripts', array( __CLASS__, 'enqueue_customizer_preview_scripts' ) );
18
+ }
19
+
20
+ public static function register_customizer_settings( $wp_customize ) {
21
+ // Header text color setting
22
+ $wp_customize->add_setting( 'amp_customizer[header_color]', array(
23
+ 'type' => 'option',
24
+ 'default' => self::DEFAULT_HEADER_COLOR,
25
+ 'sanitize_callback' => 'sanitize_hex_color',
26
+ 'transport' => 'postMessage'
27
+ ) );
28
+
29
+ // Header background color
30
+ $wp_customize->add_setting( 'amp_customizer[header_background_color]', array(
31
+ 'type' => 'option',
32
+ 'default' => self::DEFAULT_HEADER_BACKGROUND_COLOR,
33
+ 'sanitize_callback' => 'sanitize_hex_color',
34
+ 'transport' => 'postMessage'
35
+ ) );
36
+
37
+ // Background color scheme
38
+ $wp_customize->add_setting( 'amp_customizer[color_scheme]', array(
39
+ 'type' => 'option',
40
+ 'default' => self::DEFAULT_COLOR_SCHEME,
41
+ 'sanitize_callback' => array( __CLASS__ , 'sanitize_color_scheme' ),
42
+ 'transport' => 'postMessage'
43
+ ) );
44
+ }
45
+
46
+ public function register_customizer_ui( $wp_customize ) {
47
+ $wp_customize->add_section( 'amp_design', array(
48
+ 'title' => __( 'Design', 'amp' ),
49
+ 'panel' => AMP_Template_Customizer::PANEL_ID,
50
+ ) );
51
+
52
+ // Header text color control.
53
+ $wp_customize->add_control(
54
+ new WP_Customize_Color_Control( $wp_customize, 'amp_header_color', array(
55
+ 'settings' => 'amp_customizer[header_color]',
56
+ 'label' => __( 'Header Text Color', 'amp' ),
57
+ 'section' => 'amp_design',
58
+ 'priority' => 10
59
+ ) )
60
+ );
61
+
62
+ // Header background color control.
63
+ $wp_customize->add_control(
64
+ new WP_Customize_Color_Control( $wp_customize, 'amp_header_background_color', array(
65
+ 'settings' => 'amp_customizer[header_background_color]',
66
+ 'label' => __( 'Header Background & Link Color', 'amp' ),
67
+ 'section' => 'amp_design',
68
+ 'priority' => 20
69
+ ) )
70
+ );
71
+
72
+ // Background color scheme
73
+ $wp_customize->add_control( 'amp_color_scheme', array(
74
+ 'settings' => 'amp_customizer[color_scheme]',
75
+ 'label' => __( 'Color Scheme', 'amp' ),
76
+ 'section' => 'amp_design',
77
+ 'type' => 'radio',
78
+ 'priority' => 30,
79
+ 'choices' => self::get_color_scheme_names(),
80
+ ));
81
+ }
82
+
83
+ public static function enqueue_customizer_preview_scripts() {
84
+ wp_enqueue_script(
85
+ 'amp-customizer-design-preview',
86
+ amp_get_asset_url( 'js/amp-customizer-design-preview.js' ),
87
+ array( 'amp-customizer' ),
88
+ false,
89
+ true
90
+ );
91
+ wp_localize_script( 'amp-customizer-design-preview', 'amp_customizer_design', array(
92
+ 'color_schemes' => self::get_color_schemes(),
93
+ ) );
94
+ }
95
+
96
+ public static function append_settings( $settings ) {
97
+ $settings = wp_parse_args( $settings, array(
98
+ 'header_color' => self::DEFAULT_HEADER_COLOR,
99
+ 'header_background_color' => self::DEFAULT_HEADER_BACKGROUND_COLOR,
100
+ 'color_scheme' => self::DEFAULT_COLOR_SCHEME,
101
+ ) );
102
+
103
+ $theme_colors = self::get_colors_for_color_scheme( $settings['color_scheme'] );
104
+
105
+ return array_merge( $settings, $theme_colors, array(
106
+ 'link_color' => $settings['header_background_color'],
107
+ ) );
108
+ }
109
+
110
+ protected static function get_color_scheme_names() {
111
+ return array(
112
+ 'light' => __( 'Light', 'amp'),
113
+ 'dark' => __( 'Dark', 'amp' ),
114
+ );
115
+ }
116
+
117
+ protected static function get_color_schemes() {
118
+ return array(
119
+ 'light' => array(
120
+ // Convert colors to greyscale for light theme color; see http://goo.gl/2gDLsp
121
+ 'theme_color' => '#fff',
122
+ 'text_color' => '#353535',
123
+ 'muted_text_color' => '#696969',
124
+ 'border_color' => '#c2c2c2',
125
+ ),
126
+ 'dark' => array(
127
+ // Convert and invert colors to greyscale for dark theme color; see http://goo.gl/uVB2cO
128
+ 'theme_color' => '#0a0a0a',
129
+ 'text_color' => '#dedede',
130
+ 'muted_text_color' => '#b1b1b1',
131
+ 'border_color' => '#707070',
132
+ )
133
+ );
134
+ }
135
+
136
+ protected static function get_colors_for_color_scheme( $scheme ) {
137
+ $color_schemes = self::get_color_schemes();
138
+
139
+ if ( isset( $color_schemes[ $scheme ] ) ) {
140
+ return $color_schemes[ $scheme ];
141
+ }
142
+
143
+ return $color_schemes[ self::DEFAULT_COLOR_SCHEME ];
144
+ }
145
+
146
+ public static function sanitize_color_scheme( $value ) {
147
+ $schemes = self::get_color_scheme_names();
148
+ $scheme_slugs = array_keys( $schemes );
149
+
150
+ if ( ! in_array( $value, $scheme_slugs ) ) {
151
+ $value = self::DEFAULT_COLOR_SCHEME;
152
+ }
153
+
154
+ return $value;
155
+ }
156
+ }
includes/vendor/amp/includes/settings/class-amp-customizer-settings.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AMP_Customizer_Settings {
4
+ private static function get_stored_options() {
5
+ return get_option( 'amp_customizer', array() );
6
+ }
7
+
8
+ public static function get_settings() {
9
+ $settings = self::get_stored_options();
10
+
11
+ return apply_filters( 'amp_customizer_get_settings', $settings );
12
+ }
13
+ }
includes/vendor/amp/includes/utils/class-amp-dom-utils.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AMP_DOM_Utils {
4
+ public static function get_dom_from_content( $content ) {
5
+ $libxml_previous_state = libxml_use_internal_errors( true );
6
+
7
+ $dom = new DOMDocument;
8
+ // Wrap in dummy tags, since XML needs one parent node.
9
+ // It also makes it easier to loop through nodes.
10
+ // We can later use this to extract our nodes.
11
+ // Add utf-8 charset so loadHTML does not have problems parsing it. See: http://php.net/manual/en/domdocument.loadhtml.php#78243
12
+ $result = $dom->loadHTML( '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' . $content . '</body></html>' );
13
+
14
+ libxml_clear_errors();
15
+ libxml_use_internal_errors( $libxml_previous_state );
16
+
17
+ if ( ! $result ) {
18
+ return false;
19
+ }
20
+
21
+ return $dom;
22
+ }
23
+
24
+ public static function get_content_from_dom( $dom ) {
25
+ // Only want children of the body tag, since we have a subset of HTML.
26
+ $out = '';
27
+ $body = $dom->getElementsByTagName( 'body' )->item( 0 );
28
+
29
+ // AMP elements always need closing tags.
30
+ // To force them, we can't use saveHTML (node support is 5.3+) and LIBXML_NOEMPTYTAG results in issues with self-closing tags like `br` and `hr`.
31
+ // So, we're manually forcing closing tags.
32
+ self::recursive_force_closing_tags( $dom, $body );
33
+
34
+ foreach ( $body->childNodes as $node ) {
35
+ $out .= $dom->saveXML( $node );
36
+ }
37
+ return $out;
38
+ }
39
+
40
+ public static function create_node( $dom, $tag, $attributes ) {
41
+ $node = $dom->createElement( $tag );
42
+ self::add_attributes_to_node( $node, $attributes );
43
+ return $node;
44
+ }
45
+
46
+ public static function get_node_attributes_as_assoc_array( $node ) {
47
+ $attributes = array();
48
+ if ( ! $node->hasAttributes() ) {
49
+ return $attributes;
50
+ }
51
+
52
+ foreach ( $node->attributes as $attribute ) {
53
+ $attributes[ $attribute->nodeName ] = $attribute->nodeValue;
54
+ }
55
+ return $attributes;
56
+ }
57
+
58
+ public static function add_attributes_to_node( $node, $attributes ) {
59
+ foreach ( $attributes as $name => $value ) {
60
+ $node->setAttribute( $name, $value );
61
+ }
62
+ }
63
+
64
+ public static function is_node_empty( $node ) {
65
+ return false === $node->hasChildNodes()
66
+ && empty( $node->textContent );
67
+ }
68
+
69
+ public static function recursive_force_closing_tags( $dom, $node ) {
70
+ if ( XML_ELEMENT_NODE !== $node->nodeType ) {
71
+ return;
72
+ }
73
+
74
+ if ( self::is_self_closing_tag( $node->nodeName ) ) {
75
+ return;
76
+ }
77
+
78
+ if ( self::is_node_empty( $node ) ) {
79
+ $text_node = $dom->createTextNode( '' );
80
+ $node->appendChild( $text_node );
81
+ return;
82
+ }
83
+
84
+ $num_children = $node->childNodes->length;
85
+ for ( $i = $num_children - 1; $i >= 0; $i-- ) {
86
+ $child = $node->childNodes->item( $i );
87
+ self::recursive_force_closing_tags( $dom, $child );
88
+ }
89
+ }
90
+
91
+ private static function is_self_closing_tag( $tag ) {
92
+ // This function is called a lot; the static var prevents having to re-create the array every time.
93
+ static $self_closing_tags;
94
+ if ( ! isset( $self_closing_tags ) ) {
95
+ // https://www.w3.org/TR/html5/syntax.html#serializing-html-fragments
96
+ // Not all are valid AMP, but we include them for completeness.
97
+ $self_closing_tags = array(
98
+ 'area', 'base', 'basefont', 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr',
99
+ );
100
+ }
101
+
102
+ return in_array( $tag, $self_closing_tags );
103
+ }
104
+ }
includes/vendor/amp/includes/utils/class-amp-html-utils.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AMP_HTML_Utils {
4
+ public static function build_tag( $tag_name, $attributes = array(), $content = '' ) {
5
+ $attr_string = self::build_attributes_string( $attributes );
6
+ return sprintf( '<%1$s %2$s>%3$s</%1$s>', sanitize_key( $tag_name ), $attr_string, $content );
7
+ }
8
+
9
+ public static function build_attributes_string( $attributes ) {
10
+ $string = array();
11
+ foreach ( $attributes as $name => $value ) {
12
+ if ( '' === $value ) {
13
+ $string[] = sprintf( '%s', sanitize_key( $name ) );
14
+ } else {
15
+ $string[] = sprintf( '%s="%s"', sanitize_key( $name ), esc_attr( $value ) );
16
+ }
17
+ }
18
+ return implode( ' ', $string );
19
+ }
20
+ }
includes/vendor/amp/includes/utils/class-amp-image-dimension-extractor.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AMP_Image_Dimension_Extractor {
4
+ static $callbacks_registered = false;
5
+
6
+ static public function extract( $url ) {
7
+ if ( ! self::$callbacks_registered ) {
8
+ self::register_callbacks();
9
+ }
10
+
11
+ $url = self::normalize_url( $url );
12
+ if ( false === $url ) {
13
+ return false;
14
+ }
15
+
16
+ return apply_filters( 'amp_extract_image_dimensions', false, $url );
17
+ }
18
+
19
+ public static function normalize_url( $url ) {
20
+ if ( empty( $url ) ) {
21
+ return false;
22
+ }
23
+
24
+ if ( 0 === strpos( $url, 'data:' ) ) {
25
+ return false;
26
+ }
27
+
28
+ if ( 0 === strpos( $url, '//' ) ) {
29
+ return set_url_scheme( $url, 'http' );
30
+ }
31
+
32
+ $parsed = parse_url( $url );
33
+ if ( ! isset( $parsed['host'] ) ) {
34
+ $path = '';
35
+ if ( isset( $parsed['path'] ) ) {
36
+ $path .= $parsed['path'];
37
+ }
38
+ if ( isset( $parsed['query'] ) ) {
39
+ $path .= '?' . $parsed['query'];
40
+ }
41
+ $url = site_url( $path );
42
+ }
43
+
44
+ return $url;
45
+ }
46
+
47
+ private static function register_callbacks() {
48
+ self::$callbacks_registered = true;
49
+
50
+ add_filter( 'amp_extract_image_dimensions', array( __CLASS__, 'extract_from_attachment_metadata' ), 10, 2 );
51
+ add_filter( 'amp_extract_image_dimensions', array( __CLASS__, 'extract_by_downloading_image' ), 999, 2 ); // Run really late since this is our last resort
52
+
53
+ do_action( 'amp_extract_image_dimensions_callbacks_registered' );
54
+ }
55
+
56
+ public static function extract_from_attachment_metadata( $dimensions, $url ) {
57
+ if ( is_array( $dimensions ) ) {
58
+ return $dimensions;
59
+ }
60
+
61
+ $url = strtok( $url, '?' );
62
+ $attachment_id = attachment_url_to_postid( $url );
63
+ if ( empty( $attachment_id ) ) {
64
+ return false;
65
+ }
66
+
67
+ $metadata = wp_get_attachment_metadata( $attachment_id );
68
+ if ( ! $metadata ) {
69
+ return false;
70
+ }
71
+
72
+ return array( $metadata['width'], $metadata['height'] );
73
+ }
74
+
75
+ public static function extract_by_downloading_image( $dimensions, $url ) {
76
+ if ( is_array( $dimensions ) ) {
77
+ return $dimensions;
78
+ }
79
+
80
+ $url_hash = md5( $url );
81
+ $transient_name = sprintf( 'amp_img_%s', $url_hash );
82
+ $transient_expiry = 30 * DAY_IN_SECONDS;
83
+ $transient_fail = 'fail';
84
+
85
+ $dimensions = get_transient( $transient_name );
86
+
87
+ if ( is_array( $dimensions ) ) {
88
+ return $dimensions;
89
+ } elseif ( $transient_fail === $dimensions ) {
90
+ return false;
91
+ }
92
+
93
+ // Very simple lock to prevent stampedes
94
+ $transient_lock_name = sprintf( 'amp_lock_%s', $url_hash );
95
+ if ( false !== get_transient( $transient_lock_name ) ) {
96
+ return false;
97
+ }
98
+ set_transient( $transient_lock_name, 1, MINUTE_IN_SECONDS );
99
+
100
+ // Note to other developers: please don't use this class directly as it may not stick around forever...
101
+ if ( ! class_exists( 'FastImage' ) ) {
102
+ require_once( AMP__DIR__ . '/includes/lib/class-fastimage.php' );
103
+ }
104
+
105
+ // TODO: look into using curl+stream (https://github.com/willwashburn/FasterImage)
106
+ $image = new FastImage( $url );
107
+ $dimensions = $image->getSize();
108
+
109
+ if ( ! is_array( $dimensions ) ) {
110
+ set_transient( $transient_name, $transient_fail, $transient_expiry );
111
+ delete_transient( $transient_lock_name );
112
+ return false;
113
+ }
114
+
115
+ set_transient( $transient_name, $dimensions, $transient_expiry );
116
+ delete_transient( $transient_lock_name );
117
+ return $dimensions;
118
+ }
119
+ }
includes/vendor/amp/includes/utils/class-amp-string-utils.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AMP_String_Utils {
4
+ public static function endswith( $haystack, $needle ) {
5
+ return '' !== $haystack
6
+ && '' !== $needle
7
+ && $needle === substr( $haystack, -strlen( $needle ) );
8
+ }
9
+ }
includes/vendor/amp/jetpack-helper.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Jetpack bits.
4
+
5
+ add_action( 'pre_amp_render_post', 'amp_jetpack_mods' );
6
+
7
+ /**
8
+ * Disable Jetpack features that are not compatible with AMP.
9
+ *
10
+ **/
11
+ function amp_jetpack_mods() {
12
+ if ( Jetpack::is_module_active( 'stats' ) ) {
13
+ add_action( 'amp_post_template_footer', 'jetpack_amp_add_stats_pixel' );
14
+ }
15
+ amp_jetpack_disable_sharing();
16
+ amp_jetpack_disable_related_posts();
17
+ }
18
+
19
+ function amp_jetpack_disable_sharing() {
20
+ add_filter( 'sharing_show', '__return_false', 100 );
21
+ }
22
+
23
+ /**
24
+ * Remove the Related Posts placeholder and headline that gets hooked into the_content
25
+ *
26
+ * That placeholder is useless since we can't ouput, and don't want to output Related Posts in AMP.
27
+ *
28
+ **/
29
+ function amp_jetpack_disable_related_posts() {
30
+ if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
31
+ $jprp = Jetpack_RelatedPosts::init();
32
+ remove_filter( 'the_content', array( $jprp, 'filter_add_target_to_dom' ), 40 );
33
+ }
34
+ }
35
+
36
+ function jetpack_amp_add_stats_pixel( $amp_template ) {
37
+ if ( ! has_action( 'wp_footer', 'stats_footer' ) ) {
38
+ return;
39
+ }
40
+ ?>
41
+ <amp-pixel src="<?php echo esc_url( jetpack_amp_build_stats_pixel_url() ); ?>"></amp-pixel>
42
+ <?php
43
+ }
44
+
45
+ /**
46
+ * Generate the stats pixel.
47
+ *
48
+ * Looks something like:
49
+ * https://pixel.wp.com/g.gif?v=ext&j=1%3A3.9.1&blog=1234&post=5678&tz=-4&srv=example.com&host=example.com&ref=&rand=0.4107963021218808
50
+ */
51
+ function jetpack_amp_build_stats_pixel_url() {
52
+ global $wp_the_query;
53
+ if ( function_exists( 'stats_build_view_data' ) ) { // added in https://github.com/Automattic/jetpack/pull/3445
54
+ $data = stats_build_view_data();
55
+ } else {
56
+ $blog = Jetpack_Options::get_option( 'id' );
57
+ $tz = get_option( 'gmt_offset' );
58
+ $v = 'ext';
59
+ $blog_url = parse_url( site_url() );
60
+ $srv = $blog_url['host'];
61
+ $j = sprintf( '%s:%s', JETPACK__API_VERSION, JETPACK__VERSION );
62
+ $post = $wp_the_query->get_queried_object_id();
63
+ $data = compact( 'v', 'j', 'blog', 'post', 'tz', 'srv' );
64
+ }
65
+
66
+ $data['host'] = rawurlencode( $_SERVER['HTTP_HOST'] );
67
+ $data['rand'] = 'RANDOM'; // amp placeholder
68
+ $data['ref'] = 'DOCUMENT_REFERRER'; // amp placeholder
69
+ $data = array_map( 'rawurlencode' , $data );
70
+ return add_query_arg( $data, 'https://pixel.wp.com/g.gif' );
71
+ }
includes/vendor/amp/readme.md ADDED
@@ -0,0 +1,591 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AMP for WordPress
2
+
3
+ ## Overview
4
+
5
+ This plugin adds support for the [Accelerated Mobile Pages](https://www.ampproject.org) (AMP) Project, which is an open source initiative that aims to provide mobile optimized content that can load instantly everywhere.
6
+
7
+ With the plugin active, all posts on your site will have dynamically generated AMP-compatible versions, accessible by appending `/amp/` to the end your post URLs. For example, if your post URL is `http://example.com/2016/01/01/amp-on/`, you can access the AMP version at `http://example.com/2016/01/01/amp-on/amp/`. If you do not have [pretty permalinks](https://codex.wordpress.org/Using_Permalinks#mod_rewrite:_.22Pretty_Permalinks.22) enabled, you can do the same thing by appending `?amp=1`, i.e. `http://example.com/2016/01/01/amp-on/?amp=1`
8
+
9
+ Note #1: that Pages and archives are not currently supported.
10
+
11
+ Note #2: this plugin only creates AMP content but does not automatically display it to your users when they visit from a mobile device. That is handled by AMP consumers such as Google Search. For more details, see the [AMP Project FAQ](https://www.ampproject.org/docs/support/faqs.html).
12
+
13
+ ## Customization / Templating
14
+
15
+ The plugin ships with a default template that looks nice and clean and we tried to find a good balance between ease and extensibility when it comes to customization.
16
+
17
+ You can tweak small pieces of the template or the entire thing depending on your needs.
18
+
19
+ ### Where Do I Put My Code?
20
+
21
+ The code snippets below and any other code-level customizations should happen in one of the following locations.
22
+
23
+ If you're using an off-the-shelf theme (like from the WordPress.org Theme Directory):
24
+
25
+ - A [child theme](https://developer.wordpress.org/themes/advanced-topics/child-themes/).
26
+ - A custom plugin that you activate via the Dashboard.
27
+ - A [mu-plugin](https://codex.wordpress.org/Must_Use_Plugins).
28
+
29
+ If you're using a custom theme:
30
+
31
+ - `functions.php` (or via a 'require' call to files that load from `functions.php`).
32
+ - Any of the options above.
33
+
34
+ ### Theme Mods
35
+
36
+ The default template will attempt to draw from various theme mods, such as site icon, if supported by the active theme.
37
+
38
+ #### Site Icon
39
+
40
+ If you add a site icon, we will automatically replace the WordPress logo in the template.
41
+
42
+ If you'd prefer to do it via code:
43
+
44
+ ```php
45
+ add_filter( 'amp_post_template_data', 'xyz_amp_set_site_icon_url' );
46
+
47
+ function xyz_amp_set_site_icon_url( $data ) {
48
+ // Ideally a 32x32 image
49
+ $data[ 'site_icon_url' ] = get_stylesheet_directory_uri() . '/images/amp-site-icon.png';
50
+ return $data;
51
+ }
52
+ ```
53
+
54
+ #### Logo Only
55
+
56
+ If you want to hide the site text and just show a logo, use the `amp_post_template_css` action. The following colours the title bar black, hides the site title, and replaces it with a centered logo:
57
+
58
+ ```
59
+ add_action( 'amp_post_template_css', 'xyz_amp_additional_css_styles' );
60
+
61
+ function xyz_amp_additional_css_styles( $amp_template ) {
62
+ // only CSS here please...
63
+ ?>
64
+ nav.amp-wp-title-bar {
65
+ padding: 12px 0;
66
+ background: #000;
67
+ }
68
+ nav.amp-wp-title-bar a {
69
+ background-image: url( 'https://example.com/path/to/logo.png' );
70
+ background-repeat: no-repeat;
71
+ background-size: contain;
72
+ display: block;
73
+ height: 28px;
74
+ width: 94px;
75
+ margin: 0 auto;
76
+ text-indent: -9999px;
77
+ }
78
+ <?php
79
+ }
80
+ ```
81
+
82
+ Note: you will need to adjust the colours and sizes based on your brand.
83
+
84
+ ### Template Tweaks
85
+
86
+ You can tweak various parts of the template via code.
87
+
88
+ #### Featured Image
89
+
90
+ The default template does not display the featured image currently. There are many ways to add it, such as the snippet below:
91
+
92
+ ```php
93
+ add_action( 'pre_amp_render_post', 'xyz_amp_add_custom_actions' );
94
+ function xyz_amp_add_custom_actions() {
95
+ add_filter( 'the_content', 'xyz_amp_add_featured_image' );
96
+ }
97
+
98
+ function xyz_amp_add_featured_image( $content ) {
99
+ if ( has_post_thumbnail() ) {
100
+ // Just add the raw <img /> tag; our sanitizer will take care of it later.
101
+ $image = sprintf( '<p class="xyz-featured-image">%s</p>', get_the_post_thumbnail() );
102
+ $content = $image . $content;
103
+ }
104
+ return $content;
105
+ }
106
+ ```
107
+
108
+ #### Content Width
109
+
110
+ By default, your theme's `$content_width` value will be used to determine the size of the `amp` content well. You can change this:
111
+
112
+ ```php
113
+ add_filter( 'amp_content_max_width', 'xyz_amp_change_content_width' );
114
+
115
+ function xyz_amp_change_content_width( $content_max_width ) {
116
+ return 1200;
117
+ }
118
+ ```
119
+
120
+ #### Template Data
121
+
122
+ Use the `amp_post_template_data` filter to override default template data. The following changes the placeholder image used for iframes to a file located in the current theme:
123
+
124
+ ```php
125
+ add_filter( 'amp_post_template_data', 'xyz_amp_set_custom_placeholder_image' );
126
+
127
+ function xyz_set_custom_placeholder_image( $data ) {
128
+ $data[ 'placeholder_image_url' ] = get_stylesheet_directory_uri() . '/images/amp-iframe-placeholder.png';
129
+ return $data;
130
+ }
131
+ ```
132
+
133
+ Note: The path must pass the default criteria set out by [`validate_file`](https://developer.wordpress.org/reference/functions/validate_file/) and must be somewhere in a subfolder of `WP_CONTENT_DIR`.
134
+
135
+ #### Schema.org (JSON) Metadata
136
+
137
+ The plugin adds some default metadata to enable ["Rich Snippet" support](https://developers.google.com/structured-data/rich-snippets/articles). You can modify this using the `amp_post_template_metadata` filter. The following changes the type annotation to `NewsArticle` (from the default `BlogPosting`) and overrides the default Publisher Logo.
138
+
139
+ ```
140
+ add_filter( 'amp_post_template_metadata', 'xyz_amp_modify_json_metadata', 10, 2 );
141
+
142
+ function xyz_amp_modify_json_metadata( $metadata, $post ) {
143
+ $metadata['@type'] = 'NewsArticle';
144
+
145
+ $metadata['publisher']['logo'] = array(
146
+ '@type' => 'ImageObject',
147
+ 'url' => get_template_directory_uri() . '/images/my-amp-metadata-logo.png',
148
+ 'height' => 60,
149
+ 'width' => 600,
150
+ );
151
+
152
+ return $metadata;
153
+ }
154
+ ```
155
+
156
+ #### Template Meta (Author, Date, etc.)
157
+
158
+ For the meta section of the template (i.e. author, date, taxonomies, etc.), you can override templates for the existing sections, remove them, add new ones.
159
+
160
+ ##### Example: Override Author Template from Theme
161
+
162
+ Create a folder in your theme called `amp` and add a file called `meta-author.php` with the following:
163
+
164
+ ```php
165
+ <li class="xyz-byline">
166
+ <span>Anonymous</span>
167
+ </li>
168
+ ```
169
+
170
+ Replace the contents, as needed.
171
+
172
+ ##### Example: Override Taxonomy Template via filter
173
+
174
+ This will load the file `t/meta-custom-tax.php` for the `taxonomy` section:
175
+
176
+ ```php
177
+ add_filter( 'amp_post_template_file', 'xyz_amp_set_custom_tax_meta_template', 10, 3 );
178
+
179
+ function xyz_amp_set_custom_tax_meta_template( $file, $type, $post ) {
180
+ if ( 'meta-taxonomy' === $type ) {
181
+ $file = dirname( __FILE__ ) . '/t/meta-custom-tax.php';
182
+ }
183
+ return $file;
184
+ }
185
+ ```
186
+
187
+ In `t/meta-custom-tax.php`, you can add something like the following to replace the default category and tags with your custom `author` taxonomy:
188
+
189
+ ```php
190
+ <li class="xyz-tax-authors">
191
+ <?php echo get_the_term_list( $this->get( 'post_id' ), 'xyz-author', '', ', ' ); ?>
192
+ </li>
193
+ ```
194
+
195
+ ##### Example: Remove Author from `header_meta`
196
+
197
+ This will completely remove the author section:
198
+
199
+ ```php
200
+ add_filter( 'amp_post_article_header_meta', 'xyz_amp_remove_author_meta' );
201
+
202
+ function xyz_amp_remove_author_meta( $meta_parts ) {
203
+ foreach ( array_keys( $meta_parts, 'meta-author', true ) as $key ) {
204
+ unset( $meta_parts[ $key ] );
205
+ }
206
+ return $meta_parts;
207
+ }
208
+ ```
209
+
210
+ ##### Example: Add Comment Count to `footer_meta`
211
+
212
+ This adds a new section to display the comment count:
213
+
214
+ ```php
215
+ add_filter( 'amp_post_article_footer_meta', 'xyz_amp_add_comment_count_meta' );
216
+
217
+ function xyz_amp_add_comment_count_meta( $meta_parts ) {
218
+ $meta_parts[] = 'xyz-meta-comment-count';
219
+ return $meta_parts;
220
+ }
221
+
222
+ add_filter( 'amp_post_template_file', 'xyz_amp_set_comment_count_meta_path', 10, 3 );
223
+
224
+ function xyz_amp_set_comment_count_meta_path( $file, $type, $post ) {
225
+ if ( 'xyz-meta-comment-count' === $type ) {
226
+ $file = dirname( __FILE__ ) . '/templates/xyz-meta-comment-count.php';
227
+ }
228
+ return $file;
229
+ }
230
+ ```
231
+
232
+ Then, in `templates/xyz-meta-comment-count.php`:
233
+
234
+ ```php
235
+ <li>
236
+ <?php printf( _n( '%d comment', '%d comments', $this->get( 'post' )->comment_count, 'xyz-text-domain' ) ); ?>
237
+ </li>
238
+ ```
239
+
240
+ #### Custom CSS
241
+
242
+ ##### Rule Additions
243
+
244
+ If you want to append to the existing CSS rules (e.g. styles for a custom embed handler), you can use the `amp_post_template_css` action:
245
+
246
+ ```php
247
+ add_action( 'amp_post_template_css', 'xyz_amp_my_additional_css_styles' );
248
+
249
+ function xyz_amp_my_additional_css_styles( $amp_template ) {
250
+ // only CSS here please...
251
+ ?>
252
+ .amp-wp-byline amp-img {
253
+ border-radius: 0; /* we don't want round avatars! */
254
+ }
255
+ .my-custom-class {
256
+ color: blue;
257
+ }
258
+ <?php
259
+ }
260
+ ```
261
+
262
+ ##### Completely Override CSS
263
+
264
+ If you'd prefer to use your own styles, you can either:
265
+
266
+ - Create a folder in your theme called `amp` and add a file called `style.php` with your custom CSS.
267
+ - Specify a custom template using the `amp_post_template_file` filter for `'style' === $type`. See the "Override" examples in the "Meta" section for examples.
268
+
269
+ Note: the file should only include CSS, not the `<style>` opening and closing tag.
270
+
271
+ #### Head and Footer
272
+
273
+ If you want to add stuff to the head or footer of the default AMP template, use the `amp_post_template_head` and `amp_post_template_footer` actions.
274
+
275
+ ```php
276
+ add_action( 'amp_post_template_footer', 'xyz_amp_add_pixel' );
277
+
278
+ function xyz_amp_add_pixel( $amp_template ) {
279
+ $post_id = $amp_template->get( 'post_id' );
280
+ ?>
281
+ <amp-pixel src="https://example.com/hi.gif?x=RANDOM"></amp-pixel>
282
+ <?php
283
+ }
284
+ ```
285
+
286
+ #### AMP Endpoint
287
+
288
+ If you don't want to use the default `/amp` endpoint, use the `amp_query_var` filter to change it to anything else.
289
+
290
+ ```php
291
+ add_filter( 'amp_query_var' , 'xyz_amp_change_endpoint' );
292
+
293
+ function xyz_amp_change_endpoint( $amp_endpoint ) {
294
+ return 'foo';
295
+ }
296
+ ```
297
+
298
+ ### Custom Template
299
+
300
+ If you want complete control over the look and feel of your AMP content, you can override the default template using the `amp_post_template_file` filter and pass it the path to a custom template:
301
+
302
+ ```php
303
+ add_filter( 'amp_post_template_file', 'xyz_amp_set_custom_template', 10, 3 );
304
+
305
+ function xyz_amp_set_custom_template( $file, $type, $post ) {
306
+ if ( 'single' === $type ) {
307
+ $file = dirname( __FILE__ ) . '/templates/my-amp-template.php';
308
+ }
309
+ return $file;
310
+ }
311
+ ```
312
+
313
+ Note: there are some requirements for a custom template:
314
+
315
+ * You must trigger the `amp_post_template_head` action in the `<head>` section:
316
+
317
+ ```
318
+ do_action( 'amp_post_template_head', $this );
319
+ ```
320
+
321
+ * You must trigger the `amp_post_template_footer` action right before the `</body>` tag:
322
+
323
+ ```
324
+ do_action( 'amp_post_template_footer', $this );
325
+ ```
326
+
327
+ * Within your `amp-custom` `style` tags, you must trigger the `amp_post_template_css` action:
328
+
329
+ ```php
330
+ do_action( 'amp_post_template_css', $this );
331
+ ```
332
+
333
+ * You must include [all required mark-up](https://www.ampproject.org/docs/get_started/create/basic_markup.html) that isn't already output via the `amp_post_template_head` action.
334
+
335
+ ## Handling Media
336
+
337
+ By default, the plugin attempts to gracefully handle the following media elements in your content:
338
+
339
+ - images (converted from `img` => `amp-img` or `amp-anim`)
340
+ - videos (converted from `video` => `amp-video`; Note: Flash is not supported)
341
+ - audio (converted from `audio` => `amp-audio`)
342
+ - iframes (converted from `iframes` => `amp-iframes`)
343
+ - YouTube, Instagram, Twitter, and Vine oEmbeds and shortcodes (converted from the embed to the matching `amp-` component)
344
+
345
+ For additional media content such as custom shortcodes, oEmbeds or manually inserted embeds, ads, etc. there are several customization options available and outlined below.
346
+
347
+ ### Do Nothing
348
+
349
+ If your embeds/media use standard iframes, you can choose to do nothing and let the plugin handle things. They should "just work" in most cases.
350
+
351
+ ### `the_content` filter
352
+
353
+ All existing hooks on `the_content` will continue to work. This can be a good or bad thing. Good, because existing plugin integrations will continue to work. Bad, because not all added content may make sense in an AMP context.
354
+
355
+ You can add additional callbacks to `the_content` filter to output additional content as needed. Use the `is_amp_endpoint()` function to check if an AMP version of a post is being viewed. However, we recommend using an Embed Handler instead.
356
+
357
+ Caveat: with this method, if you add a custom component that requires inclusion of a script, you will need to add that script manually to the template using the `amp_post_template_head` action.
358
+
359
+ ### Update Existing Shortcodes
360
+
361
+ In your existing shortcode or oEmbed callbacks, you can branch using the `is_amp_endpoint()` and output customized content for AMP content.
362
+
363
+ The same caveat about scripts for custom AMP components applies.
364
+
365
+ ### Custom Embed Handler
366
+
367
+ Embed Handlers are helper classes to inject AMP-specific content for your oEmbeds and shortcodes.
368
+
369
+ Embed Handlers register the embeds they handle using standard WordPress functions such as `add_shortcode`. For working examples, check out the existing implementations for Instagram, Twitter, etc. as guides to build your own.
370
+
371
+ While the primary purpose of Embed Handlers is for use with embeds, you can use them for adding AMP-specific `the_content` callbacks as well.
372
+
373
+ #### Step 1: Build the Embed Handler
374
+
375
+ Your Embed Handler class needs to extend the `AMP_Base_Embed_Handler` class.
376
+
377
+ Note: make sure to set proper priorities or remove existing callbacks for your regular content.
378
+
379
+ In `classes/class-amp-related-posts-embed.php`:
380
+
381
+ ```php
382
+ class XYZ_AMP_Related_Posts_Embed extends AMP_Base_Embed_Handler {
383
+ public function register_embed() {
384
+ // If we have an existing callback we are overriding, remove it.
385
+ remove_filter( 'the_content', 'xyz_add_related_posts' );
386
+
387
+ // Add our new callback
388
+ add_filter( 'the_content', array( $this, 'add_related_posts' ) );
389
+ }
390
+
391
+ public function unregister_embed() {
392
+ // Let's clean up after ourselves, just in case.
393
+ add_filter( 'the_content', 'xyz_add_related_posts' );
394
+ remove_filter( 'the_content', array( $this, 'add_related_posts' ) );
395
+ }
396
+
397
+ public function get_scripts() {
398
+ return array( 'amp-mustache' => 'https://cdn.ampproject.org/v0/amp-mustache-0.1.js' );
399
+ }
400
+
401
+ public function add_related_posts( $content ) {
402
+ // See https://github.com/ampproject/amphtml/blob/master/extensions/amp-list/amp-list.md for details on amp-list
403
+ $related_posts_list = '
404
+ <amp-list src="https://data.com/articles.json?ref=CANONICAL_URL" width=300 height=200 layout=responsive>
405
+ <template type="amp-mustache">
406
+ <div>
407
+ <amp-img src="{{imageUrl}}" width=50 height=50></amp-img>
408
+ {{title}}
409
+ </div>
410
+ </template>
411
+ <div overflow role=button aria-label="Show more" class="list-overflow">
412
+ Show more
413
+ </div>
414
+ </amp-list>';
415
+
416
+ $content .= $related_posts_list;
417
+
418
+ return $content;
419
+ }
420
+ }
421
+ ```
422
+
423
+ #### Step 2: Load the Embed Handler
424
+
425
+ ```php
426
+ add_filter( 'amp_content_embed_handlers', 'xyz_amp_add_related_embed', 10, 2 );
427
+
428
+ function xyz_amp_add_related_embed( $embed_handler_classes, $post ) {
429
+ require_once( dirname( __FILE__ ) . '/classes/class-amp-related-posts-embed.php' );
430
+ $embed_handler_classes[ 'XYZ_AMP_Related_Posts_Embed' ] = array();
431
+ return $embed_handler_classes;
432
+ }
433
+ ```
434
+
435
+ ### Custom Sanitizer
436
+
437
+ The name "sanitizer" is a bit of a misnomer. These are primarily used internally in the plugin to make your site's content compatible with the amp spec. This involves stripping unsupported tags and attributes and transforming media elements to their matching amp version (e.g. `img` => `amp-img`).
438
+
439
+ Sanitizers are pretty versatile and, unlike Embed Handlers -- which work with HTML content as a string -- they can be used to manipulate your post's AMP content using [PHP's `DOM` library](http://php.net/manual/en/book.dom.php). We've included an example that shows you how to use a custom sanitizer to inject ads into your content. You can, of course, do many other things such as add related content.
440
+
441
+ #### Step 1: Build the Sanitizer
442
+
443
+ Your sanitizer needs to extend the `AMP_Base_Sanitizer`. In `classes/class-ad-inject-sanitizer.php`:
444
+
445
+ ```php
446
+ class XYZ_AMP_Ad_Injection_Sanitizer extends AMP_Base_Sanitizer {
447
+ public function sanitize() {
448
+ $body = $this->get_body_node();
449
+
450
+ // Build our amp-ad tag
451
+ $ad_node = AMP_DOM_Utils::create_node( $this->dom, 'amp-ad', array(
452
+ // Taken from example at https://github.com/ampproject/amphtml/blob/master/builtins/amp-ad.md
453
+ 'width' => 300,
454
+ 'height' => 250,
455
+ 'type' => 'a9',
456
+ 'data-aax_size' => '300x250',
457
+ 'data-aax_pubname' => 'test123',
458
+ 'data-aax_src' => '302',
459
+ ) );
460
+
461
+ // Add a placeholder to show while loading
462
+ $fallback_node = AMP_DOM_Utils::create_node( $this->dom, 'amp-img', array(
463
+ 'placeholder' => '',
464
+ 'layout' => 'fill',
465
+ 'src' => 'https://placehold.it/300X250',
466
+ ) );
467
+ $ad_node->appendChild( $fallback_node );
468
+
469
+ // If we have a lot of paragraphs, insert before the 4th one.
470
+ // Otherwise, add it to the end.
471
+ $p_nodes = $body->getElementsByTagName( 'p' );
472
+ if ( $p_nodes->length > 6 ) {
473
+ $p_nodes->item( 4 )->parentNode->insertBefore( $ad_node, $p_nodes->item( 4 ));
474
+ } else {
475
+ $body->appendChild( $ad_node );
476
+ }
477
+ }
478
+ }
479
+ ```
480
+
481
+ #### Step 2: Load the Sanitizer
482
+
483
+ ```php
484
+ add_filter( 'amp_content_sanitizers', 'xyz_amp_add_ad_sanitizer', 10, 2 );
485
+
486
+ function xyz_amp_add_ad_sanitizer( $sanitizer_classes, $post ) {
487
+ require_once( dirname( __FILE__ ) . '/classes/class-ad-inject-sanitizer.php' );
488
+ $sanitizer_classes[ 'XYZ_AMP_Ad_Injection_Sanitizer' ] = array(); // the array can be used to pass args to your sanitizer and accessed within the class via `$this->args`
489
+ return $sanitizer_classes;
490
+ }
491
+ ```
492
+
493
+ ## Analytics
494
+
495
+ To output proper analytics tags, you can use the `amp_post_template_analytics` filter:
496
+
497
+ ```
498
+ add_filter( 'amp_post_template_analytics', 'xyz_amp_add_custom_analytics' );
499
+ function xyz_amp_add_custom_analytics( $analytics ) {
500
+ if ( ! is_array( $analytics ) ) {
501
+ $analytics = array();
502
+ }
503
+
504
+ // https://developers.google.com/analytics/devguides/collection/amp-analytics/
505
+ $analytics['xyz-googleanalytics'] = array(
506
+ 'type' => 'googleanalytics',
507
+ 'attributes' => array(
508
+ // 'data-credentials' => 'include',
509
+ ),
510
+ 'config_data' => array(
511
+ 'vars' => array(
512
+ 'account' => "UA-XXXXX-Y"
513
+ ),
514
+ 'triggers' => array(
515
+ 'trackPageview' => array(
516
+ 'on' => 'visible',
517
+ 'request' => 'pageview',
518
+ ),
519
+ ),
520
+ ),
521
+ );
522
+
523
+ // https://www.parsely.com/docs/integration/tracking/google-amp.html
524
+ $analytics['xyz-parsely'] = array(
525
+ 'type' => 'parsely',
526
+ 'attributes' => array(),
527
+ 'config_data' => array(
528
+ 'vars' => array(
529
+ 'apikey' => 'YOUR APIKEY GOES HERE',
530
+ )
531
+ ),
532
+ );
533
+
534
+ return $analytics;
535
+ }
536
+ ```
537
+
538
+ Each analytics entry must include a unique array key and the following attributes:
539
+
540
+ - `type`: `(string)` one of the [valid vendors](https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/amp-analytics.md#analytics-vendors) for amp-analytics.
541
+ - `attributes`: `(array)` any [additional valid attributes](https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/amp-analytics.md#attributes) to add to the `amp-analytics` element.
542
+ - `config_data`: `(array)` the [config data](https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/amp-analytics.md#configuration) to include in the `amp-analytics` script tag. This is `json_encode`-d on output.
543
+
544
+ ## Custom Post Type Support
545
+
546
+ By default, the plugin only creates AMP content for posts. You can add support for other post_types using the post_type parameter used when registering the custom post type (assume our post_type is `xyz-review`):
547
+
548
+ ```php
549
+ add_action( 'amp_init', 'xyz_amp_add_review_cpt' );
550
+ function xyz_amp_add_review_cpt() {
551
+ add_post_type_support( 'xyz-review', AMP_QUERY_VAR );
552
+ }
553
+ ```
554
+
555
+ You'll need to flush your rewrite rules after this.
556
+
557
+ If you want a custom template for your post type:
558
+
559
+ ```
560
+ add_filter( 'amp_post_template_file', 'xyz_amp_set_review_template', 10, 3 );
561
+
562
+ function xyz_amp_set_review_template( $file, $type, $post ) {
563
+ if ( 'single' === $type && 'xyz-review' === $post->post_type ) {
564
+ $file = dirname( __FILE__ ) . '/templates/my-amp-review-template.php';
565
+ }
566
+ return $file;
567
+ }
568
+ ```
569
+
570
+ We may provide better ways to handle this in the future.
571
+
572
+ ## Plugin integrations
573
+
574
+ ### Jetpack
575
+
576
+ Jetpack integration is baked in. More support for things like Related Posts to come.
577
+
578
+ ### Parse.ly
579
+
580
+ [Parse.ly's WordPress plugin](https://wordpress.org/plugins/wp-parsely/) automatically tracks AMP pages when enabled along with this plugin.
581
+
582
+
583
+ ### Yoast SEO
584
+
585
+ If you're using [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/), check out the companion plugin here: https://github.com/Yoast/yoastseo-amp
586
+
587
+ ## Compatibility Issues
588
+
589
+ The following plugins have been known to cause issues with this plugin:
590
+
591
+ - Cloudflare Rocket Loader (modifies the output of the AMP page, which breaks validation.)
includes/vendor/amp/readme.txt ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === AMP ===
2
+ Contributors: batmoo, joen, automattic, potatomaster
3
+ Tags: amp, mobile
4
+ Requires at least: 4.4
5
+ Tested up to: 4.8
6
+ Stable tag: 0.4.2
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Enable Accelerated Mobile Pages (AMP) on your WordPress site.
11
+
12
+ == Description ==
13
+
14
+ This plugin adds support for the [Accelerated Mobile Pages](https://www.ampproject.org) (AMP) Project, which is an an open source initiative that aims to provide mobile optimized content that can load instantly everywhere.
15
+
16
+ With the plugin active, all posts on your site will have dynamically generated AMP-compatible versions, accessible by appending `/amp/` to the end your post URLs. For example, if your post URL is `http://example.com/2016/01/01/amp-on/`, you can access the AMP version at `http://example.com/2016/01/01/amp-on/amp/`. If you do not have [pretty permalinks](https://codex.wordpress.org/Using_Permalinks#mod_rewrite:_.22Pretty_Permalinks.22) enabled, you can do the same thing by appending `?amp=1`, i.e. `http://example.com/2016/01/01/amp-on/?amp=1`
17
+
18
+ Note #1: that Pages and archives are not currently supported. Pages support is being worked on.
19
+
20
+ Note #2: this plugin only creates AMP content but does not automatically display it to your users when they visit from a mobile device. That is handled by AMP consumers such as Google Search. For more details, see the [AMP Project FAQ](https://www.ampproject.org/docs/support/faqs.html).
21
+
22
+ Follow along with or contribute to the development of this plugin at https://github.com/Automattic/amp-wp
23
+
24
+ == Installation ==
25
+
26
+ 1. Upload the folder to the `/wp-content/plugins/` directory
27
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
28
+ 1. You may need to refresh your permalinks by going to `Settings > Permalinks` and tapping the `Save` button.
29
+
30
+ == Frequently Asked Questions ==
31
+
32
+ = How do I customize the AMP output for my site? =
33
+
34
+ You can tweak a few things like colours from the AMP Customizer. From the Dashboard, go to `Appearance > AMP`.
35
+
36
+ For deeper level customizations, please see the readme at https://github.com/Automattic/amp-wp/blob/master/readme.md
37
+
38
+ = What about ads and shortcodes and such? =
39
+
40
+ Check out https://github.com/Automattic/amp-wp/blob/master/readme.md#handling-media
41
+
42
+ = What about analytics? =
43
+
44
+ Many plugins are adding AMP support already. If you handling analytics yourself, please see https://github.com/Automattic/amp-wp/blob/master/readme.md#analytics
45
+
46
+ = Google Webmaster Tools is reporting validation errors for my site. How do I fix them? =
47
+
48
+ The best place to start is to open a new discussion in the [support forum](https://wordpress.org/support/plugin/amp) with details on what the specific validation error is.
49
+
50
+ = Why aren't Pages supported yet =
51
+
52
+ A wise green Yoda once said, "Patience you must have, my young padawan." We're working on it :)
53
+
54
+ == Changelog ==
55
+
56
+ = 0.4.2 (2016-10-13) =
57
+
58
+ - Fix: Prevent validation errors for `html` tag (h/t Maxime2 and everyone else that reported this error)
59
+ - Fix: Handle variable name conflict that was causing content_max_width to be ignored (h/t mimancillas)
60
+ - Fix: Prevent errors when nodes don't have attributes (h/t stephenmax)
61
+ - Fix: Back-compat for 4.5 (add sanitize_hex_color function, h/t xotihcan)
62
+ - Fix: Handle gif featured images (h/t protocolil)
63
+ - Documentation updates (props troyxmccall)
64
+
65
+ = 0.4.1 (2016-10-10) =
66
+
67
+ - Fix: Don't fire the_content for featured image output
68
+ - Fix: Don't show comment link when disabled and no comments on post (h/t neotrope)
69
+ - Fix: strip `!important` from inline styles (h/t compointdesigner and enriccardonagmailcom)
70
+
71
+ = 0.4 (2016-10-06) =
72
+
73
+ - New template: spiffy, shiny, and has the fresh theme smell (props allancole and the Automattic Theme Team).
74
+ - *Warning*: The template update has potential breaking changes. Please see https://wordpress.org/support/topic/v0-4-whats-new-and-possible-breaking-changes/
75
+ - AMP Customizer: Pick your colours and make the template your own (props DrewAPicture and 10up)
76
+ - Fix: support for inline styles (props coreymckrill).
77
+ - Fix: no more fatal errors when tags not supported by post type (props david-binda)
78
+ - Fix: no more unnecessary `<br>` tags.
79
+ - Fix: sanitize children of removed nodes (like empty `<a>` tags) (props Maxime2).
80
+ - Fix: no more broken YouTube URLs with multiple ?s.
81
+ - Fix: properly handle tel and sms schemes (h/t soundstrategies).
82
+ - Fix: remove amp endpoint on deactivate.
83
+ - New filter: `amp_pre_get_permalink` if you want a completely custom AMP permalink.
84
+
85
+ = 0.3.3 (Aug 18, 2016) =
86
+
87
+ - Handle many more validation errors (props bcampeau and alleyinteractive).
88
+ - New filter: `amp_post_template_dir` (props mustafauysal).
89
+ - New template: Nav bar is now it's own template part (props jdevalk).
90
+ - Better ratio for YouTube embeds.
91
+ - Fix: better timezone handling (props rinatkhaziev).
92
+ - Fix: better handling of non-int dimensions (like `100%`).
93
+ - Fix: better handling of empty dimensions.
94
+ - Fix: `autoplay` is a bool-like value.
95
+ - Fix: breakage when using the `query_string` hook (h/t mkuplens).
96
+ - Fix: don't break really large Twitter IDs.
97
+ - Fix: don't break Instagram shortcodes when using URLs with querystrings.
98
+ - Readme improvements (props nickjohnford, sotayamashita)
99
+
100
+ = 0.3.2 (Mar 4, 2016) =
101
+
102
+ * Jetpack Stats support.
103
+ * Better version of Merriweather and use system fonts for sans-serif (props mattmiklic).
104
+ * Move font to stylesheet so it can be more easily overridden (props mattmiklic).
105
+ * Fix: Template loading issues on Windows. (Thanks to everyone who reported this, especially w33zy for pointing out the `validate_file` issue.)
106
+ * Fix: don't run AMP on post comment feeds (props kraftbj).
107
+ * Fix: un-break pagination when using a static home page with multiple pages.
108
+ * Fix: force amp-iframe to use https to validate correctly (props mister-ben).
109
+ * Fix: validation for `target` and `video`/`audio` attributes.
110
+ * Fix: clipped images in galleries (thanks tobaco).
111
+
112
+ = 0.3.1 (Feb 24, 2016) =
113
+
114
+ * Allow custom query var (props vaurdan).
115
+ * Fix AMP URLs for non-pretty permalinks (props rakuishi).
116
+ * Fix for password-protected posts.
117
+ * Fix dimension extraction for schema-less or relative image URLs.
118
+ * Better fallback for images with no dimensions.
119
+ * Validation fixes for `a` tags (props kraftbj).
120
+ * Updated AMP boilerplate.
121
+ * Allow `on` tags for elements (props Steven Evatt).
122
+ * Prefixed class names.
123
+
124
+ = 0.3 (Feb 18, 2016) =
125
+
126
+ * Fetch dimensions for hotlinked images.
127
+ * Add amp-facebook support.
128
+ * Add some new actions and filters (e.g. `amp_init`).
129
+ * Fix validation errors for [gallery] shortcodes.
130
+ * Fix issues with path validation on Windows.
131
+ * Fix issues with really squeezed layout.
132
+ * Breaking change: `style.css` no longer contains the `<style> tag. If you have a custom stylesheet, you need to update it to remove the tag.
133
+ * Breaking change: `single.php` no longer includes the AMP boilerplate styles. They are instead added via the `amp_post_template_head` hook. If you have a custom template, please remove the boilerplate styles.
134
+
135
+ = 0.2 (Jan 28, 2016) =
136
+
137
+ * Lots and lots and lots of compatibility and validation fixes
138
+ * Lots and lots and lots of improvements for customization
139
+
140
+ = 0.1 =
141
+ * Initial version
142
+
143
+ == Upgrade Notice ==
144
+
145
+ = 0.4 =
146
+
147
+ * Breaking change: The new template has changes to markup, class names, and styles that may not work with existing customizations. If you want to stay on the old template for now, you can use the following code snippet:
148
+
149
+ ```
150
+ if ( function_exists( 'amp_backcompat_use_v03_templates' ) ) {
151
+ amp_backcompat_use_v03_templates();
152
+ }
153
+ ```
154
+
155
+ For more details, please see https://wordpress.org/support/topic/v0-4-whats-new-and-possible-breaking-changes/
156
+
157
+ = 0.3.1 =
158
+
159
+ * Breaking change: `AMP_QUERY_VAR` is now defined right before `amp_init`.
160
+ * Breaking change: class names for elements in the default template were prefixed with `amp-wp-`. Any styles targeting these classes should be updated.
161
+
162
+ = 0.3 =
163
+
164
+ * Breaking change: `style.css` no longer contains the `<style> tag. If you have a custom stylesheet, you need to update it to remove the tag.
165
+ * Breaking change: `single.php` no longer includes the AMP boilerplate styles. They are instead added via the `amp_post_template_head` hook. If you have a custom template, please remove the boilerplate styles.
includes/vendor/amp/templates/featured-image.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $featured_image = $this->get( 'featured_image' );
3
+
4
+ if ( empty( $featured_image ) ) {
5
+ return;
6
+ }
7
+
8
+ $amp_html = $featured_image['amp_html'];
9
+ $caption = $featured_image['caption'];
10
+ ?>
11
+ <figure class="amp-wp-article-featured-image wp-caption">
12
+ <?php echo $amp_html; // amphtml content; no kses ?>
13
+ <?php if ( $caption ) : ?>
14
+ <p class="wp-caption-text">
15
+ <?php echo wp_kses_data( $caption ); ?>
16
+ </p>
17
+ <?php endif; ?>
18
+ </figure>
includes/vendor/amp/templates/footer.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <footer class="amp-wp-footer">
2
+ <div>
3
+ <h2><?php echo esc_html( $this->get( 'blog_name' ) ); ?></h2>
4
+ <p>
5
+ <a href="<?php echo esc_url( __( 'https://wordpress.org/', 'amp' ) ); ?>"><?php printf( __( 'Powered by %s', 'amp' ), 'WordPress' ); ?></a>
6
+ </p>
7
+ <a href="#top" class="back-to-top"><?php _e( 'Back to top', 'amp' ); ?></a>
8
+ </div>
9
+ </footer>
includes/vendor/amp/templates/header-bar.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <header id="#top" class="amp-wp-header">
2
+ <div>
3
+ <a href="<?php echo esc_url( $this->get( 'home_url' ) ); ?>">
4
+ <?php $site_icon_url = $this->get( 'site_icon_url' );
5
+ if ( $site_icon_url ) : ?>
6
+ <amp-img src="<?php echo esc_url( $site_icon_url ); ?>" width="32" height="32" class="amp-wp-site-icon"></amp-img>
7
+ <?php endif; ?>
8
+ <?php echo esc_html( $this->get( 'blog_name' ) ); ?>
9
+ </a>
10
+ </div>
11
+ </header>
includes/vendor/amp/templates/meta-author.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php $post_author = $this->get( 'post_author' ); ?>
2
+ <?php if ( $post_author ) : ?>
3
+ <?php $author_avatar_url = get_avatar_url( $post_author->user_email, array( 'size' => 24 ) ); ?>
4
+ <div class="amp-wp-meta amp-wp-byline">
5
+ <?php if ( function_exists( 'get_avatar_url' ) ) : ?>
6
+ <amp-img src="<?php echo esc_url( $author_avatar_url ); ?>" width="24" height="24" layout="fixed"></amp-img>
7
+ <?php endif; ?>
8
+ <span class="amp-wp-author author vcard"><?php echo esc_html( $post_author->display_name ); ?></span>
9
+ </div>
10
+ <?php endif; ?>
includes/vendor/amp/templates/meta-comments-link.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $comments_link_url = $this->get( 'comments_link_url' );
3
+ ?>
4
+ <?php if ( $comments_link_url ) : ?>
5
+ <?php $comments_link_text = $this->get( 'comments_link_text' ); ?>
6
+ <div class="amp-wp-meta amp-wp-comments-link">
7
+ <a href="<?php echo esc_url( $comments_link_url ); ?>">
8
+ <?php echo esc_html( $comments_link_text ); ?>
9
+ </a>
10
+ </div>
11
+ <?php endif; ?>
includes/vendor/amp/templates/meta-taxonomy.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $categories = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'amp' ), '', $this->ID ); ?>
2
+ <?php if ( $categories ) : ?>
3
+ <div class="amp-wp-meta amp-wp-tax-category">
4
+ <?php printf( esc_html__( 'Categories: %s', 'amp' ), $categories ); ?>
5
+ </div>
6
+ <?php endif; ?>
7
+
8
+ <?php
9
+ $tags = get_the_tag_list(
10
+ '',
11
+ _x( ', ', 'Used between list items, there is a space after the comma.', 'amp' ),
12
+ '',
13
+ $this->ID
14
+ ); ?>
15
+ <?php if ( $tags && ! is_wp_error( $tags ) ) : ?>
16
+ <div class="amp-wp-meta amp-wp-tax-tag">
17
+ <?php printf( esc_html__( 'Tags: %s', 'amp' ), $tags ); ?>
18
+ </div>
19
+ <?php endif; ?>
includes/vendor/amp/templates/meta-time.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="amp-wp-meta amp-wp-posted-on">
2
+ <time datetime="<?php echo esc_attr( date( 'c', $this->get( 'post_publish_timestamp' ) ) ); ?>">
3
+ <?php
4
+ echo esc_html(
5
+ sprintf(
6
+ _x( '%s ago', '%s = human-readable time difference', 'amp' ),
7
+ human_time_diff( $this->get( 'post_publish_timestamp' ), current_time( 'timestamp' ) )
8
+ )
9
+ );
10
+ ?>
11
+ </time>
12
+ </div>
includes/vendor/amp/templates/single.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
6
+ <?php do_action( 'amp_post_template_head', $this ); ?>
7
+ <style amp-custom>
8
+ <?php $this->load_parts( array( 'style' ) ); ?>
9
+ <?php do_action( 'amp_post_template_css', $this ); ?>
10
+ </style>
11
+ </head>
12
+
13
+ <body class="<?php echo esc_attr( $this->get( 'body_class' ) ); ?>">
14
+
15
+ <?php $this->load_parts( array( 'header-bar' ) ); ?>
16
+
17
+ <article class="amp-wp-article">
18
+
19
+ <header class="amp-wp-article-header">
20
+ <h1 class="amp-wp-title"><?php echo wp_kses_data( $this->get( 'post_title' ) ); ?></h1>
21
+ <?php $this->load_parts( apply_filters( 'amp_post_article_header_meta', array( 'meta-author', 'meta-time' ) ) ); ?>
22
+ </header>
23
+
24
+ <?php $this->load_parts( array( 'featured-image' ) ); ?>
25
+
26
+ <div class="amp-wp-article-content">
27
+ <?php echo $this->get( 'post_amp_content' ); // amphtml content; no kses ?>
28
+ </div>
29
+
30
+ <footer class="amp-wp-article-footer">
31
+ <?php $this->load_parts( apply_filters( 'amp_post_article_footer_meta', array( 'meta-taxonomy', 'meta-comments-link' ) ) ); ?>
32
+ </footer>
33
+
34
+ </article>
35
+
36
+ <?php $this->load_parts( array( 'footer' ) ); ?>
37
+
38
+ <?php do_action( 'amp_post_template_footer', $this ); ?>
39
+
40
+ </body>
41
+ </html>
includes/vendor/amp/templates/style.php ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Get content width
3
+ $content_max_width = absint( $this->get( 'content_max_width' ) );
4
+
5
+ // Get template colors
6
+ $theme_color = $this->get_customizer_setting( 'theme_color' );
7
+ $text_color = $this->get_customizer_setting( 'text_color' );
8
+ $muted_text_color = $this->get_customizer_setting( 'muted_text_color' );
9
+ $border_color = $this->get_customizer_setting( 'border_color' );
10
+ $link_color = $this->get_customizer_setting( 'link_color' );
11
+ $header_background_color = $this->get_customizer_setting( 'header_background_color' );
12
+ $header_color = $this->get_customizer_setting( 'header_color' );
13
+ ?>
14
+ /* Generic WP styling */
15
+
16
+ .alignright {
17
+ float: right;
18
+ }
19
+
20
+ .alignleft {
21
+ float: left;
22
+ }
23
+
24
+ .aligncenter {
25
+ display: block;
26
+ margin-left: auto;
27
+ margin-right: auto;
28
+ }
29
+
30
+ .amp-wp-enforced-sizes {
31
+ /** Our sizes fallback is 100vw, and we have a padding on the container; the max-width here prevents the element from overflowing. **/
32
+ max-width: 100%;
33
+ margin: 0 auto;
34
+ }
35
+
36
+ .amp-wp-unknown-size img {
37
+ /** Worst case scenario when we can't figure out dimensions for an image. **/
38
+ /** Force the image into a box of fixed dimensions and use object-fit to scale. **/
39
+ object-fit: contain;
40
+ }
41
+
42
+ /* Template Styles */
43
+
44
+ .amp-wp-content,
45
+ .amp-wp-title-bar div {
46
+ <?php if ( $content_max_width > 0 ) : ?>
47
+ margin: 0 auto;
48
+ max-width: <?php echo sprintf( '%dpx', $content_max_width ); ?>;
49
+ <?php endif; ?>
50
+ }
51
+
52
+ html {
53
+ background: <?php echo sanitize_hex_color( $header_background_color ); ?>;
54
+ }
55
+
56
+ body {
57
+ background: <?php echo sanitize_hex_color( $theme_color ); ?>;
58
+ color: <?php echo sanitize_hex_color( $text_color ); ?>;
59
+ font-family: 'Merriweather', 'Times New Roman', Times, Serif;
60
+ font-weight: 300;
61
+ line-height: 1.75em;
62
+ }
63
+
64
+ p,
65
+ ol,
66
+ ul,
67
+ figure {
68
+ margin: 0 0 1em;
69
+ padding: 0;
70
+ }
71
+
72
+ a,
73
+ a:visited {
74
+ color: <?php echo sanitize_hex_color( $link_color ); ?>;
75
+ }
76
+
77
+ a:hover,
78
+ a:active,
79
+ a:focus {
80
+ color: <?php echo sanitize_hex_color( $text_color ); ?>;
81
+ }
82
+
83
+ /* Quotes */
84
+
85
+ blockquote {
86
+ color: <?php echo sanitize_hex_color( $text_color ); ?>;
87
+ background: rgba(127,127,127,.125);
88
+ border-left: 2px solid <?php echo sanitize_hex_color( $link_color ); ?>;
89
+ margin: 8px 0 24px 0;
90
+ padding: 16px;
91
+ }
92
+
93
+ blockquote p:last-child {
94
+ margin-bottom: 0;
95
+ }
96
+
97
+ /* UI Fonts */
98
+
99
+ .amp-wp-meta,
100
+ .amp-wp-header div,
101
+ .amp-wp-title,
102
+ .wp-caption-text,
103
+ .amp-wp-tax-category,
104
+ .amp-wp-tax-tag,
105
+ .amp-wp-comments-link,
106
+ .amp-wp-footer p,
107
+ .back-to-top {
108
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif;
109
+ }
110
+
111
+ /* Header */
112
+
113
+ .amp-wp-header {
114
+ background-color: <?php echo sanitize_hex_color( $header_background_color ); ?>;
115
+ }
116
+
117
+ .amp-wp-header div {
118
+ color: <?php echo sanitize_hex_color( $header_color ); ?>;
119
+ font-size: 1em;
120
+ font-weight: 400;
121
+ margin: 0 auto;
122
+ max-width: calc(840px - 32px);
123
+ padding: .875em 16px;
124
+ position: relative;
125
+ }
126
+
127
+ .amp-wp-header a {
128
+ color: <?php echo sanitize_hex_color( $header_color ); ?>;
129
+ text-decoration: none;
130
+ }
131
+
132
+ /* Site Icon */
133
+
134
+ .amp-wp-header .amp-wp-site-icon {
135
+ /** site icon is 32px **/
136
+ background-color: <?php echo sanitize_hex_color( $header_color ); ?>;
137
+ border: 1px solid <?php echo sanitize_hex_color( $header_color ); ?>;
138
+ border-radius: 50%;
139
+ position: absolute;
140
+ right: 18px;
141
+ top: 10px;
142
+ }
143
+
144
+ /* Article */
145
+
146
+ .amp-wp-article {
147
+ color: <?php echo sanitize_hex_color( $text_color ); ?>;
148
+ font-weight: 400;
149
+ margin: 1.5em auto;
150
+ max-width: 840px;
151
+ overflow-wrap: break-word;
152
+ word-wrap: break-word;
153
+ }
154
+
155
+ /* Article Header */
156
+
157
+ .amp-wp-article-header {
158
+ align-items: center;
159
+ align-content: stretch;
160
+ display: flex;
161
+ flex-wrap: wrap;
162
+ justify-content: space-between;
163
+ margin: 1.5em 16px 1.5em;
164
+ }
165
+
166
+ .amp-wp-title {
167
+ color: <?php echo sanitize_hex_color( $text_color ); ?>;
168
+ display: block;
169
+ flex: 1 0 100%;
170
+ font-weight: 900;
171
+ margin: 0 0 .625em;
172
+ width: 100%;
173
+ }
174
+
175
+ /* Article Meta */
176
+
177
+ .amp-wp-meta {
178
+ color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
179
+ display: inline-block;
180
+ flex: 2 1 50%;
181
+ font-size: .875em;
182
+ line-height: 1.5em;
183
+ margin: 0;
184
+ padding: 0;
185
+ }
186
+
187
+ .amp-wp-article-header .amp-wp-meta:last-of-type {
188
+ text-align: right;
189
+ }
190
+
191
+ .amp-wp-article-header .amp-wp-meta:first-of-type {
192
+ text-align: left;
193
+ }
194
+
195
+ .amp-wp-byline amp-img,
196
+ .amp-wp-byline .amp-wp-author {
197
+ display: inline-block;
198
+ vertical-align: middle;
199
+ }
200
+
201
+ .amp-wp-byline amp-img {
202
+ border: 1px solid <?php echo sanitize_hex_color( $link_color ); ?>;
203
+ border-radius: 50%;
204
+ position: relative;
205
+ margin-right: 6px;
206
+ }
207
+
208
+ .amp-wp-posted-on {
209
+ text-align: right;
210
+ }
211
+
212
+ /* Featured image */
213
+
214
+ .amp-wp-article-featured-image {
215
+ margin: 0 0 1em;
216
+ }
217
+ .amp-wp-article-featured-image amp-img {
218
+ margin: 0 auto;
219
+ }
220
+ .amp-wp-article-featured-image.wp-caption .wp-caption-text {
221
+ margin: 0 18px;
222
+ }
223
+
224
+ /* Article Content */
225
+
226
+ .amp-wp-article-content {
227
+ margin: 0 16px;
228
+ }
229
+
230
+ .amp-wp-article-content ul,
231
+ .amp-wp-article-content ol {
232
+ margin-left: 1em;
233
+ }
234
+
235
+ .amp-wp-article-content amp-img {
236
+ margin: 0 auto;
237
+ }
238
+
239
+ .amp-wp-article-content amp-img.alignright {
240
+ margin: 0 0 1em 16px;
241
+ }
242
+
243
+ .amp-wp-article-content amp-img.alignleft {
244
+ margin: 0 16px 1em 0;
245
+ }
246
+
247
+ /* Captions */
248
+
249
+ .wp-caption {
250
+ padding: 0;
251
+ }
252
+
253
+ .wp-caption.alignleft {
254
+ margin-right: 16px;
255
+ }
256
+
257
+ .wp-caption.alignright {
258
+ margin-left: 16px;
259
+ }
260
+
261
+ .wp-caption .wp-caption-text {
262
+ border-bottom: 1px solid <?php echo sanitize_hex_color( $border_color ); ?>;
263
+ color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
264
+ font-size: .875em;
265
+ line-height: 1.5em;
266
+ margin: 0;
267
+ padding: .66em 10px .75em;
268
+ }
269
+
270
+ /* AMP Media */
271
+
272
+ amp-carousel {
273
+ background: <?php echo sanitize_hex_color( $border_color ); ?>;
274
+ margin: 0 -16px 1.5em;
275
+ }
276
+ amp-iframe,
277
+ amp-youtube,
278
+ amp-instagram,
279
+ amp-vine {
280
+ background: <?php echo sanitize_hex_color( $border_color ); ?>;
281
+ margin: 0 -16px 1.5em;
282
+ }
283
+
284
+ .amp-wp-article-content amp-carousel amp-img {
285
+ border: none;
286
+ }
287
+
288
+ amp-carousel > amp-img > img {
289
+ object-fit: contain;
290
+ }
291
+
292
+ .amp-wp-iframe-placeholder {
293
+ background: <?php echo sanitize_hex_color( $border_color ); ?> url( <?php echo esc_url( $this->get( 'placeholder_image_url' ) ); ?> ) no-repeat center 40%;
294
+ background-size: 48px 48px;
295
+ min-height: 48px;
296
+ }
297
+
298
+ /* Article Footer Meta */
299
+
300
+ .amp-wp-article-footer .amp-wp-meta {
301
+ display: block;
302
+ }
303
+
304
+ .amp-wp-tax-category,
305
+ .amp-wp-tax-tag {
306
+ color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
307
+ font-size: .875em;
308
+ line-height: 1.5em;
309
+ margin: 1.5em 16px;
310
+ }
311
+
312
+ .amp-wp-comments-link {
313
+ color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
314
+ font-size: .875em;
315
+ line-height: 1.5em;
316
+ text-align: center;
317
+ margin: 2.25em 0 1.5em;
318
+ }
319
+
320
+ .amp-wp-comments-link a {
321
+ border-style: solid;
322
+ border-color: <?php echo sanitize_hex_color( $border_color ); ?>;
323
+ border-width: 1px 1px 2px;
324
+ border-radius: 4px;
325
+ background-color: transparent;
326
+ color: <?php echo sanitize_hex_color( $link_color ); ?>;
327
+ cursor: pointer;
328
+ display: block;
329
+ font-size: 14px;
330
+ font-weight: 600;
331
+ line-height: 18px;
332
+ margin: 0 auto;
333
+ max-width: 200px;
334
+ padding: 11px 16px;
335
+ text-decoration: none;
336
+ width: 50%;
337
+ -webkit-transition: background-color 0.2s ease;
338
+ transition: background-color 0.2s ease;
339
+ }
340
+
341
+ /* AMP Footer */
342
+
343
+ .amp-wp-footer {
344
+ border-top: 1px solid <?php echo sanitize_hex_color( $border_color ); ?>;
345
+ margin: calc(1.5em - 1px) 0 0;
346
+ }
347
+
348
+ .amp-wp-footer div {
349
+ margin: 0 auto;
350
+ max-width: calc(840px - 32px);
351
+ padding: 1.25em 16px 1.25em;
352
+ position: relative;
353
+ }
354
+
355
+ .amp-wp-footer h2 {
356
+ font-size: 1em;
357
+ line-height: 1.375em;
358
+ margin: 0 0 .5em;
359
+ }
360
+
361
+ .amp-wp-footer p {
362
+ color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
363
+ font-size: .8em;
364
+ line-height: 1.5em;
365
+ margin: 0 85px 0 0;
366
+ }
367
+
368
+ .amp-wp-footer a {
369
+ text-decoration: none;
370
+ }
371
+
372
+ .back-to-top {
373
+ bottom: 1.275em;
374
+ font-size: .8em;
375
+ font-weight: 600;
376
+ line-height: 2em;
377
+ position: absolute;
378
+ right: 16px;
379
+ }
includes/welcome.php CHANGED
@@ -1,5 +1,4 @@
1
- <?php
2
- add_action( 'admin_init', 'ampforwp_welcome_screen_do_activation_redirect' );
3
  function ampforwp_welcome_screen_do_activation_redirect() {
4
  // Bail if no activation redirect
5
  if ( ! get_transient( 'ampforwp_welcome_screen_activation_redirect' ) ) {
@@ -18,7 +17,7 @@ function ampforwp_welcome_screen_do_activation_redirect() {
18
  wp_safe_redirect( add_query_arg( array( 'page' => 'ampforwp-welcome-page' ), admin_url( 'index.php' ) ) );
19
  }
20
 
21
- add_action( 'admin_init', 'ampforwp_welcome_screen_do_activation_redirect_parent' );
22
  function ampforwp_welcome_screen_do_activation_redirect_parent() {
23
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
24
  $amp_plugin_activation_check = is_plugin_active( 'amp/amp.php' );
@@ -54,7 +53,7 @@ function ampforwp_welcome_screen_pages() {
54
  function ampforwp_welcome_screen_content() {
55
  ?>
56
  <div class="wrap">
57
- <?php echo ampforwp_plugin_parent_activation(); ?>
58
 
59
  <div class="clear"></div>
60
 
@@ -63,16 +62,16 @@ function ampforwp_welcome_screen_content() {
63
  <h1 style="color:#388E3C;font-weight:500"><i class="dashicons dashicons-yes"></i><?php echo __('AMP is now Installed!','accelerated-mobile-pages') ?></h1>
64
  <p style=" font-family: georgia; font-size: 20px; font-style: italic; margin-bottom: 3px; line-height: 1.5; color: #666;"><?php echo __('Thank you so much for installing the AMPforWP plugin!','accelerated-mobile-pages') ?></p>
65
  <p style="font-family: georgia;font-size: 20px;margin-top: 4px;font-style: italic;line-height: 1.5;color: #666;"><?php echo __('Our team works really hard to deliver good user experience to you.','accelerated-mobile-pages') ?></p>
66
- <div class="install_options">
67
- <div class="install_options_left">
68
- <p style="margin-top:0;margin-bottom:0;font-size: 15px;line-height: 1;"><b><?php echo __('Head Over to Settings','accelerated-mobile-pages') ?></b></p>
69
- <p style="margin-top: 8px;margin-bottom:0px;"><?php echo __('Time to customize the your AMP!','accelerated-mobile-pages') ?></p>
70
- </div>
71
- <div class="install_options_right">
72
- <a href="<?php echo esc_url( admin_url('admin.php?page=amp_options') );?>"><?php echo __('AMP Options Panel','accelerated-mobile-pages') ?></a>
73
- </div>
74
- <div class="clear"></div>
75
- </div>
76
 
77
 
78
 
@@ -147,115 +146,6 @@ function ampforwp_plugin_parent_activation() {
147
  <div id="ampforwp-network-status"></div>
148
  </div>
149
 
150
- <style>
151
- .install_options{
152
- max-width: 550px;
153
- background: #fff;
154
- border: 1px solid #ddd;
155
- padding: 25px 27px 25px 26px;
156
- border-radius: 2px;
157
- margin-top: 19px;
158
- }
159
- .install_options_left{float:left}
160
- .install_options_right{float:right}
161
- .install_options_right a{
162
- background: #4CAF50;
163
- padding: 11px 20px 12px 20px;
164
- text-decoration: none;
165
- color: #fff;
166
- margin-top: 1px;
167
- display: inline-block;
168
- font-size: 16px;
169
- border-radius: 3px;
170
- }
171
- .getstarted_wrapper{
172
- max-width: 510px;
173
- margin-top: 20px; }
174
- .getstarted_options{ float: left}
175
- .getstarted_options{float: left; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
176
- .getstarted_links{float: right; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
177
- .ampforwp-post-installtion-instructions, .ampforwp-pre-installtion-instructions{ margin-left: 15px;}
178
- .getstarted_ul li{ list-style-type: decimal; list-style-position: inside; }
179
- a.getstarted_btn{
180
- background: #666;
181
- color: #fff;
182
- padding: 9px 35px 9px 35px;
183
- font-size: 13px;
184
- line-height: 1;
185
- text-decoration: none;
186
- margin-top: 8px;
187
- display: inline-block;}
188
- .dashicons-warning, .dashicons-yes{
189
- font-family: dashicons;
190
- font-style: normal;
191
- position: relative;
192
- top: 1px;
193
- font-size: 32px;
194
- margin-right: 18px;
195
- }
196
- .dashicons-yes{
197
- margin-right: 25px;
198
- }
199
- .dashicons-yes:before {
200
- content: "\f147";
201
- background: #388e3c;
202
- color: #fff;
203
- border-radius: 40px;
204
- padding-right: 3px;
205
- padding-top: 1px;
206
- }
207
- .ampforwp-plugin-action-buttons {
208
- text-align:right;
209
- margin-top: 0;
210
- }
211
- .ampforwp-plugin-action-buttons li {
212
- display: inline-block;
213
- margin-left: 1em;
214
- }
215
- .ampforwp-button-con {
216
- padding-right: 15px;
217
- }
218
- .ampforwp-button-install {
219
- background: none repeat scroll 0% 0% #2EA2CC !important;
220
- border-color: #0074A2 !important;
221
- box-shadow: 0px 1px 0px rgba(120, 200, 230, 0.5) inset, 0px 1px 0px rgba(0, 0, 0, 0.15) !important;
222
- color: #FFF !important;
223
- }
224
- .ampforwp-button-install:focus {
225
- box-shadow: 0px 0px 0px 1px #5B9DD9, 0px 0px 2px 1px rgba(30, 140, 190, 0.8) !important;
226
- }
227
- .ampforwp-button-install:hover {
228
- color: #FFF !important;
229
- background: none repeat scroll 0% 0% #5B9DD9 !important;
230
- }
231
- .ampforwp-button-update {
232
- background: none repeat scroll 0% 0% #E74F34 !important;
233
- border-color: #C52F2F !important;
234
- box-shadow: 0px 1px 0px rgba(255, 235, 235, 0.5) inset, 0px 1px 0px rgba(0, 0, 0, 0.15) !important;
235
- color: #FFF !important;
236
- }
237
- .ampforwp-button-update:focus {
238
- box-shadow: 0px 0px 0px 1px #DA3232, 0px 0px 2px 1px rgba(255, 140, 140, 0.8) !important;
239
- }
240
- .ampforwp-button-update:hover {
241
- color: #FFF !important;
242
- background: none repeat scroll 0% 0% #DA3232 !important;
243
- }
244
- .drop-shadow {
245
- position:relative;
246
- background:#fff;
247
- margin-bottom:40px;
248
- }
249
- .drop-shadow:before,
250
- .drop-shadow:after {
251
- content:"";
252
- position:absolute;
253
- z-index:-2;
254
- } .authors{font-style: italic}
255
- .ampforwp-custom-btn a{ font-size: 18px !important; background: #388E3C !important; border: 0px !important; border-radius: 2px !important; box-shadow: none !important; padding: 8px 20px !important; height: auto !important}
256
- .plugin-card-top h4{margin-top: 10px;}
257
- </style>
258
-
259
  <div style="margin-top:30px;" class="wp-list-table widefat plugin-install">
260
  <div id="the-list">
261
 
@@ -390,7 +280,7 @@ function ampforwp_plugin_parent_activation() {
390
  <?php
391
  }
392
 
393
- add_action('admin_footer','ampforwp_offline_admin_notice');
394
  function ampforwp_offline_admin_notice() {
395
 
396
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
@@ -431,3 +321,116 @@ function ampforwp_offline_admin_notice() {
431
  <?php } ?>
432
  <?php
433
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php add_action( 'admin_init', 'ampforwp_welcome_screen_do_activation_redirect' );
 
2
  function ampforwp_welcome_screen_do_activation_redirect() {
3
  // Bail if no activation redirect
4
  if ( ! get_transient( 'ampforwp_welcome_screen_activation_redirect' ) ) {
17
  wp_safe_redirect( add_query_arg( array( 'page' => 'ampforwp-welcome-page' ), admin_url( 'index.php' ) ) );
18
  }
19
 
20
+ // add_action( 'admin_init', 'ampforwp_welcome_screen_do_activation_redirect_parent' );
21
  function ampforwp_welcome_screen_do_activation_redirect_parent() {
22
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
23
  $amp_plugin_activation_check = is_plugin_active( 'amp/amp.php' );
53
  function ampforwp_welcome_screen_content() {
54
  ?>
55
  <div class="wrap">
56
+ <?php // echo ampforwp_plugin_parent_activation(); ?>
57
 
58
  <div class="clear"></div>
59
 
62
  <h1 style="color:#388E3C;font-weight:500"><i class="dashicons dashicons-yes"></i><?php echo __('AMP is now Installed!','accelerated-mobile-pages') ?></h1>
63
  <p style=" font-family: georgia; font-size: 20px; font-style: italic; margin-bottom: 3px; line-height: 1.5; color: #666;"><?php echo __('Thank you so much for installing the AMPforWP plugin!','accelerated-mobile-pages') ?></p>
64
  <p style="font-family: georgia;font-size: 20px;margin-top: 4px;font-style: italic;line-height: 1.5;color: #666;"><?php echo __('Our team works really hard to deliver good user experience to you.','accelerated-mobile-pages') ?></p>
65
+ <div class="install_options">
66
+ <div class="install_options_left">
67
+ <p style="margin-top:0;margin-bottom:0;font-size: 15px;line-height: 1;"><b><?php echo __('Head Over to Settings','accelerated-mobile-pages') ?></b></p>
68
+ <p style="margin-top: 8px;margin-bottom:0px;"><?php echo __('Time to customize the your AMP!','accelerated-mobile-pages') ?></p>
69
+ </div>
70
+ <div class="install_options_right">
71
+ <a href="<?php echo esc_url( admin_url('admin.php?page=amp_options') );?>"><?php echo __('AMP Options Panel','accelerated-mobile-pages') ?></a>
72
+ </div>
73
+ <div class="clear"></div>
74
+ </div>
75
 
76
 
77
 
146
  <div id="ampforwp-network-status"></div>
147
  </div>
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  <div style="margin-top:30px;" class="wp-list-table widefat plugin-install">
150
  <div id="the-list">
151
 
280
  <?php
281
  }
282
 
283
+ // add_action('admin_footer','ampforwp_offline_admin_notice');
284
  function ampforwp_offline_admin_notice() {
285
 
286
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
321
  <?php } ?>
322
  <?php
323
  }
324
+
325
+
326
+ add_action('admin_footer','afdfddf');
327
+ function afdfddf(){?>
328
+ <style>
329
+ .install_options{
330
+ max-width: 550px;
331
+ background: #fff;
332
+ border: 1px solid #ddd;
333
+ padding: 25px 27px 25px 26px;
334
+ border-radius: 2px;
335
+ margin-top: 19px;
336
+ }
337
+ .install_options_left{float:left}
338
+ .install_options_right{float:right}
339
+ .install_options_right a{
340
+ background: #4CAF50;
341
+ padding: 11px 20px 12px 20px;
342
+ text-decoration: none;
343
+ color: #fff;
344
+ margin-top: 1px;
345
+ display: inline-block;
346
+ font-size: 16px;
347
+ border-radius: 3px;
348
+ }
349
+ .getstarted_wrapper{
350
+ max-width: 510px;
351
+ margin-top: 20px; }
352
+ .getstarted_options{ float: left}
353
+ .getstarted_options{float: left; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
354
+ .getstarted_links{float: right; background: #fff; border: 1px solid #ddd; padding: 10px 30px 10px 30px; border-radius: 2px; }
355
+ .ampforwp-post-installtion-instructions, .ampforwp-pre-installtion-instructions{ margin-left: 15px;}
356
+ .getstarted_ul li{ list-style-type: decimal; list-style-position: inside; }
357
+ a.getstarted_btn{
358
+ background: #666;
359
+ color: #fff;
360
+ padding: 9px 35px 9px 35px;
361
+ font-size: 13px;
362
+ line-height: 1;
363
+ text-decoration: none;
364
+ margin-top: 8px;
365
+ display: inline-block;}
366
+ .dashicons-warning, .dashicons-yes{
367
+ font-family: dashicons;
368
+ font-style: normal;
369
+ position: relative;
370
+ top: 1px;
371
+ font-size: 32px;
372
+ margin-right: 18px;
373
+ }
374
+ .dashicons-yes{
375
+ margin-right: 25px;
376
+ }
377
+ .dashicons-yes:before {
378
+ content: "\f147";
379
+ background: #388e3c;
380
+ color: #fff;
381
+ border-radius: 40px;
382
+ padding-right: 3px;
383
+ padding-top: 1px;
384
+ }
385
+ .ampforwp-plugin-action-buttons {
386
+ text-align:right;
387
+ margin-top: 0;
388
+ }
389
+ .ampforwp-plugin-action-buttons li {
390
+ display: inline-block;
391
+ margin-left: 1em;
392
+ }
393
+ .ampforwp-button-con {
394
+ padding-right: 15px;
395
+ }
396
+ .ampforwp-button-install {
397
+ background: none repeat scroll 0% 0% #2EA2CC !important;
398
+ border-color: #0074A2 !important;
399
+ box-shadow: 0px 1px 0px rgba(120, 200, 230, 0.5) inset, 0px 1px 0px rgba(0, 0, 0, 0.15) !important;
400
+ color: #FFF !important;
401
+ }
402
+ .ampforwp-button-install:focus {
403
+ box-shadow: 0px 0px 0px 1px #5B9DD9, 0px 0px 2px 1px rgba(30, 140, 190, 0.8) !important;
404
+ }
405
+ .ampforwp-button-install:hover {
406
+ color: #FFF !important;
407
+ background: none repeat scroll 0% 0% #5B9DD9 !important;
408
+ }
409
+ .ampforwp-button-update {
410
+ background: none repeat scroll 0% 0% #E74F34 !important;
411
+ border-color: #C52F2F !important;
412
+ box-shadow: 0px 1px 0px rgba(255, 235, 235, 0.5) inset, 0px 1px 0px rgba(0, 0, 0, 0.15) !important;
413
+ color: #FFF !important;
414
+ }
415
+ .ampforwp-button-update:focus {
416
+ box-shadow: 0px 0px 0px 1px #DA3232, 0px 0px 2px 1px rgba(255, 140, 140, 0.8) !important;
417
+ }
418
+ .ampforwp-button-update:hover {
419
+ color: #FFF !important;
420
+ background: none repeat scroll 0% 0% #DA3232 !important;
421
+ }
422
+ .drop-shadow {
423
+ position:relative;
424
+ background:#fff;
425
+ margin-bottom:40px;
426
+ }
427
+ .drop-shadow:before,
428
+ .drop-shadow:after {
429
+ content:"";
430
+ position:absolute;
431
+ z-index:-2;
432
+ } .authors{font-style: italic}
433
+ .ampforwp-custom-btn a{ font-size: 18px !important; background: #388E3C !important; border: 0px !important; border-radius: 2px !important; box-shadow: none !important; padding: 8px 20px !important; height: auto !important}
434
+ .plugin-card-top h4{margin-top: 10px;}
435
+ </style>
436
+ <?php }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
4
  Donate link: https://www.paypal.me/Kaludi/5
5
  Requires at least: 3.0
6
  Tested up to: 4.8.1
7
- Stable tag: 0.9.57.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -137,6 +137,16 @@ You can contact me using this url: http://ampforwp.com/contact/
137
 
138
  == Changelog ==
139
 
 
 
 
 
 
 
 
 
 
 
140
  = 0.9.57 (5th August 2017) =
141
  * See the Full changelog https://ampforwp.com/0-9-57-released-compatibility-issue-fixed-62nd-update/
142
 
4
  Donate link: https://www.paypal.me/Kaludi/5
5
  Requires at least: 3.0
6
  Tested up to: 4.8.1
7
+ Stable tag: 0.9.58
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
137
 
138
  == Changelog ==
139
 
140
+ = 0.9.58 (9th August 2017) =
141
+ * View more details on https://ampforwp.com/new/
142
+ * Genesis SEO for AMP support added
143
+ * AMP 0.4.2 Vendor Bundled for making it crash proof
144
+ * Archive desc only on 1st page #1029
145
+ * Ads are not working after 0.9.6 #1030
146
+ * Fixed the Post 0.9.57 Update Bugs #1025
147
+ * All Images are aligned on left side in design 3 #1031
148
+ * Custom frontpage title issue in Design 3 fixed
149
+
150
  = 0.9.57 (5th August 2017) =
151
  * See the Full changelog https://ampforwp.com/0-9-57-released-compatibility-issue-fixed-62nd-update/
152
 
templates/custom-amp-content.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
  // Adding Custom meta Sanitizer to sanitize the custom content added throught tinymce post meta
3
-
4
  add_filter( 'amp_post_template_data', 'ampforwp_custom_post_content_sanitizer', 10, 2 );
5
 
6
  function ampforwp_custom_post_content_sanitizer( $data, $post ) {
1
  <?php
2
  // Adding Custom meta Sanitizer to sanitize the custom content added throught tinymce post meta
 
3
  add_filter( 'amp_post_template_data', 'ampforwp_custom_post_content_sanitizer', 10, 2 );
4
 
5
  function ampforwp_custom_post_content_sanitizer( $data, $post ) {
templates/custom-sanitizer.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php' );
4
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
5
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
@@ -120,4 +119,4 @@ class AMPFORWP_Content_Sanitizer {
120
 
121
  return array( $sanitized_content, $scripts, $styles );
122
  }
123
- }
1
  <?php
 
2
  require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php' );
3
  require_once( AMP__DIR__ . '/includes/sanitizers/class-amp-base-sanitizer.php' );
4
  require_once( AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' );
119
 
120
  return array( $sanitized_content, $scripts, $styles );
121
  }
122
+ }
templates/design-manager/design-1/archive.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php global $redux_builder_amp; ?>
2
  <!doctype html>
3
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
  <head>
@@ -46,11 +46,13 @@
46
  the_archive_title( '<h3 class="page-title">', '</h3>' );
47
 
48
  $arch_desc = $sanitizer->get_amp_content();
49
- if( $arch_desc ) { ?>
50
- <div class="amp-wp-content taxonomy-description">
51
- <?php echo $arch_desc ; ?>
52
- </div> <?php
53
- }
 
 
54
  } ?>
55
 
56
  <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
1
+ <?php global $redux_builder_amp; global $wp; ?>
2
  <!doctype html>
3
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
  <head>
46
  the_archive_title( '<h3 class="page-title">', '</h3>' );
47
 
48
  $arch_desc = $sanitizer->get_amp_content();
49
+ if( $arch_desc ) {
50
+ if($wp->query_vars['paged'] <= '1') {?>
51
+ <div class="amp-wp-content taxonomy-description">
52
+ <?php echo $arch_desc ; ?>
53
+ </div> <?php
54
+ }
55
+ }
56
  } ?>
57
 
58
  <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
templates/design-manager/design-1/elements/content.php CHANGED
@@ -24,22 +24,21 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
24
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
25
  }
26
 
27
- if($redux_builder_amp['amp-pagination']) {
28
- $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
29
- $queried_var = get_query_var('page');
30
- if ( $queried_var > 1 ) {
31
- $queried_var = $queried_var -1 ;
32
- }
33
- else{
34
- $queried_var = 0;
35
- }
36
- echo $ampforwp_new_content[$queried_var];
37
- do_action('ampforwp_after_post_content',$this) ;
38
- }
39
- else{
40
- echo $ampforwp_the_content;
41
- }//#1015 Pegazee
42
- ?>
43
  <!--Post Next-Previous Links-->
44
  <?php
45
  if($redux_builder_amp['enable-single-next-prev']) { ?>
24
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
25
  }
26
 
27
+ if($redux_builder_amp['amp-pagination']) {
28
+ $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
29
+ $queried_var = get_query_var('page');
30
+ if ( $queried_var > 1 ) {
31
+ $queried_var = $queried_var -1 ;
32
+ }
33
+ else {
34
+ $queried_var = 0;
35
+ }
36
+ echo $ampforwp_new_content[$queried_var];
37
+ } else {
38
+ echo $ampforwp_the_content;
39
+ }//#1015 Pegazee
40
+
41
+ do_action('ampforwp_after_post_content',$this) ; ?>
 
42
  <!--Post Next-Previous Links-->
43
  <?php
44
  if($redux_builder_amp['enable-single-next-prev']) { ?>
templates/design-manager/design-2/archive.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php global $redux_builder_amp; ?>
2
  <!doctype html>
3
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
  <head>
@@ -48,10 +48,12 @@
48
  the_archive_title( '<h3 class="page-title">', '</h3>' );
49
 
50
  $arch_desc = $sanitizer->get_amp_content();
51
- if( $arch_desc ) { ?>
52
- <div class="amp-wp-content taxonomy-description">
53
- <?php echo $arch_desc ; ?>
54
- </div> <?php
 
 
55
  } ?>
56
  </div>
57
  <?php
1
+ <?php global $redux_builder_amp; global $wp; ?>
2
  <!doctype html>
3
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
  <head>
48
  the_archive_title( '<h3 class="page-title">', '</h3>' );
49
 
50
  $arch_desc = $sanitizer->get_amp_content();
51
+ if( $arch_desc ) {
52
+ if($wp->query_vars['paged'] <= '1') {?>
53
+ <div class="amp-wp-content taxonomy-description">
54
+ <?php echo $arch_desc ; ?>
55
+ </div> <?php
56
+ }
57
  } ?>
58
  </div>
59
  <?php
templates/design-manager/design-2/elements/content.php CHANGED
@@ -25,22 +25,21 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
25
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
26
  }
27
  // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
28
-
29
- if($redux_builder_amp['amp-pagination']) {
30
- $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
31
- $queried_var = get_query_var('page');
32
- if ( $queried_var > 1 ) {
33
- $queried_var = $queried_var -1 ;
34
- }
35
- else{
36
- $queried_var = 0;
37
- }
38
- echo $ampforwp_new_content[$queried_var];
39
- do_action('ampforwp_after_post_content',$this) ; //Post After Content here
40
- }
41
- else{
42
  echo $ampforwp_the_content;
43
- }//#1015 Pegazee
 
44
  ?>
45
 
46
  </div>
25
  $ampforwp_the_content = $this->get( 'ampforwp_amp_content' );
26
  }
27
  // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
28
+
29
+ if($redux_builder_amp['amp-pagination']) {
30
+ $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
31
+ $queried_var = get_query_var('page');
32
+ if ( $queried_var > 1 ) {
33
+ $queried_var = $queried_var -1 ;
34
+ }
35
+ else{
36
+ $queried_var = 0;
37
+ }
38
+ echo $ampforwp_new_content[$queried_var];
39
+ } else {
 
 
40
  echo $ampforwp_the_content;
41
+ }//#1015 Pegazee
42
+ do_action('ampforwp_after_post_content',$this) ; //Post After Content here
43
  ?>
44
 
45
  </div>
templates/design-manager/design-3/archive.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php global $redux_builder_amp; ?>
2
  <!doctype html>
3
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
  <head>
@@ -68,10 +68,12 @@ if ( get_query_var( 'paged' ) ) {
68
  the_archive_title( '<h3 class="amp-wp-content page-title">', '</h3>' );
69
 
70
  $arch_desc = $sanitizer->get_amp_content();
71
- if( $arch_desc ) { ?>
72
- <div class="amp-wp-content taxonomy-description">
73
- <?php echo $arch_desc ; ?>
74
- </div> <?php
 
 
75
  }
76
  } ?>
77
 
1
+ <?php global $redux_builder_amp; global $wp; ?>
2
  <!doctype html>
3
  <html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
4
  <head>
68
  the_archive_title( '<h3 class="amp-wp-content page-title">', '</h3>' );
69
 
70
  $arch_desc = $sanitizer->get_amp_content();
71
+ if( $arch_desc ) {
72
+ if($wp->query_vars['paged'] <= '1') {?>
73
+ <div class="amp-wp-content taxonomy-description">
74
+ <?php echo $arch_desc ; ?>
75
+ </div> <?php
76
+ }
77
  }
78
  } ?>
79
 
templates/design-manager/design-3/elements/content.php CHANGED
@@ -3,19 +3,18 @@
3
  <!--Post Content here-->
4
  <div class="amp-wp-content the_content">
5
  <?php global $redux_builder_amp;
6
- if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
7
- if($redux_builder_amp['enable-excerpt-single']) {
8
- if(has_excerpt()){ ?>
9
- <div class="ampforwp_single_excerpt">
10
- <?php $content = get_the_excerpt();
11
- echo $content; ?>
12
- </div>
13
- <?php }
14
- }
15
- }
16
- do_action('ampforwp_before_post_content',$this) //Post before Content here ?>
17
 
18
- <?php
19
  $amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
20
 
21
  // Normal Front Page Content
@@ -27,7 +26,7 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
27
  }
28
 
29
  // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
30
- if($redux_builder_amp['amp-pagination']) {
31
  $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
32
  $queried_var = get_query_var('page');
33
  if ( $queried_var > 1 ) {
@@ -37,12 +36,10 @@ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
37
  $queried_var = 0;
38
  }
39
  echo $ampforwp_new_content[$queried_var];
40
- do_action('ampforwp_after_post_content',$this) ; //Post After Content here
41
- }
42
- else{
43
  echo $ampforwp_the_content;
44
- }//#1015 pegazee
45
- ?>
46
  </div>
47
  <!--Post Content Ends here-->
48
 
3
  <!--Post Content here-->
4
  <div class="amp-wp-content the_content">
5
  <?php global $redux_builder_amp;
6
+ if( array_key_exists( 'enable-excerpt-single' , $redux_builder_amp ) ) {
7
+ if($redux_builder_amp['enable-excerpt-single']) {
8
+ if( has_excerpt() ){ ?>
9
+ <div class="ampforwp_single_excerpt">
10
+ <?php $content = get_the_excerpt();
11
+ echo $content; ?>
12
+ </div> <?php
13
+ }
14
+ }
15
+ }
16
+ do_action('ampforwp_before_post_content',$this); //Post before Content here
17
 
 
18
  $amp_custom_content_enable = get_post_meta( $this->get( 'post_id' ) , 'ampforwp_custom_content_editor_checkbox', true);
19
 
20
  // Normal Front Page Content
26
  }
27
 
28
  // echo $this->get( 'post_amp_content' ); // amphtml content; no kses
29
+ if($redux_builder_amp['amp-pagination']) {
30
  $ampforwp_new_content = explode('<!--nextpage-->', $ampforwp_the_content);
31
  $queried_var = get_query_var('page');
32
  if ( $queried_var > 1 ) {
36
  $queried_var = 0;
37
  }
38
  echo $ampforwp_new_content[$queried_var];
39
+ } else{
 
 
40
  echo $ampforwp_the_content;
41
+ }//#1015 pegazee
42
+ do_action('ampforwp_after_post_content',$this) ; //Post After Content here ?>
43
  </div>
44
  <!--Post Content Ends here-->
45
 
templates/design-manager/design-3/style.php CHANGED
@@ -121,9 +121,7 @@ body .amp-loop-list-noimg .amp-wp-post-content{ width:100% }
121
  /* Single */
122
  .single-post main{ margin: 20px 17px 17px 17px; }
123
  .amp-wp-article-content{ font-family:'PT Serif', serif; }
124
- .single-post .post-featured-img, .single-post .amp-wp-article-content amp-img{ margin:0 -17px 17px -17px }
125
- .single-post .amp-wp-article-content .alignleft amp-img { margin-right: 7px; }
126
- .single-post .amp-wp-article-content .alignright amp-img { margin-left: 7px; }
127
  .ampforwp-title{ padding: 0px 0px 0px 0px; margin-top: 12px; margin-bottom: 12px; }
128
  .comment-button-wrapper{ margin-bottom: 50px; margin-top: 30px; text-align:center }
129
  .comment-button-wrapper a{ color: #fff; background: #312c7e; font-size: 14px; padding: 12px 22px 12px 22px; font-family: 'Roboto Slab', serif; border-radius: 2px; text-transform: uppercase; letter-spacing: 1px; }
@@ -142,9 +140,7 @@ h1.amp-wp-title{ margin: 0; color: #333333; font-size: 48px; line-height: 58px;
142
  .amp-wp-tax-tag { list-style: none; display: inline-block; }
143
  figure{ margin: 0 0 20px 0; }
144
  figure amp-img{ max-width:100%; }
145
- figcaption{ font-size: 11px; margin-bottom: 11px; background: #eee; padding: 6px 8px; }
146
- .single-post figcaption{ margin-top: -17px; margin-left: -17px; margin-right: -17px; }
147
- .single-post .alignright figcaption { margin: -17px -7px 0 7px; }
148
  .amp-wp-byline amp-img{ display: none; }
149
  .amp-wp-author{ margin-right: 1px; }
150
  .amp-wp-meta, .amp-wp-meta a{ font-size: 13px; color: #acacac; margin: 20px 0px 20px 0px; padding: 0; }
@@ -289,12 +285,12 @@ table tr:hover td { background: #f2f2f2; background: -webkit-gradient(linear, le
289
  /* Responsive */
290
  @media screen and (min-width: 650px) { table {display: inline-table;} }
291
  @media screen and (min-width:1034px){
292
- .single-post .amp-wp-article-content amp-img{ margin:0 -17px 17px -17px }
293
  }
294
  @media screen and (max-width: 1033px){
295
- .single-post figcaption{ margin: -7px 0px 17px 0px }
296
  }
297
- @media screen and (max-width: 768px){ .amp-wp-meta{ margin:10px 0px 15px 0px } .home-post_image{ width: 40%; } .amp-loop-list .amp-wp-post-content{ width: 58%; } .amp-loop-list .featured_time{line-height:1} .single-post main .amp-wp-content h1{ line-height:1.4; font-size: 30px;} }
298
  @media screen and (max-width: 600px){ .amp-loop-list .amp-wp-tags{display:none} }
299
  @media screen and (max-width: 530px){ .home-post_image{ width: 35%; } .amp-loop-list .amp-wp-post-content{ width: 63%; } .amp-wp-post-content p { font-size: 12px; } .related_posts ol li p { line-height: 1.6; margin: 7px 0 0 0;} .comments_list ul li .comment-body {width:auto} .amp-category-block li:nth-child(3) {margin:0} }
300
  @media screen and (max-width: 425px){ .home-post_image{ /* width: 125px;*/ width: 31.6%; overflow: hidden; height: 100px; /* margin-right: 13px; */ margin-right: 3%; } .home-post_image amp-img{ width: 144%; left: -20%; } h2.amp-wp-title{ margin-bottom: 7px; line-height: 1.31578947; font-size: 19px; position:relative;top:-3px } h2.amp-wp-title a{ color:#262626} .amp-loop-list{padding:25px 15px 22px 15px} .amp-loop-list .amp-wp-post-content{ width: 63%; } .amp-loop-list .amp-wp-post-content p, .related_posts .related_link p{ display:none } .related_posts .related_link a{ font-size: 18px; line-height: 1.7; } .ampforwp-tax-category{ padding-bottom:0 } .amp-wp-byline{ padding:0 } .related_posts .related_link a{ font-size: 17px; line-height: 1.5; } .single-post main .amp-wp-content h1{ line-height: 1.3; font-size: 26px;} .icono-share{display:none} .ampforwp-social-icons amp-social-share{ margin-right: 3px;} main .amp-wp-content{ font-size: 16px; line-height: 26px;} .single-post .amp_author_area .amp_author_area_wrapper{font-size:13px;} .amp-category-post{ font-size:12px; color:#666 } }
@@ -340,9 +336,9 @@ amp-user-notification button { background-color: <?php echo $redux_builder_amp[
340
  <?php if( $redux_builder_amp['enable-single-social-icons'] == true && is_socialshare_or_socialsticky_enabled_in_ampforwp() ) { ?>
341
  .single-post footer { padding-bottom: 41px;}
342
  <?php } ?>
 
343
  .single-post amp-img.alignleft, amp-anim.alignleft{ margin-right: 15px; margin-bottom:5px; float: left;}
344
- .single-post amp-img.alignright, amp-anim.alignright{ float:right; margin-left: 15px; margin-bottom:5px;}
345
- .single-post amp-img.aligncenter, amp-anim.aligncenter{ text-align:center; margin: 0 auto; max-width:100%}
346
  .amp-wp-author:before{ content: " <?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-published-by'], 'Published by' );?> ";}
347
  .ampforwp-tax-category span:last-child:after { content: ' ';}
348
  .ampforwp-tax-category span:after{ content: ', ';}
121
  /* Single */
122
  .single-post main{ margin: 20px 17px 17px 17px; }
123
  .amp-wp-article-content{ font-family:'PT Serif', serif; }
124
+ .single-post .post-featured-img, .single-post .amp-wp-article-content amp-img{ margin:0 17px 0px -17px }
 
 
125
  .ampforwp-title{ padding: 0px 0px 0px 0px; margin-top: 12px; margin-bottom: 12px; }
126
  .comment-button-wrapper{ margin-bottom: 50px; margin-top: 30px; text-align:center }
127
  .comment-button-wrapper a{ color: #fff; background: #312c7e; font-size: 14px; padding: 12px 22px 12px 22px; font-family: 'Roboto Slab', serif; border-radius: 2px; text-transform: uppercase; letter-spacing: 1px; }
140
  .amp-wp-tax-tag { list-style: none; display: inline-block; }
141
  figure{ margin: 0 0 20px 0; }
142
  figure amp-img{ max-width:100%; }
143
+ figcaption{ font-size: 11px; line-height: 1.6; margin-bottom: 11px; background: #eee; padding: 6px 8px; }
 
 
144
  .amp-wp-byline amp-img{ display: none; }
145
  .amp-wp-author{ margin-right: 1px; }
146
  .amp-wp-meta, .amp-wp-meta a{ font-size: 13px; color: #acacac; margin: 20px 0px 20px 0px; padding: 0; }
285
  /* Responsive */
286
  @media screen and (min-width: 650px) { table {display: inline-table;} }
287
  @media screen and (min-width:1034px){
288
+ .single-post .amp-wp-article-content amp-img{ margin:0 auto }
289
  }
290
  @media screen and (max-width: 1033px){
291
+ .single-post figcaption{ margin: 0px 17px 5px -17px; }
292
  }
293
+ @media screen and (max-width: 768px){ .amp-wp-meta{ margin:10px 0px 15px 0px } .home-post_image{ width: 40%; } .amp-loop-list .amp-wp-post-content{ width: 58%; } .amp-loop-list .featured_time{line-height:1} .single-post main .amp-wp-content h1{ line-height:1.4; font-size: 30px;} .single-post .alignright amp-img, .alignright figcaption{margin:0 -17px 0 17px} .alignnone figcaption{margin:0px -17px 5px -17px} }
294
  @media screen and (max-width: 600px){ .amp-loop-list .amp-wp-tags{display:none} }
295
  @media screen and (max-width: 530px){ .home-post_image{ width: 35%; } .amp-loop-list .amp-wp-post-content{ width: 63%; } .amp-wp-post-content p { font-size: 12px; } .related_posts ol li p { line-height: 1.6; margin: 7px 0 0 0;} .comments_list ul li .comment-body {width:auto} .amp-category-block li:nth-child(3) {margin:0} }
296
  @media screen and (max-width: 425px){ .home-post_image{ /* width: 125px;*/ width: 31.6%; overflow: hidden; height: 100px; /* margin-right: 13px; */ margin-right: 3%; } .home-post_image amp-img{ width: 144%; left: -20%; } h2.amp-wp-title{ margin-bottom: 7px; line-height: 1.31578947; font-size: 19px; position:relative;top:-3px } h2.amp-wp-title a{ color:#262626} .amp-loop-list{padding:25px 15px 22px 15px} .amp-loop-list .amp-wp-post-content{ width: 63%; } .amp-loop-list .amp-wp-post-content p, .related_posts .related_link p{ display:none } .related_posts .related_link a{ font-size: 18px; line-height: 1.7; } .ampforwp-tax-category{ padding-bottom:0 } .amp-wp-byline{ padding:0 } .related_posts .related_link a{ font-size: 17px; line-height: 1.5; } .single-post main .amp-wp-content h1{ line-height: 1.3; font-size: 26px;} .icono-share{display:none} .ampforwp-social-icons amp-social-share{ margin-right: 3px;} main .amp-wp-content{ font-size: 16px; line-height: 26px;} .single-post .amp_author_area .amp_author_area_wrapper{font-size:13px;} .amp-category-post{ font-size:12px; color:#666 } }
336
  <?php if( $redux_builder_amp['enable-single-social-icons'] == true && is_socialshare_or_socialsticky_enabled_in_ampforwp() ) { ?>
337
  .single-post footer { padding-bottom: 41px;}
338
  <?php } ?>
339
+ .single-post .alignnone amp-img{ padding: 17px;margin-bottom:0px}
340
  .single-post amp-img.alignleft, amp-anim.alignleft{ margin-right: 15px; margin-bottom:5px; float: left;}
341
+ .single-post amp-img.alignright, amp-anim.alignright{ float:right; margin: 0px -17px 17px 0; }
 
342
  .amp-wp-author:before{ content: " <?php global $redux_builder_amp; echo ampforwp_translation($redux_builder_amp['amp-translator-published-by'], 'Published by' );?> ";}
343
  .ampforwp-tax-category span:last-child:after { content: ' ';}
344
  .ampforwp-tax-category span:after{ content: ', ';}
templates/features.php CHANGED
@@ -86,25 +86,34 @@
86
 
87
 
88
  // 0.9. AMP Design Manager Files
89
- require 'design-manager.php';
90
  // Custom AMP Content
91
- require 'custom-amp-content.php';
92
  // Custom AMPFORWP Sanitizers
93
- require 'custom-sanitizer.php';
94
  // Custom Frontpage items
95
- require 'frontpage-elements.php';
96
  require AMPFORWP_PLUGIN_DIR . '/classes/class-ampforwp-youtube-embed.php' ;
97
 
 
98
  function ampforwp_include_customizer_files(){
99
  $amp_plugin_data;
100
-
101
- $amp_plugin_data = get_plugin_data( AMPFORWP_MAIN_PLUGIN_DIR. 'amp/amp.php' );
102
- if ( $amp_plugin_data['Version'] > '0.4.2' ) {
103
- return require 'customizer/customizer-new.php' ;
104
- } else {
105
- return require 'customizer/customizer.php' ;
106
- }
107
- }
 
 
 
 
 
 
 
 
108
  ampforwp_include_customizer_files();
109
  //0.
110
 
@@ -2506,59 +2515,8 @@ function ampforwp_meta_description() {
2506
  if( !$redux_builder_amp['ampforwp-seo-meta-description'] ){
2507
  return;
2508
  }
2509
-
2510
- global $post;
2511
  $desc = "" ;
2512
-
2513
- if($redux_builder_amp['ampforwp-seo-yoast-description']){
2514
- if ( class_exists('WPSEO_Frontend') ) {
2515
- // general Description of everywhere
2516
- $front = WPSEO_Frontend::get_instance();
2517
- $desc = addslashes( strip_tags( $front->metadesc( false ) ) );
2518
-
2519
- // Static front page
2520
- // Code for Custom Frontpage Yoast SEO Description
2521
- $post_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
2522
- if ( class_exists('WPSEO_Meta') ) {
2523
- if ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) {
2524
- $desc = addslashes( strip_tags( WPSEO_Meta::get_value('metadesc', $post_id ) ) );
2525
- }
2526
- }
2527
- }
2528
- // for search
2529
- if( is_search() ) {
2530
- $desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
2531
- }
2532
- } else {
2533
- if( is_home() ) {
2534
- // normal home page
2535
- $desc= addslashes( strip_tags( get_bloginfo( 'description' ) ) );
2536
- }
2537
-
2538
- if( is_archive() ) {
2539
- $desc= addslashes( strip_tags( get_the_archive_description() ) );
2540
- }
2541
-
2542
- if( is_single() || is_page() ) {
2543
- if( has_excerpt() ){
2544
- $desc = get_the_excerpt();
2545
- } else {
2546
- global $post;
2547
- $id = $post->ID;
2548
- $desc = get_post($id)->post_content;
2549
- }
2550
- $desc = addslashes( wp_trim_words( strip_tags( $desc ) , '15' ) );
2551
- }
2552
-
2553
- if( is_search() ) {
2554
- $desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
2555
- }
2556
-
2557
- if( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) {
2558
- $post_id = $redux_builder_amp['amp-frontpage-select-option-pages'] ;
2559
- $desc = addslashes( wp_trim_words( strip_tags( get_post_field('post_content', $post_id) ) , '15' ) );
2560
- }
2561
- }
2562
 
2563
  // strip_shortcodes strategy not working here so had to do this way
2564
  // strips shortcodes
@@ -3362,4 +3320,87 @@ function ampforwp_add_blacklist_sanitizer($data){
3362
  // Blacklist Sanitizer Added back until we find a better solution to replace it
3363
  $data['AMP_Blacklist_Sanitizer'] = array();
3364
  return $data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3365
  }
86
 
87
 
88
  // 0.9. AMP Design Manager Files
89
+ require AMPFORWP_PLUGIN_DIR .'templates/design-manager.php';
90
  // Custom AMP Content
91
+ require AMPFORWP_PLUGIN_DIR .'templates/custom-amp-content.php';
92
  // Custom AMPFORWP Sanitizers
93
+ require AMPFORWP_PLUGIN_DIR .'templates/custom-sanitizer.php';
94
  // Custom Frontpage items
95
+ require AMPFORWP_PLUGIN_DIR .'templates/frontpage-elements.php';
96
  require AMPFORWP_PLUGIN_DIR . '/classes/class-ampforwp-youtube-embed.php' ;
97
 
98
+ // TODO: Update this function
99
  function ampforwp_include_customizer_files(){
100
  $amp_plugin_data;
101
+ $amp_plugin_activation_check;
102
+
103
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
104
+ $amp_plugin_activation_check = is_plugin_active( 'amp/amp.php' );
105
+
106
+ if ( $amp_plugin_activation_check ) {
107
+ $amp_plugin_data = get_plugin_data( AMPFORWP_MAIN_PLUGIN_DIR. 'amp/amp.php' );
108
+ if ( $amp_plugin_data['Version'] > '0.4.2' ) {
109
+ return require AMPFORWP_PLUGIN_DIR .'templates/customizer/customizer-new.php' ;
110
+ } else {
111
+ return require AMPFORWP_PLUGIN_DIR .'templates/customizer/customizer.php' ;
112
+ }
113
+ } else {
114
+ return require AMPFORWP_PLUGIN_DIR .'templates/customizer/customizer.php' ;
115
+ }
116
+ }
117
  ampforwp_include_customizer_files();
118
  //0.
119
 
2515
  if( !$redux_builder_amp['ampforwp-seo-meta-description'] ){
2516
  return;
2517
  }
 
 
2518
  $desc = "" ;
2519
+ $desc = ampforwp_generate_meta_desc();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2520
 
2521
  // strip_shortcodes strategy not working here so had to do this way
2522
  // strips shortcodes
3320
  // Blacklist Sanitizer Added back until we find a better solution to replace it
3321
  $data['AMP_Blacklist_Sanitizer'] = array();
3322
  return $data;
3323
+ }
3324
+
3325
+ // Genesis SEO #1013
3326
+ add_filter('wp_title', 'genesis_seo_title');
3327
+ add_filter('pre_get_document_title', 'genesis_seo_title');
3328
+
3329
+ function genesis_seo_title( $title ) {
3330
+ if(function_exists('genesis_title')){
3331
+ $genesis_title = genesis_default_title( $title );
3332
+ if( $genesis_title ){
3333
+ $title = $genesis_title;
3334
+ }
3335
+ }
3336
+ return $title;
3337
+ }
3338
+
3339
+ //Meta description #1013
3340
+ function ampforwp_generate_meta_desc(){
3341
+ global $post;
3342
+ //$desc = '';
3343
+
3344
+ if($redux_builder_amp['ampforwp-seo-yoast-description']){
3345
+ if ( class_exists('WPSEO_Frontend') ) {
3346
+ // general Description of everywhere
3347
+ $front = WPSEO_Frontend::get_instance();
3348
+ $desc = addslashes( strip_tags( $front->metadesc( false ) ) );
3349
+
3350
+ // Static front page
3351
+ // Code for Custom Frontpage Yoast SEO Description
3352
+ $post_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
3353
+ if ( class_exists('WPSEO_Meta') ) {
3354
+ if ( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) {
3355
+ $desc = addslashes( strip_tags( WPSEO_Meta::get_value('metadesc', $post_id ) ) );
3356
+ }
3357
+ }
3358
+ }
3359
+ // for search
3360
+ if( is_search() ) {
3361
+ $desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
3362
+ }
3363
+ }
3364
+
3365
+ else {
3366
+ if( is_home() ) {
3367
+ // normal home page
3368
+ $desc= addslashes( strip_tags( get_bloginfo( 'description' ) ) );
3369
+ }
3370
+
3371
+ if( is_archive() ) {
3372
+ $desc= addslashes( strip_tags( get_the_archive_description() ) );
3373
+ }
3374
+
3375
+ if( is_single() || is_page() ) {
3376
+ if( has_excerpt() ){
3377
+ $desc = get_the_excerpt();
3378
+ } else {
3379
+ global $post;
3380
+ $id = $post->ID;
3381
+ $desc = get_post($id)->post_content;
3382
+ }
3383
+ $desc = addslashes( wp_trim_words( strip_tags( $desc ) , '15' ) );
3384
+ }
3385
+
3386
+ if( is_search() ) {
3387
+ $desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
3388
+ }
3389
+
3390
+ if( is_home() && $redux_builder_amp['amp-frontpage-select-option'] ) {
3391
+ $post_id = $redux_builder_amp['amp-frontpage-select-option-pages'] ;
3392
+ $desc = addslashes( wp_trim_words( strip_tags( get_post_field('post_content', $post_id) ) , '15' ) );
3393
+ }
3394
+ }
3395
+
3396
+ //Genesis
3397
+ if(function_exists('genesis_meta')){
3398
+ if(function_exists('genesis_seo_meta_description')){
3399
+ $genesis_description = genesis_get_seo_meta_description();
3400
+ if($genesis_description){
3401
+ $desc = $genesis_description;
3402
+ }
3403
+ }
3404
+ }
3405
+ return $desc;
3406
  }
templates/frontpage-elements.php CHANGED
@@ -185,11 +185,11 @@ function ampforwp_design_2_frontpage_title() {
185
  function ampforwp_design_3_frontpage_title() {
186
  global $redux_builder_amp;
187
  if( $redux_builder_amp['ampforwp-title-on-front-page'] ) { ?>
188
- <header class="amp-wp-article-header ampforwp-title amp-wp-content">
189
  <h1 class="amp-wp-title"> <?php
190
  $ID = $redux_builder_amp['amp-frontpage-select-option-pages'];
191
  echo get_the_title( $ID ) ;?>
192
  </h1>
193
- </header> <?php
194
  }
195
  }
185
  function ampforwp_design_3_frontpage_title() {
186
  global $redux_builder_amp;
187
  if( $redux_builder_amp['ampforwp-title-on-front-page'] ) { ?>
188
+ <main><header class="amp-wp-article-header ampforwp-title amp-wp-content">
189
  <h1 class="amp-wp-title"> <?php
190
  $ID = $redux_builder_amp['amp-frontpage-select-option-pages'];
191
  echo get_the_title( $ID ) ;?>
192
  </h1>
193
+ </header></main><?php
194
  }
195
  }
templates/search-functions.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  // 46. search search search everywhere #615
4
 
5
  add_action('pre_amp_render_post','ampforwp_search_related_functions',12);
1
  <?php
 
2
  // 46. search search search everywhere #615
3
 
4
  add_action('pre_amp_render_post','ampforwp_search_related_functions',12);