Enable jQuery Migrate Helper - Version 1.0.0

Version Description

Download this release

Release Info

Developer Clorith
Plugin Icon wp plugin Enable jQuery Migrate Helper
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
class-jquery-migrate-helper.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class jQuery_Migrate_Helper,
4
+ *
5
+ */
6
+
7
+ if ( ! defined( 'ABSPATH' ) ) {
8
+ die( 'Invalid request.' );
9
+ }
10
+
11
+ class jQuery_Migrate_Helper {
12
+
13
+ private function __construct() {}
14
+
15
+ public static function init_actions() {
16
+ // To be able to replace the src, scripts should not be concatenated.
17
+ if ( ! defined( 'CONCATENATE_SCRIPTS' ) ) {
18
+ define( 'CONCATENATE_SCRIPTS', false );
19
+ }
20
+
21
+ $GLOBALS['concatenate_scripts'] = false;
22
+
23
+ add_action( 'wp_default_scripts', array( __CLASS__, 'replace_scripts' ), -1 );
24
+
25
+ // We need our own script for displaying warnings to run as late as possible.
26
+ // Print it separately after the footer scripts.
27
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'register_scripts' ) );
28
+ add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_scripts' ), 100 );
29
+
30
+ add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
31
+ add_action( 'wp_ajax_jquery-migrate-dismiss-notice', array( __CLASS__, 'admin_notices_dismiss' ) );
32
+ }
33
+
34
+ // Pre-register scripts on 'wp_default_scripts' action, they won't be overwritten by $wp_scripts->add().
35
+ private static function set_script( $scripts, $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
36
+ $script = $scripts->query( $handle, 'registered' );
37
+
38
+ if ( $script ) {
39
+ // If already added
40
+ $script->src = $src;
41
+ $script->deps = $deps;
42
+ $script->ver = $ver;
43
+ $script->args = $in_footer;
44
+
45
+ unset( $script->extra['group'] );
46
+
47
+ if ( $in_footer ) {
48
+ $script->add_data( 'group', 1 );
49
+ }
50
+ } else {
51
+ // Add the script
52
+ if ( $in_footer ) {
53
+ $scripts->add( $handle, $src, $deps, $ver, 1 );
54
+ } else {
55
+ $scripts->add( $handle, $src, $deps, $ver );
56
+ }
57
+ }
58
+ }
59
+
60
+ /*
61
+ * Enqueue jQuery migrate, and force it to be the development version.
62
+ *
63
+ * This will ensure that console errors are generated, and we can surface these to the
64
+ * end user in a responsible manner so that they can update their plugins and theme,
65
+ * or make a decision to switch to other plugin/theme if no updates are available.
66
+ */
67
+ public static function replace_scripts( $scripts ) {
68
+ $assets_url = plugins_url( 'js/', __FILE__ );
69
+
70
+ self::set_script( $scripts, 'jquery-migrate', $assets_url . 'jquery-migrate-1.4.1-wp.js', array(), '1.4.1-wp' );
71
+ self::set_script( $scripts, 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.4-wp' );
72
+ }
73
+
74
+ /**
75
+ * Register the deprecation notice capture handler script.
76
+ */
77
+ public static function register_scripts() {
78
+ wp_register_script( 'jquery-migrate-deprecation-notices', plugins_url( 'js/deprecation-notice.js', __FILE__ ), array( 'jquery' ), false, true );
79
+ }
80
+
81
+ /**
82
+ * Output/print the deprecation notice script. Needs to be last in the footer.
83
+ */
84
+ public static function print_scripts() {
85
+ wp_print_scripts( 'jquery-migrate-deprecation-notices' );
86
+ }
87
+
88
+ /**
89
+ * HTML for jQuery Migrate deprecated notices.
90
+ *
91
+ * This notice is only displayed if there are JS migration deprecation notices
92
+ * for scripts loaded on the current screen.
93
+ *
94
+ * @since 1.0.0
95
+ */
96
+ public static function deprecated_scripts_notice() {
97
+ ?>
98
+
99
+ <div class="notice notice-error is-dismissible jquery-migrate-deprecation-notice hidden">
100
+ <h2><?php _ex( 'jQuery Migrate Helper', 'Admin notice header', 'enable-jquery-migrate-helper' ); ?> &mdash; <?php _ex( 'Warnings encountered', 'enable-jquery-migrate-helper' ); ?></h2>
101
+ <p><?php _e( 'This page generated the following warnings:', 'enable-jquery-migrate-helper' ); ?></p>
102
+
103
+ <ol class="jquery-migrate-deprecation-list"></ol>
104
+
105
+ <p>
106
+ <?php _e( 'Please make sure you are using the latest version of all of your plugins, and your theme.', 'enable-jquery-migrate-helper' ); ?>
107
+ <?php _e( 'If you are, you may want to ask the developers of the code mentioned in the warnings for an update.', 'enable-jquery-migrate-helper' ); ?>
108
+ </p>
109
+ </div>
110
+
111
+ <?php
112
+ }
113
+
114
+ /**
115
+ * HTML for the Dashboard notice.
116
+ */
117
+ public static function dashboard_notice() {
118
+ // Show again in two seeks if the user has dismissed this notice.
119
+ $is_dismissed = get_option( '_jquery_migrate_dismissed_notice', false );
120
+ $recurrence = 2 * WEEK_IN_SECONDS;
121
+
122
+ // If the message has been dismissed, and it has been less than two weeks since it was seen,
123
+ // then skip showing the admin notice for now.
124
+ if ( false !== $is_dismissed && $is_dismissed > ( time() - $recurrence ) ) {
125
+ return;
126
+ }
127
+
128
+ ?>
129
+
130
+ <div class="notice notice-warning is-dismissible jquery-migrate-dashboard-notice">
131
+ <h2><?php _ex( 'jQuery Migrate Helper', 'Admin notice header', 'enable-jquery-migrate-helper' ); ?></h2>
132
+ <p>
133
+ <?php _e( 'Right now you are using the Enable jQuery Migrate Helper plugin to enable support for old JavaScript code that uses deprecated functions in the jQuery JavaScript library.', 'enable-jquery-migrate-helper' ); ?>
134
+ <?php _e( 'You will see warnings about these functions while using WordPress administration, but they will not be shown on the front-end of your site.', 'enable-jquery-migrate-helper' ); ?>
135
+ <?php _e( 'To check if there are any warnings generated by your theme please look in the browser console.', 'enable-jquery-migrate-helper' ); ?>
136
+ </p>
137
+
138
+ <p>
139
+ <?php _e( 'If you get warnings, you should check the theme or plugin that generated them for an update. There will very likely be one you can install.', 'enable-jquery-migrate-helper' ); ?>
140
+ <?php _e( 'When you have updated your plugins and themes, and there are no more warnings, please deactivate Enable jQuery Migrate Helper.', 'enable-jquery-migrate-helper' ); ?>
141
+ </p>
142
+
143
+ <p>
144
+ <?php _e( '* A script, a file, or some other piece of code is deprecated when its developers are in the process of replacing it with more modern code or removing it entirely.', 'enable-jquery-migrate-helper' ); ?>
145
+ </p>
146
+ <?php wp_nonce_field( 'jquery-migrate-notice', 'jquery-migrate-notice-nonce', false ); ?>
147
+ </div>
148
+
149
+ <?php
150
+ }
151
+
152
+ public static function admin_notices() {
153
+ // Show only to admins.
154
+ if ( ! current_user_can( 'update_plugins' ) ) {
155
+ return;
156
+ }
157
+
158
+ if ( get_current_screen()->id === 'dashboard' ) {
159
+ self::dashboard_notice();
160
+ }
161
+
162
+ self::deprecated_scripts_notice();
163
+ }
164
+
165
+ public static function admin_notices_dismiss() {
166
+ if ( empty( POST['dismiss-notice-nonce'] ) || ! current_user_can( 'manage_options' ) ) {
167
+ return;
168
+ }
169
+
170
+ if ( ! wp_verify_nonce( POST['dismiss-notice-nonce'], 'jquery-migrate-notice' ) ) {
171
+ return;
172
+ }
173
+
174
+ update_option( '_jquery_migrate_dismissed_notice', time() );
175
+ }
176
+ }
enable-jquery-migrate-helper.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Enable jQuery Migrate Helper
4
+ Plugin URI: https://wordpress.org/plugins/enable-jquery-migrate-helper
5
+ Description: Enable support for old and outdated plugins and themes during a jQuery update transitional phase.
6
+ Version: 1.0.0
7
+ Requires at least: 5.4
8
+ Tested up to: 5.5
9
+ Requires PHP: 5.6
10
+ Author: The WordPress Team
11
+ Author URI: https://wordpress.org
12
+ Contributors: wordpressdotorg, clorith, azaozz
13
+ License: GPLv2
14
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
+ Text Domain: enable-jquery-migrate-helper
16
+ */
17
+
18
+ if ( ! defined( 'ABSPATH' ) ) {
19
+ die( 'Invalid request.' );
20
+ }
21
+
22
+ if ( version_compare( $GLOBALS['wp_version'], '5.6-alpha', '<' ) && ! class_exists( 'jQuery_Migrate_Helper' ) ) {
23
+ include_once __DIR__ . '/class-jquery-migrate-helper.php';
24
+ add_action( 'plugins_loaded', array( 'jQuery_Migrate_Helper', 'init_actions' ) );
25
+ }
js/deprecation-notice.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Show all jQuery Migrate warnings in the UI.
3
+ */
4
+ jQuery( document ).ready( function( $ ) {
5
+ const notice = $( '.notice.jquery-migrate-deprecation-notice' );
6
+ const warnings = jQuery.migrateWarnings;
7
+
8
+ /**
9
+ * Filter the trace, return the first URI that is to a plugin or theme script.
10
+ */
11
+ function getPluginSlugFromTrace( trace ) {
12
+ let traceLines = trace.split( '\n' ),
13
+ match = null;
14
+
15
+ // Loop over each line in the stack trace
16
+ traceLines.forEach( function( line ) {
17
+ if ( ! line ) {
18
+ return;
19
+ }
20
+
21
+ // Remove cache-busting.
22
+ line = line.split( '?' )[0];
23
+
24
+ // The first few lines are going to be references to the jquery-migrate script.
25
+ // The first instance that is not one of them is probably a valid plugin or theme.
26
+ if (
27
+ ! match &&
28
+ line.indexOf( '/jquery-migrate-helper/js' ) === -1 &&
29
+ line.indexOf( '/enable-jquery-migrate-helper/js' ) === -1 &&
30
+ ( line.indexOf( '/plugins/' ) > -1 || line.indexOf( '/themes/' ) > -1 )
31
+ ) {
32
+ match = line.replace( /.*?http/, 'http' );
33
+ }
34
+ } );
35
+
36
+ // If the stack trace did not contain a matching plugin or theme, just return a null value.
37
+ return match;
38
+ }
39
+
40
+ if ( notice.length && warnings.length ) {
41
+ const list = notice.find( '.jquery-migrate-deprecation-list' );
42
+
43
+ notice.show();
44
+
45
+ warnings.forEach( function( entry ) {
46
+ const trace = getPluginSlugFromTrace( entry.trace );
47
+ let message = trace ? trace + ': ' : '';
48
+
49
+ message += entry.warning;
50
+ list.append( $( '<li></li>' ).text( message ) );
51
+ } );
52
+ }
53
+
54
+ // Add handler for dismissing of the dashboard notice.
55
+ $( document ).on( 'click', '.jquery-migrate-dashboard-notice .notice-dismiss', function() {
56
+ $.post( {
57
+ url: window.ajaxurl,
58
+ data: {
59
+ action: 'jquery-migrate-dismiss-notice',
60
+ 'dismiss-notice-nonce': $( '#jquery-migrate-notice-nonce' ).val(),
61
+ },
62
+ } );
63
+ } );
64
+ } );
js/jquery-migrate-1.4.1-wp.js ADDED
@@ -0,0 +1,763 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery Migrate - v1.4.1 - 2016-05-19
3
+ * Copyright jQuery Foundation and other contributors
4
+ */
5
+ (function( jQuery, window, undefined ) {
6
+ // See http://bugs.jquery.com/ticket/13335
7
+ // "use strict";
8
+
9
+
10
+ jQuery.migrateVersion = "1.4.1";
11
+
12
+
13
+ var warnedAbout = {};
14
+
15
+ // List of warnings already given; public read only
16
+ jQuery.migrateWarnings = [];
17
+
18
+ // Set to true to prevent console output; migrateWarnings still maintained
19
+ // jQuery.migrateMute = false;
20
+
21
+ // Show a message on the console so devs know we're active
22
+ if ( window.console && window.console.log ) {
23
+ window.console.log( "JQMIGRATE: Migrate is installed" +
24
+ ( jQuery.migrateMute ? "" : " with logging active" ) +
25
+ ", version " + jQuery.migrateVersion );
26
+ }
27
+
28
+ // Set to false to disable traces that appear with warnings
29
+ if ( jQuery.migrateTrace === undefined ) {
30
+ jQuery.migrateTrace = true;
31
+ }
32
+
33
+ // Forget any warnings we've already given; public
34
+ jQuery.migrateReset = function() {
35
+ warnedAbout = {};
36
+ jQuery.migrateWarnings.length = 0;
37
+ };
38
+
39
+ function migrateWarn( msg) {
40
+ var console = window.console;
41
+ var error = new Error();
42
+
43
+ // WP: Add all warnings to jQuery.migrateWarnings.
44
+ var tracedError = {
45
+ warning: msg,
46
+ trace: error.stack || error
47
+ };
48
+
49
+ jQuery.migrateWarnings.push( tracedError );
50
+ // WP: end.
51
+
52
+ if ( ! warnedAbout[ msg ] ) {
53
+ warnedAbout[ msg ] = true;
54
+
55
+ if ( console && console.warn && !jQuery.migrateMute ) {
56
+ console.warn( "JQMIGRATE: " + msg );
57
+ if ( jQuery.migrateTrace && console.trace ) {
58
+ console.trace();
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ function migrateWarnProp( obj, prop, value, msg ) {
65
+ if ( Object.defineProperty ) {
66
+ // On ES5 browsers (non-oldIE), warn if the code tries to get prop;
67
+ // allow property to be overwritten in case some other plugin wants it
68
+ try {
69
+ Object.defineProperty( obj, prop, {
70
+ configurable: true,
71
+ enumerable: true,
72
+ get: function() {
73
+ migrateWarn( msg );
74
+ return value;
75
+ },
76
+ set: function( newValue ) {
77
+ migrateWarn( msg );
78
+ value = newValue;
79
+ }
80
+ });
81
+ return;
82
+ } catch( err ) {
83
+ // IE8 is a dope about Object.defineProperty, can't warn there
84
+ }
85
+ }
86
+
87
+ // Non-ES5 (or broken) browser; just set the property
88
+ jQuery._definePropertyBroken = true;
89
+ obj[ prop ] = value;
90
+ }
91
+
92
+ if ( document.compatMode === "BackCompat" ) {
93
+ // jQuery has never supported or tested Quirks Mode
94
+ migrateWarn( "jQuery is not compatible with Quirks Mode" );
95
+ }
96
+
97
+
98
+ var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
99
+ oldAttr = jQuery.attr,
100
+ valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
101
+ function() { return null; },
102
+ valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
103
+ function() { return undefined; },
104
+ rnoType = /^(?:input|button)$/i,
105
+ rnoAttrNodeType = /^[238]$/,
106
+ rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
107
+ ruseDefault = /^(?:checked|selected)$/i;
108
+
109
+ // jQuery.attrFn
110
+ migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
111
+
112
+ jQuery.attr = function( elem, name, value, pass ) {
113
+ var lowerName = name.toLowerCase(),
114
+ nType = elem && elem.nodeType;
115
+
116
+ if ( pass ) {
117
+ // Since pass is used internally, we only warn for new jQuery
118
+ // versions where there isn't a pass arg in the formal params
119
+ if ( oldAttr.length < 4 ) {
120
+ migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
121
+ }
122
+ if ( elem && !rnoAttrNodeType.test( nType ) &&
123
+ (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
124
+ return jQuery( elem )[ name ]( value );
125
+ }
126
+ }
127
+
128
+ // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
129
+ // for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
130
+ if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
131
+ migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
132
+ }
133
+
134
+ // Restore boolHook for boolean property/attribute synchronization
135
+ if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
136
+ jQuery.attrHooks[ lowerName ] = {
137
+ get: function( elem, name ) {
138
+ // Align boolean attributes with corresponding properties
139
+ // Fall back to attribute presence where some booleans are not supported
140
+ var attrNode,
141
+ property = jQuery.prop( elem, name );
142
+ return property === true || typeof property !== "boolean" &&
143
+ ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
144
+
145
+ name.toLowerCase() :
146
+ undefined;
147
+ },
148
+ set: function( elem, value, name ) {
149
+ var propName;
150
+ if ( value === false ) {
151
+ // Remove boolean attributes when set to false
152
+ jQuery.removeAttr( elem, name );
153
+ } else {
154
+ // value is true since we know at this point it's type boolean and not false
155
+ // Set boolean attributes to the same name and set the DOM property
156
+ propName = jQuery.propFix[ name ] || name;
157
+ if ( propName in elem ) {
158
+ // Only set the IDL specifically if it already exists on the element
159
+ elem[ propName ] = true;
160
+ }
161
+
162
+ elem.setAttribute( name, name.toLowerCase() );
163
+ }
164
+ return name;
165
+ }
166
+ };
167
+
168
+ // Warn only for attributes that can remain distinct from their properties post-1.9
169
+ if ( ruseDefault.test( lowerName ) ) {
170
+ migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" );
171
+ }
172
+ }
173
+
174
+ return oldAttr.call( jQuery, elem, name, value );
175
+ };
176
+
177
+ // attrHooks: value
178
+ jQuery.attrHooks.value = {
179
+ get: function( elem, name ) {
180
+ var nodeName = ( elem.nodeName || "" ).toLowerCase();
181
+ if ( nodeName === "button" ) {
182
+ return valueAttrGet.apply( this, arguments );
183
+ }
184
+ if ( nodeName !== "input" && nodeName !== "option" ) {
185
+ migrateWarn("jQuery.fn.attr('value') no longer gets properties");
186
+ }
187
+ return name in elem ?
188
+ elem.value :
189
+ null;
190
+ },
191
+ set: function( elem, value ) {
192
+ var nodeName = ( elem.nodeName || "" ).toLowerCase();
193
+ if ( nodeName === "button" ) {
194
+ return valueAttrSet.apply( this, arguments );
195
+ }
196
+ if ( nodeName !== "input" && nodeName !== "option" ) {
197
+ migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
198
+ }
199
+ // Does not return so that setAttribute is also used
200
+ elem.value = value;
201
+ }
202
+ };
203
+
204
+
205
+ var matched, browser,
206
+ oldInit = jQuery.fn.init,
207
+ oldFind = jQuery.find,
208
+ oldParseJSON = jQuery.parseJSON,
209
+ rspaceAngle = /^\s*</,
210
+ rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
211
+ rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
212
+ // Note: XSS check is done below after string is trimmed
213
+ rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
214
+
215
+ // $(html) "looks like html" rule change
216
+ jQuery.fn.init = function( selector, context, rootjQuery ) {
217
+ var match, ret;
218
+
219
+ if ( selector && typeof selector === "string" ) {
220
+ if ( !jQuery.isPlainObject( context ) &&
221
+ (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
222
+
223
+ // This is an HTML string according to the "old" rules; is it still?
224
+ if ( !rspaceAngle.test( selector ) ) {
225
+ migrateWarn("$(html) HTML strings must start with '<' character");
226
+ }
227
+ if ( match[ 3 ] ) {
228
+ migrateWarn("$(html) HTML text after last tag is ignored");
229
+ }
230
+
231
+ // Consistently reject any HTML-like string starting with a hash (gh-9521)
232
+ // Note that this may break jQuery 1.6.x code that otherwise would work.
233
+ if ( match[ 0 ].charAt( 0 ) === "#" ) {
234
+ migrateWarn("HTML string cannot start with a '#' character");
235
+ jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
236
+ }
237
+
238
+ // Now process using loose rules; let pre-1.8 play too
239
+ // Is this a jQuery context? parseHTML expects a DOM element (#178)
240
+ if ( context && context.context && context.context.nodeType ) {
241
+ context = context.context;
242
+ }
243
+
244
+ if ( jQuery.parseHTML ) {
245
+ return oldInit.call( this,
246
+ jQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||
247
+ context || document, true ), context, rootjQuery );
248
+ }
249
+ }
250
+ }
251
+
252
+ ret = oldInit.apply( this, arguments );
253
+
254
+ // Fill in selector and context properties so .live() works
255
+ if ( selector && selector.selector !== undefined ) {
256
+ // A jQuery object, copy its properties
257
+ ret.selector = selector.selector;
258
+ ret.context = selector.context;
259
+
260
+ } else {
261
+ ret.selector = typeof selector === "string" ? selector : "";
262
+ if ( selector ) {
263
+ ret.context = selector.nodeType? selector : context || document;
264
+ }
265
+ }
266
+
267
+ return ret;
268
+ };
269
+ jQuery.fn.init.prototype = jQuery.fn;
270
+
271
+ jQuery.find = function( selector ) {
272
+ var args = Array.prototype.slice.call( arguments );
273
+
274
+ // Support: PhantomJS 1.x
275
+ // String#match fails to match when used with a //g RegExp, only on some strings
276
+ if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
277
+
278
+ // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
279
+ // First see if qS thinks it's a valid selector, if so avoid a false positive
280
+ try {
281
+ document.querySelector( selector );
282
+ } catch ( err1 ) {
283
+
284
+ // Didn't *look* valid to qSA, warn and try quoting what we think is the value
285
+ selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
286
+ return "[" + attr + op + "\"" + value + "\"]";
287
+ } );
288
+
289
+ // If the regexp *may* have created an invalid selector, don't update it
290
+ // Note that there may be false alarms if selector uses jQuery extensions
291
+ try {
292
+ document.querySelector( selector );
293
+ migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
294
+ args[ 0 ] = selector;
295
+ } catch ( err2 ) {
296
+ migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
297
+ }
298
+ }
299
+ }
300
+
301
+ return oldFind.apply( this, args );
302
+ };
303
+
304
+ // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
305
+ var findProp;
306
+ for ( findProp in oldFind ) {
307
+ if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
308
+ jQuery.find[ findProp ] = oldFind[ findProp ];
309
+ }
310
+ }
311
+
312
+ // Let $.parseJSON(falsy_value) return null
313
+ jQuery.parseJSON = function( json ) {
314
+ if ( !json ) {
315
+ migrateWarn("jQuery.parseJSON requires a valid JSON string");
316
+ return null;
317
+ }
318
+ return oldParseJSON.apply( this, arguments );
319
+ };
320
+
321
+ jQuery.uaMatch = function( ua ) {
322
+ ua = ua.toLowerCase();
323
+
324
+ var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
325
+ /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
326
+ /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
327
+ /(msie) ([\w.]+)/.exec( ua ) ||
328
+ ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
329
+ [];
330
+
331
+ return {
332
+ browser: match[ 1 ] || "",
333
+ version: match[ 2 ] || "0"
334
+ };
335
+ };
336
+
337
+ // Don't clobber any existing jQuery.browser in case it's different
338
+ if ( !jQuery.browser ) {
339
+ matched = jQuery.uaMatch( navigator.userAgent );
340
+ browser = {};
341
+
342
+ if ( matched.browser ) {
343
+ browser[ matched.browser ] = true;
344
+ browser.version = matched.version;
345
+ }
346
+
347
+ // Chrome is Webkit, but Webkit is also Safari.
348
+ if ( browser.chrome ) {
349
+ browser.webkit = true;
350
+ } else if ( browser.webkit ) {
351
+ browser.safari = true;
352
+ }
353
+
354
+ jQuery.browser = browser;
355
+ }
356
+
357
+ // Warn if the code tries to get jQuery.browser
358
+ migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
359
+
360
+ // jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
361
+ jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat");
362
+ migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" );
363
+ migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" );
364
+
365
+ jQuery.sub = function() {
366
+ function jQuerySub( selector, context ) {
367
+ return new jQuerySub.fn.init( selector, context );
368
+ }
369
+ jQuery.extend( true, jQuerySub, this );
370
+ jQuerySub.superclass = this;
371
+ jQuerySub.fn = jQuerySub.prototype = this();
372
+ jQuerySub.fn.constructor = jQuerySub;
373
+ jQuerySub.sub = this.sub;
374
+ jQuerySub.fn.init = function init( selector, context ) {
375
+ var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );
376
+ return instance instanceof jQuerySub ?
377
+ instance :
378
+ jQuerySub( instance );
379
+ };
380
+ jQuerySub.fn.init.prototype = jQuerySub.fn;
381
+ var rootjQuerySub = jQuerySub(document);
382
+ migrateWarn( "jQuery.sub() is deprecated" );
383
+ return jQuerySub;
384
+ };
385
+
386
+ // The number of elements contained in the matched element set
387
+ jQuery.fn.size = function() {
388
+ migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
389
+ return this.length;
390
+ };
391
+
392
+
393
+ var internalSwapCall = false;
394
+
395
+ // If this version of jQuery has .swap(), don't false-alarm on internal uses
396
+ if ( jQuery.swap ) {
397
+ jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
398
+ var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
399
+
400
+ if ( oldHook ) {
401
+ jQuery.cssHooks[ name ].get = function() {
402
+ var ret;
403
+
404
+ internalSwapCall = true;
405
+ ret = oldHook.apply( this, arguments );
406
+ internalSwapCall = false;
407
+ return ret;
408
+ };
409
+ }
410
+ });
411
+ }
412
+
413
+ jQuery.swap = function( elem, options, callback, args ) {
414
+ var ret, name,
415
+ old = {};
416
+
417
+ if ( !internalSwapCall ) {
418
+ migrateWarn( "jQuery.swap() is undocumented and deprecated" );
419
+ }
420
+
421
+ // Remember the old values, and insert the new ones
422
+ for ( name in options ) {
423
+ old[ name ] = elem.style[ name ];
424
+ elem.style[ name ] = options[ name ];
425
+ }
426
+
427
+ ret = callback.apply( elem, args || [] );
428
+
429
+ // Revert the old values
430
+ for ( name in options ) {
431
+ elem.style[ name ] = old[ name ];
432
+ }
433
+
434
+ return ret;
435
+ };
436
+
437
+
438
+ // Ensure that $.ajax gets the new parseJSON defined in core.js
439
+ jQuery.ajaxSetup({
440
+ converters: {
441
+ "text json": jQuery.parseJSON
442
+ }
443
+ });
444
+
445
+
446
+ var oldFnData = jQuery.fn.data;
447
+
448
+ jQuery.fn.data = function( name ) {
449
+ var ret, evt,
450
+ elem = this[0];
451
+
452
+ // Handles 1.7 which has this behavior and 1.8 which doesn't
453
+ if ( elem && name === "events" && arguments.length === 1 ) {
454
+ ret = jQuery.data( elem, name );
455
+ evt = jQuery._data( elem, name );
456
+ if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
457
+ migrateWarn("Use of jQuery.fn.data('events') is deprecated");
458
+ return evt;
459
+ }
460
+ }
461
+ return oldFnData.apply( this, arguments );
462
+ };
463
+
464
+
465
+ var rscriptType = /\/(java|ecma)script/i;
466
+
467
+ // Since jQuery.clean is used internally on older versions, we only shim if it's missing
468
+ if ( !jQuery.clean ) {
469
+ jQuery.clean = function( elems, context, fragment, scripts ) {
470
+ // Set context per 1.8 logic
471
+ context = context || document;
472
+ context = !context.nodeType && context[0] || context;
473
+ context = context.ownerDocument || context;
474
+
475
+ migrateWarn("jQuery.clean() is deprecated");
476
+
477
+ var i, elem, handleScript, jsTags,
478
+ ret = [];
479
+
480
+ jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
481
+
482
+ // Complex logic lifted directly from jQuery 1.8
483
+ if ( fragment ) {
484
+ // Special handling of each script element
485
+ handleScript = function( elem ) {
486
+ // Check if we consider it executable
487
+ if ( !elem.type || rscriptType.test( elem.type ) ) {
488
+ // Detach the script and store it in the scripts array (if provided) or the fragment
489
+ // Return truthy to indicate that it has been handled
490
+ return scripts ?
491
+ scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
492
+ fragment.appendChild( elem );
493
+ }
494
+ };
495
+
496
+ for ( i = 0; (elem = ret[i]) != null; i++ ) {
497
+ // Check if we're done after handling an executable script
498
+ if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
499
+ // Append to fragment and handle embedded scripts
500
+ fragment.appendChild( elem );
501
+ if ( typeof elem.getElementsByTagName !== "undefined" ) {
502
+ // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
503
+ jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
504
+
505
+ // Splice the scripts into ret after their former ancestor and advance our index beyond them
506
+ ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
507
+ i += jsTags.length;
508
+ }
509
+ }
510
+ }
511
+ }
512
+
513
+ return ret;
514
+ };
515
+ }
516
+
517
+ var eventAdd = jQuery.event.add,
518
+ eventRemove = jQuery.event.remove,
519
+ eventTrigger = jQuery.event.trigger,
520
+ oldToggle = jQuery.fn.toggle,
521
+ oldLive = jQuery.fn.live,
522
+ oldDie = jQuery.fn.die,
523
+ oldLoad = jQuery.fn.load,
524
+ ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
525
+ rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
526
+ rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
527
+ hoverHack = function( events ) {
528
+ if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
529
+ return events;
530
+ }
531
+ if ( rhoverHack.test( events ) ) {
532
+ migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
533
+ }
534
+ return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
535
+ };
536
+
537
+ // Event props removed in 1.9, put them back if needed; no practical way to warn them
538
+ if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
539
+ jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
540
+ }
541
+
542
+ // Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
543
+ if ( jQuery.event.dispatch ) {
544
+ migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
545
+ }
546
+
547
+ // Support for 'hover' pseudo-event and ajax event warnings
548
+ jQuery.event.add = function( elem, types, handler, data, selector ){
549
+ if ( elem !== document && rajaxEvent.test( types ) ) {
550
+ migrateWarn( "AJAX events should be attached to document: " + types );
551
+ }
552
+ eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
553
+ };
554
+ jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
555
+ eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
556
+ };
557
+
558
+ jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
559
+
560
+ jQuery.fn[ name ] = function() {
561
+ var args = Array.prototype.slice.call( arguments, 0 );
562
+
563
+ // If this is an ajax load() the first arg should be the string URL;
564
+ // technically this could also be the "Anything" arg of the event .load()
565
+ // which just goes to show why this dumb signature has been deprecated!
566
+ // jQuery custom builds that exclude the Ajax module justifiably die here.
567
+ if ( name === "load" && typeof args[ 0 ] === "string" ) {
568
+ return oldLoad.apply( this, args );
569
+ }
570
+
571
+ migrateWarn( "jQuery.fn." + name + "() is deprecated" );
572
+
573
+ args.splice( 0, 0, name );
574
+ if ( arguments.length ) {
575
+ return this.bind.apply( this, args );
576
+ }
577
+
578
+ // Use .triggerHandler here because:
579
+ // - load and unload events don't need to bubble, only applied to window or image
580
+ // - error event should not bubble to window, although it does pre-1.7
581
+ // See http://bugs.jquery.com/ticket/11820
582
+ this.triggerHandler.apply( this, args );
583
+ return this;
584
+ };
585
+
586
+ });
587
+
588
+ jQuery.fn.toggle = function( fn, fn2 ) {
589
+
590
+ // Don't mess with animation or css toggles
591
+ if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
592
+ return oldToggle.apply( this, arguments );
593
+ }
594
+ migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
595
+
596
+ // Save reference to arguments for access in closure
597
+ var args = arguments,
598
+ guid = fn.guid || jQuery.guid++,
599
+ i = 0,
600
+ toggler = function( event ) {
601
+ // Figure out which function to execute
602
+ var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
603
+ jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
604
+
605
+ // Make sure that clicks stop
606
+ event.preventDefault();
607
+
608
+ // and execute the function
609
+ return args[ lastToggle ].apply( this, arguments ) || false;
610
+ };
611
+
612
+ // link all the functions, so any of them can unbind this click handler
613
+ toggler.guid = guid;
614
+ while ( i < args.length ) {
615
+ args[ i++ ].guid = guid;
616
+ }
617
+
618
+ return this.click( toggler );
619
+ };
620
+
621
+ jQuery.fn.live = function( types, data, fn ) {
622
+ migrateWarn("jQuery.fn.live() is deprecated");
623
+ if ( oldLive ) {
624
+ return oldLive.apply( this, arguments );
625
+ }
626
+ jQuery( this.context ).on( types, this.selector, data, fn );
627
+ return this;
628
+ };
629
+
630
+ jQuery.fn.die = function( types, fn ) {
631
+ migrateWarn("jQuery.fn.die() is deprecated");
632
+ if ( oldDie ) {
633
+ return oldDie.apply( this, arguments );
634
+ }
635
+ jQuery( this.context ).off( types, this.selector || "**", fn );
636
+ return this;
637
+ };
638
+
639
+ // Turn global events into document-triggered events
640
+ jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
641
+ if ( !elem && !rajaxEvent.test( event ) ) {
642
+ migrateWarn( "Global events are undocumented and deprecated" );
643
+ }
644
+ return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
645
+ };
646
+ jQuery.each( ajaxEvents.split("|"),
647
+ function( _, name ) {
648
+ jQuery.event.special[ name ] = {
649
+ setup: function() {
650
+ var elem = this;
651
+
652
+ // The document needs no shimming; must be !== for oldIE
653
+ if ( elem !== document ) {
654
+ jQuery.event.add( document, name + "." + jQuery.guid, function() {
655
+ jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );
656
+ });
657
+ jQuery._data( this, name, jQuery.guid++ );
658
+ }
659
+ return false;
660
+ },
661
+ teardown: function() {
662
+ if ( this !== document ) {
663
+ jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
664
+ }
665
+ return false;
666
+ }
667
+ };
668
+ }
669
+ );
670
+
671
+ jQuery.event.special.ready = {
672
+ setup: function() {
673
+ if ( this === document ) {
674
+ migrateWarn( "'ready' event is deprecated" );
675
+ }
676
+ }
677
+ };
678
+
679
+ var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
680
+ oldFnFind = jQuery.fn.find;
681
+
682
+ jQuery.fn.andSelf = function() {
683
+ migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
684
+ return oldSelf.apply( this, arguments );
685
+ };
686
+
687
+ jQuery.fn.find = function( selector ) {
688
+ var ret = oldFnFind.apply( this, arguments );
689
+ ret.context = this.context;
690
+ ret.selector = this.selector ? this.selector + " " + selector : selector;
691
+ return ret;
692
+ };
693
+
694
+
695
+ // jQuery 1.6 did not support Callbacks, do not warn there
696
+ if ( jQuery.Callbacks ) {
697
+
698
+ var oldDeferred = jQuery.Deferred,
699
+ tuples = [
700
+ // action, add listener, callbacks, .then handlers, final state
701
+ [ "resolve", "done", jQuery.Callbacks("once memory"),
702
+ jQuery.Callbacks("once memory"), "resolved" ],
703
+ [ "reject", "fail", jQuery.Callbacks("once memory"),
704
+ jQuery.Callbacks("once memory"), "rejected" ],
705
+ [ "notify", "progress", jQuery.Callbacks("memory"),
706
+ jQuery.Callbacks("memory") ]
707
+ ];
708
+
709
+ jQuery.Deferred = function( func ) {
710
+ var deferred = oldDeferred(),
711
+ promise = deferred.promise();
712
+
713
+ deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
714
+ var fns = arguments;
715
+
716
+ migrateWarn( "deferred.pipe() is deprecated" );
717
+
718
+ return jQuery.Deferred(function( newDefer ) {
719
+ jQuery.each( tuples, function( i, tuple ) {
720
+ var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
721
+ // deferred.done(function() { bind to newDefer or newDefer.resolve })
722
+ // deferred.fail(function() { bind to newDefer or newDefer.reject })
723
+ // deferred.progress(function() { bind to newDefer or newDefer.notify })
724
+ deferred[ tuple[1] ](function() {
725
+ var returned = fn && fn.apply( this, arguments );
726
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
727
+ returned.promise()
728
+ .done( newDefer.resolve )
729
+ .fail( newDefer.reject )
730
+ .progress( newDefer.notify );
731
+ } else {
732
+ newDefer[ tuple[ 0 ] + "With" ](
733
+ this === promise ? newDefer.promise() : this,
734
+ fn ? [ returned ] : arguments
735
+ );
736
+ }
737
+ });
738
+ });
739
+ fns = null;
740
+ }).promise();
741
+
742
+ };
743
+
744
+ deferred.isResolved = function() {
745
+ migrateWarn( "deferred.isResolved is deprecated" );
746
+ return deferred.state() === "resolved";
747
+ };
748
+
749
+ deferred.isRejected = function() {
750
+ migrateWarn( "deferred.isRejected is deprecated" );
751
+ return deferred.state() === "rejected";
752
+ };
753
+
754
+ if ( func ) {
755
+ func.call( deferred, deferred );
756
+ }
757
+
758
+ return deferred;
759
+ };
760
+
761
+ }
762
+
763
+ })( jQuery, window );
readme.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Enable jQuery Migrate Helper ===
2
+ Contributors: wordpressdotorg, clorith, azaozz
3
+ Requires at least: 5.4
4
+ Tested up to: 5.5
5
+ Stable tag: 1.0.0
6
+ Requires PHP: 5.6
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ == Description ==
11
+
12
+ With the update to WordPress 5.5, a migration tool known as `jquery-migrate` will no longer be enabled by default. This may lead to unexpected behaviors in some themes or plugins who run older code.
13
+
14
+ This plugin serves as a temporary solution, enabling the migration script for your site to give your plugin and theme authors some more time to update, and test, their code.
15
+
16
+ == Frequently Asked Questions ==
17
+
18
+ = What does it mean that something is "deprecated" =
19
+ A script, a file, or some other piece of code is deprecated when its developers are in the process of replacing it with more modern code or removing it entirely.
20
+
21
+ = How do I find and use the browser console =
22
+ WordPress.org has an article about [using the browsers console log to diagnose JavaScript errors](https://wordpress.org/support/article/using-your-browser-to-diagnose-javascript-errors/).
23
+
24
+ == Installation ==
25
+
26
+ 1. Upload to your plugins folder, usually `wp-content/plugins/`.
27
+ 2. Activate the plugin on the plugin screen.
28
+ 3. That's it! The plugin handles the rest automatically for you.
29
+
30
+ == Changelog ==
31
+
32
+ = v 1.0.0 =
33
+ * Initial release.