PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 6.0.4
Admin and Site Enhancements (ASE) v6.0.4
9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / assets / js / admin-page.js
admin-site-enhancements / assets / js Last commit date
codemirror 2 years ago datatables 2 years ago admin-page.js 2 years ago content-order-sort.js 2 years ago custom-admin-menu.js 2 years ago external-permalinks.js 2 years ago hide-admin-notices.js 2 years ago jBox.all.min.js 2 years ago jquery.jsticky.mod.js 2 years ago jquery.jsticky.mod.min.js 2 years ago jquery.mjs.nestedSortable.js 2 years ago jquery.ui.touch-punch.min.js 2 years ago js.cookie.min.js 2 years ago media-replace.js 2 years ago multiple-user-roles.js 2 years ago toggle-hidden-menu.js 2 years ago
admin-page.js
735 lines
1 (function( $ ) {
2 'use strict';
3
4 $(document).ready( function() {
5
6 // Make page header sticky on scroll. Using https://github.com/AndrewHenderson/jSticky
7 $('#asenha-header').sticky({
8 topSpacing: 0, // Space between element and top of the viewport (in pixels)
9 zIndex: 100, // z-index
10 stopper: '', // Id, class, or number value
11 stickyClass: 'asenha-sticky' // Class applied to element when it's stuck. Class name or false.
12 })
13
14 // Clicking on header save button triggers click of the hidden form submit button
15 $('.asenha-save-button').click( function(e) {
16
17 e.preventDefault();
18
19 $('.asenha-saving-changes').fadeIn();
20
21 // Get current tab's URL hash and save it in cookie
22 var hash = decodeURI(window.location.hash).substr(1); // get hash without the # character
23 Cookies.set('asenha_tab', hash, { expires: 1 }); // expires in 1 day
24
25 $.ajax({
26 url: asenhaStats.saveChangesJsonpUrl,
27 method: 'GET',
28 dataType: 'jsonp',
29 crossDomain: true
30 // success: function(response) {
31 // console.log(response);
32 // }
33 });
34
35 // Submit the settings form
36 $('input[type="submit"]#asenha-submit').click();
37
38 });
39
40 // Show all / less toggler for field options | Modified from https://codepen.io/symonsays/pen/rzgEgY
41 $('.asenha-field-with-options.field-show-more > .show-more').click(function(e) {
42
43 e.preventDefault();
44
45 var $this = $(this);
46 $this.toggleClass('show-more');
47
48 if ($this.hasClass('show-more')) {
49 $this.next().removeClass('opened',0);
50 $this.html('Expand ▼');
51 } else {
52 $this.next().addClass('opened',0);
53 $this.html('Collapse ▲');
54 }
55
56 });
57
58 // Email Delivery >> Send test email
59 $('#send-test-email').click(function(e) {
60 e.preventDefault();
61 var emailTo = $('#test-email-to').val();
62 if ( emailTo ) {
63 $('#ajax-result').show();
64 $('.sending-test-email').show();
65 $('.test-email-result').hide();
66 $('#test-email-success').hide();
67 $('#test-email-failed').hide();
68 $.ajax({
69 url: ajaxurl,
70 data: {
71 'action':'send_test_email',
72 'email_to': emailTo
73 },
74 success:function(data) {
75 var data = data.slice(0,-1); // remove strange trailing zero in string returned by AJAX call
76 var response = JSON.parse(data);
77
78 if ( response.status == 'success' ) {
79 setTimeout( function() {
80 $('.sending-test-email').hide();
81 $('.test-email-result').show();
82 $('#test-email-success').show();
83 }, 1500);
84 }
85 },
86 error:function(errorThrown) {
87 console.log(errorThrown);
88 setTimeout( function() {
89 $('.sending-test-email').hide();
90 $('.test-email-result').show();
91 $('#test-email-failed').show();
92 }, 1500);
93 }
94 });
95 } else {
96 alert( 'Please enter destination email address first.' );
97 }
98
99 });
100
101 // Initialize data tables
102 var table = $("#login-attempts-log").DataTable({
103 pageLength: 10
104 });
105
106 // Place fields into the "Content Management" tab
107
108 $('.enable-duplication').appendTo('.fields-content-management > table > tbody');
109 $('.content-order').appendTo('.fields-content-management > table > tbody');
110 $('.content-order-subfields-heading').appendTo('.fields-content-management .content-order .asenha-subfields');
111 $('.content-order-for').appendTo('.fields-content-management .content-order .asenha-subfields');
112
113 $('.enable-media-replacement').appendTo('.fields-content-management > table > tbody');
114 $('.enable-svg-upload').appendTo('.fields-content-management > table > tbody');
115 $('.enable-svg-upload-for').appendTo('.fields-content-management .enable-svg-upload .asenha-subfields');
116
117 $('.enable-external-permalinks').appendTo('.fields-content-management > table > tbody');
118 $('.enable-external-permalinks-for').appendTo('.fields-content-management .enable-external-permalinks .asenha-subfields');
119 $('.external-links-new-tab').appendTo('.fields-content-management > table > tbody');
120 $('.custom-nav-menu-items-new-tab').appendTo('.fields-content-management > table > tbody');
121 $('.enable-missed-schedule-posts-auto-publish').appendTo('.fields-content-management > table > tbody');
122
123 // Place fields into "Admin Interface" tab
124 $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody');
125 $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
126 $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
127 $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
128 $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
129 $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
130 $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
131 $('.hide-help-drawer').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
132
133 $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody');
134 $('.disable-dashboard-widgets').appendTo('.fields-admin-interface > table > tbody');
135 $('.disabled-dashboard-widgets').appendTo('.fields-admin-interface .disable-dashboard-widgets .asenha-subfields');
136 $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody');
137 $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields');
138 $('.wider-admin-menu').appendTo('.fields-admin-interface > table > tbody');
139 $('.admin-menu-width').appendTo('.fields-admin-interface .wider-admin-menu .asenha-subfields');
140 $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody');
141 $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields');
142
143 $('.enhance-list-tables').appendTo('.fields-admin-interface > table > tbody');
144 $('.show-featured-image-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
145 $('.show-excerpt-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
146 $('.show-id-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
147 $('.show-id-in-action_row').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
148 $('.show-custom-taxonomy-filters').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
149 $('.hide-comments-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
150 $('.hide-post-tags-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
151
152 // Place fields into "Log In | Log Out" tab
153 $('.change-login-url').appendTo('.fields-login-logout > table > tbody');
154 $('.custom-login-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields');
155 $('.site-identity-on-login').appendTo('.fields-login-logout > table > tbody');
156 $('.enable-login-logout-menu').appendTo('.fields-login-logout > table > tbody');
157 $('.enable-last-login-column').appendTo('.fields-login-logout > table > tbody');
158 $('.redirect-after-login').appendTo('.fields-login-logout > table > tbody');
159 $('.redirect-after-login-to-slug').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields');
160 $('.redirect-after-login-for').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields');
161 $('.redirect-after-logout').appendTo('.fields-login-logout > table > tbody');
162 $('.redirect-after-logout-to-slug').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields');
163 $('.redirect-after-logout-for').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields');
164
165 // Place fields into "Custom Code" tab
166
167 $('.enable-custom-admin-css').appendTo('.fields-custom-code > table > tbody');
168 $('.custom-admin-css').appendTo('.fields-custom-code .enable-custom-admin-css .asenha-subfields');
169 $('.enable-custom-frontend-css').appendTo('.fields-custom-code > table > tbody');
170
171 $('.custom-frontend-css').appendTo('.fields-custom-code .enable-custom-frontend-css .asenha-subfields');
172 $('.insert-head-body-footer-code').appendTo('.fields-custom-code > table > tbody');
173 $('.head-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
174 $('.head-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
175 $('.body-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
176 $('.body-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
177 $('.footer-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
178 $('.footer-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
179 $('.enable-custom-body-class').appendTo('.fields-custom-code > table > tbody');
180 $('.enable-custom-body-class-for').appendTo('.fields-custom-code .enable-custom-body-class .asenha-subfields');
181 $('.manage-ads-appads-txt').appendTo('.fields-custom-code > table > tbody');
182 $('.ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields');
183 $('.app-ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields');
184 $('.manage-robots-txt').appendTo('.fields-custom-code > table > tbody');
185 $('.robots-txt-content').appendTo('.fields-custom-code .manage-robots-txt .asenha-subfields');
186
187 // Place fields into the "Disable Components" tab
188 $('.disable-gutenberg').appendTo('.fields-disable-components > table > tbody');
189 $('.disable-gutenberg-for').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields');
190 $('.disable-gutenberg-frontend-styles').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields');
191 $('.disable-block-widgets').appendTo('.fields-disable-components > table > tbody');
192 $('.disable-comments').appendTo('.fields-disable-components > table > tbody');
193 $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields');
194 $('.disable-rest-api').appendTo('.fields-disable-components > table > tbody');
195 $('.disable-feeds').appendTo('.fields-disable-components > table > tbody');
196 $('.disable-all-updates').appendTo('.fields-disable-components > table > tbody');
197 $('.disable-smaller-components').appendTo('.fields-disable-components > table > tbody');
198 $('.disable-head-generator-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
199 $('.disable-resource-version-number').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
200 $('.disable-head-wlwmanifest-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
201 $('.disable-head-rsd-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
202 $('.disable-head-shortlink-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
203 $('.disable-frontend-dashicons').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
204 $('.disable-emoji-support').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
205 $('.disable-jquery-migrate').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
206
207 // Place fields into "Security" tab
208 $('.limit-login-attempts').appendTo('.fields-security > table > tbody');
209 $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields');
210 $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields');
211 $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields');
212 $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody');
213 $('.obfuscate-email-address').appendTo('.fields-security > table > tbody');
214 $('.obfuscate-email-address-description').appendTo('.fields-security .obfuscate-email-address .asenha-subfields');
215 $('.disable-xmlrpc').appendTo('.fields-security > table > tbody');
216
217 // Place fields into "Optimizations" tab
218 $('.image-upload-control').appendTo('.fields-optimizations > table > tbody');
219 $('.image-max-width').appendTo('.fields-optimizations .image-upload-control .asenha-subfields');
220 $('.image-max-height').appendTo('.fields-optimizations .image-upload-control .asenha-subfields');
221
222 $('.image-upload-control-description').appendTo('.fields-optimizations .image-upload-control .asenha-subfields');
223 $('.enable-revisions-control').appendTo('.fields-optimizations > table > tbody');
224 $('.revisions-max-number').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields');
225 $('.enable-revisions-control-for').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields');
226 $('.enable-heartbeat-control').appendTo('.fields-optimizations > table > tbody');
227 $('.heartbeat-control-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
228 $('.heartbeat-interval-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
229 $('.heartbeat-control-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
230 $('.heartbeat-interval-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
231 $('.heartbeat-control-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
232 $('.heartbeat-interval-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
233
234 // Place fields into "Utilities" tab
235 $('.smtp-email-delivery').appendTo('.fields-utilities > table > tbody');
236 $('.smtp-default-from-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
237 $('.smtp-default-from-name').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
238 $('.smtp-default-from-email').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
239 $('.smtp-force-from').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
240 $('.smtp--description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
241 $('.smtp-host').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
242 $('.smtp-port').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
243 $('.smtp-security').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
244 $('.smtp-username').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
245 $('.smtp-password').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
246 $('.smtp-debug').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
247 $('.smtp-send-test-email-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
248 $('.smtp-send-test-email-to').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
249 $('.smtp-send-test-email-result').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
250 $('.multiple-user-roles').appendTo('.fields-utilities > table > tbody');
251 $('.view-admin-as-role').appendTo('.fields-utilities > table > tbody');
252 $('.view-admin-as-role-description').appendTo('.fields-utilities .view-admin-as-role .asenha-subfields');
253 $('.enable-password-protection').appendTo('.fields-utilities > table > tbody');
254 $('.password-protection-password').appendTo('.fields-utilities .enable-password-protection .asenha-subfields');
255 $('.maintenance-mode').appendTo('.fields-utilities > table > tbody');
256 $('.maintenance-page-heading').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
257 $('.maintenance-page-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
258 $('.maintenance-page-background').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
259 $('.maintenance-mode-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
260 $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody');
261 $('.display-system-summary').appendTo('.fields-utilities > table > tbody');
262
263 // Remove empty .form-table that originally holds the fields
264 const formTableCount = $('.form-table').length;
265 // $('.form-table')[formTableCount-1].remove();
266
267 // Enable Custom Admin CSS => Initialize CodeMirror
268 var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]");
269 // if ( typeof CodeMirror != "undefined" ) {
270 // alert('CodeMirror is available');
271 // }
272 var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, {
273 mode: "css",
274 lineNumbers: true,
275 lineWrapping: true
276 });
277
278 adminCssEditor.setSize("100%",600);
279
280 // Enable Custom Frontend CSS => Initialize CodeMirror
281 var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]");
282 var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, {
283 mode: "css",
284 lineNumbers: true,
285 lineWrapping: true
286 });
287
288 frontendCssEditor.setSize("100%",600);
289
290 // Manage ads.txt and app-ads.txt=> Initialize CodeMirror
291 var adsTxtTextarea = document.getElementById("admin_site_enhancements[ads_txt_content]");
292 var adsTxtEditor = CodeMirror.fromTextArea(adsTxtTextarea, {
293 mode: "markdown",
294 lineNumbers: true,
295 lineWrapping: true
296 });
297
298 adsTxtEditor.setSize("100%",300);
299
300 var appAdsTxtTextarea = document.getElementById("admin_site_enhancements[app_ads_txt_content]");
301 var appAdsTxtEditor = CodeMirror.fromTextArea(appAdsTxtTextarea, {
302 mode: "markdown",
303 lineNumbers: true,
304 lineWrapping: true
305 });
306
307 appAdsTxtEditor.setSize("100%",300);
308
309 // Manage robots.txt => Initialize CodeMirror
310 var robotsTxtTextarea = document.getElementById("admin_site_enhancements[robots_txt_content]");
311 var robotsTxtEditor = CodeMirror.fromTextArea(robotsTxtTextarea, {
312 mode: "markdown",
313 lineNumbers: true,
314 lineWrapping: true
315 });
316
317 robotsTxtEditor.setSize("100%",400);
318
319 // Insert <head>, <body> and <footer> code => Initialize CodeMirror
320 var headCodeTextarea = document.getElementById("admin_site_enhancements[head_code]");
321 var headCodeEditor = CodeMirror.fromTextArea(headCodeTextarea, {
322 mode: "htmlmixed",
323 lineNumbers: true,
324 lineWrapping: true
325 });
326 headCodeEditor.setSize("100%",300);
327
328 var bodyCodeTextarea = document.getElementById("admin_site_enhancements[body_code]");
329 var bodyCodeEditor = CodeMirror.fromTextArea(bodyCodeTextarea, {
330 mode: "htmlmixed",
331 lineNumbers: true,
332 lineWrapping: true
333 });
334 bodyCodeEditor.setSize("100%",300);
335
336 var footerCodeTextarea = document.getElementById("admin_site_enhancements[footer_code]");
337 var footerCodeEditor = CodeMirror.fromTextArea(footerCodeTextarea, {
338 mode: "htmlmixed",
339 lineNumbers: true,
340 lineWrapping: true
341 });
342 footerCodeEditor.setSize("100%",300);
343
344 // Show and hide corresponding fields on tab clicks
345
346 $('#tab-content-management + label').click( function() {
347 $('.fields-content-management').show();
348 $('.asenha-fields:not(.fields-content-management)').hide();
349 window.location.hash = 'content-management';
350 Cookies.set('asenha_tab', 'content-management', { expires: 1 }); // expires in 1 day
351 });
352
353 $('#tab-admin-interface + label').click( function() {
354 $('.fields-admin-interface').show();
355 $('.asenha-fields:not(.fields-admin-interface)').hide();
356 window.location.hash = 'admin-interface';
357 Cookies.set('asenha_tab', 'admin-interface', { expires: 1 }); // expires in 1 day
358 });
359
360 $('#tab-login-logout + label').click( function() {
361 $('.fields-login-logout').show();
362 $('.asenha-fields:not(.fields-login-logout)').hide();
363 window.location.hash = 'login-logout';
364 Cookies.set('asenha_tab', 'login-logout', { expires: 1 }); // expires in 1 day
365 });
366
367 $('#tab-custom-code + label').click( function() {
368 $('.fields-custom-code').show();
369 $('.asenha-fields:not(.fields-custom-code)').hide();
370 window.location.hash = 'custom-code';
371 Cookies.set('asenha_tab', 'custom-code', { expires: 1 }); // expires in 1 day
372 adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror
373 frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror
374 adsTxtEditor.refresh(); // Manage ads.txt >> CodeMirror
375 appAdsTxtEditor.refresh(); // Manage app-ads.txt >> CodeMirror
376 headCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror
377 bodyCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror
378 footerCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror
379 robotsTxtEditor.refresh(); // Manage robots.txt >> CodeMirror
380 });
381
382 $('#tab-disable-components + label').click( function() {
383 $('.fields-disable-components').show();
384 $('.asenha-fields:not(.fields-disable-components)').hide();
385 window.location.hash = 'disable-components';
386 Cookies.set('asenha_tab', 'disable-components', { expires: 1 }); // expires in 1 day
387 });
388
389 $('#tab-security + label').click( function() {
390 $('.fields-security').show();
391 $('.asenha-fields:not(.fields-security)').hide();
392 window.location.hash = 'security';
393 Cookies.set('asenha_tab', 'security', { expires: 1 }); // expires in 1 day
394 });
395
396 $('#tab-optimizations + label').click( function() {
397 $('.fields-optimizations').show();
398 $('.asenha-fields:not(.fields-optimizations)').hide();
399 window.location.hash = 'optimizations';
400 Cookies.set('asenha_tab', 'optimizations', { expires: 1 }); // expires in 1 day
401 });
402
403 $('#tab-utilities + label').click( function() {
404 $('.fields-utilities').show();
405 $('.asenha-fields:not(.fields-utilities)').hide();
406 window.location.hash = 'utilities';
407 Cookies.set('asenha_tab', 'utilities', { expires: 1 }); // expires in 1 day
408 });
409
410 // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty
411 var asenhaTabHash = Cookies.get('asenha_tab');
412
413 if (typeof asenhaTabHash === 'undefined') {
414 $('#tab-content-management + label').trigger('click');
415 } else {
416 $('#tab-' + asenhaTabHash + ' + label').trigger('click');
417 }
418
419 // Show or hide subfields on document ready and on toggle click
420
421 function subfieldsToggler( fieldId, fieldClass, sortableId, codeMirrorInstances ) {
422
423 if (document.getElementById('admin_site_enhancements['+fieldId+']')) {
424
425 // Show/hide subfields on document ready, depending on if module is enabled or not
426 if ( document.getElementById('admin_site_enhancements['+fieldId+']').checked ) {
427
428 $('.'+fieldClass+' .asenha-subfields').show();
429 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
430 $('.'+fieldClass+' .asenha-subfield-select-inner').show();
431 }
432 $('.asenha-toggle.'+fieldClass+' td .asenha-field-with-options').addClass('is-enabled');
433 if ( codeMirrorInstances ) {
434 Object.keys(codeMirrorInstances).forEach(function(key) {
435 codeMirrorInstances[key].refresh();
436 });
437 }
438
439 } else {
440
441 $('.'+fieldClass+' .asenha-subfields').hide();
442 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
443 $('.'+fieldClass+' .asenha-subfield-select-inner').hide();
444 }
445
446 }
447
448 // Show/hide subfields on toggle click
449 document.getElementById('admin_site_enhancements['+fieldId+']').addEventListener('click', event => {
450 if (event.target.checked) {
451
452 $('.'+fieldClass+' .asenha-subfields').fadeIn();
453 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
454 $('.'+fieldClass+' .asenha-subfield-select-inner').show();
455 }
456 $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled');
457 if (document.getElementById(sortableId)) {
458 // Initialize sortable elements: https://api.jqueryui.com/sortable/
459 $('#' + sortableId ).sortable();
460 }
461 if ( codeMirrorInstances ) {
462 Object.keys(codeMirrorInstances).forEach(function(key) {
463 codeMirrorInstances[key].refresh();
464 });
465 }
466
467 } else {
468
469 $('.'+fieldClass+' .asenha-subfields').hide();
470 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
471 $('.'+fieldClass+' .asenha-subfield-select-inner').hide();
472 }
473 $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled');
474
475 }
476 });
477
478 }
479
480 }
481
482
483 subfieldsToggler( 'content_order', 'content-order' );
484 subfieldsToggler( 'enable_svg_upload', 'enable-svg-upload' );
485
486 subfieldsToggler( 'enable_external_permalinks', 'enable-external-permalinks' );
487 subfieldsToggler( 'enhance_list_tables', 'enhance-list-tables' );
488 subfieldsToggler( 'wider_admin_menu', 'wider-admin-menu' );
489 subfieldsToggler( 'customize_admin_menu', 'customize-admin-menu', 'custom-admin-menu' );
490 subfieldsToggler( 'disable_dashboard_widgets', 'disable-dashboard-widgets' );
491 // Clean Up Admin Bar
492 subfieldsToggler( 'hide_modify_elements', 'hide-modify-elements' );
493 subfieldsToggler( 'hide_admin_bar', 'hide-admin-bar' );
494 subfieldsToggler( 'change_login_url', 'change-login-url' );
495 subfieldsToggler( 'redirect_after_login', 'redirect-after-login' );
496 subfieldsToggler( 'redirect_after_logout', 'redirect-after-logout' );
497 subfieldsToggler( 'enable_custom_admin_css', 'enable-custom-admin-css', '', {adminCssEditor} );
498 subfieldsToggler( 'enable_custom_frontend_css', 'enable-custom-frontend-css', '', {frontendCssEditor} );
499 subfieldsToggler( 'insert_head_body_footer_code', 'insert-head-body-footer-code', '', {headCodeEditor,bodyCodeEditor,footerCodeEditor} );
500 subfieldsToggler( 'enable_custom_body_class', 'enable-custom-body-class' );
501 subfieldsToggler( 'manage_ads_appads_txt', 'manage-ads-appads-txt', '', {adsTxtEditor,appAdsTxtEditor} );
502 subfieldsToggler( 'manage_robots_txt', 'manage-robots-txt', '', {robotsTxtEditor} );
503 subfieldsToggler( 'disable_gutenberg', 'disable-gutenberg' );
504 subfieldsToggler( 'disable_comments', 'disable-comments' );
505 subfieldsToggler( 'disable_smaller_components', 'disable-smaller-components' );
506 subfieldsToggler( 'limit_login_attempts', 'limit-login-attempts' );
507 subfieldsToggler( 'obfuscate_email_address', 'obfuscate-email-address' );
508 subfieldsToggler( 'image_upload_control', 'image-upload-control' );
509 subfieldsToggler( 'enable_revisions_control', 'enable-revisions-control' );
510 subfieldsToggler( 'enable_heartbeat_control', 'enable-heartbeat-control' );
511
512 // Enable Heartbeat Control => Check if "Modify interval" is chosen/clicked and show/hide the corresponding select field
513 if ( $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]:checked').val() == 'modify' ) {
514 $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show();
515 }
516
517 $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]').click(function() {
518 var radioValue = $(this).attr('value');
519 if ( radioValue == 'modify' ) {
520 $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show();
521 } else {
522 $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').hide();
523 }
524 });
525
526 if ( $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]:checked').val() == 'modify' ) {
527 $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show();
528 }
529
530 $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]').click(function() {
531 var radioValue = $(this).attr('value');
532 if ( radioValue == 'modify' ) {
533 $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show();
534 } else {
535 $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').hide();
536 }
537 });
538
539 if ( $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]:checked').val() == 'modify' ) {
540 $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show();
541 }
542
543 $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]').click(function() {
544 var radioValue = $(this).attr('value');
545 if ( radioValue == 'modify' ) {
546 $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show();
547 } else {
548 $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').hide();
549 }
550 });
551
552 subfieldsToggler( 'smtp_email_delivery', 'smtp-email-delivery' );
553
554 // SMTP Email Delivery => Empty field value on click, so new password can be easily entered
555 var oldSmtpPassValue = '';
556
557 $('input[name="admin_site_enhancements[smtp_password]"]').focusin(function() {
558 oldSmtpPassValue = $(this).val();
559 $(this).val('');
560 });
561
562 $('input[name="admin_site_enhancements[smtp_password]"]').focusout(function() {
563 if ( $(this).val() == '' ) {
564 $(this).val(oldSmtpPassValue);
565 }
566 });
567
568 subfieldsToggler( 'view_admin_as_role', 'view-admin-as-role' );
569 subfieldsToggler( 'enable_password_protection', 'enable-password-protection' );
570
571 // Enable Password protection => Empty field value on click, so new password can be easily entered
572 var oldValue = '';
573 $('input[name="admin_site_enhancements[password_protection_password]"]').focusin(function() {
574 oldValue = $(this).val();
575 $(this).val('');
576 });
577
578 $('input[name="admin_site_enhancements[password_protection_password]"]').focusout(function() {
579 if ( $(this).val() == '' ) {
580 $(this).val(oldValue);
581 }
582 });
583
584 subfieldsToggler( 'maintenance_mode', 'maintenance-mode' );
585
586 // =============== ASE PRO =================
587
588 if ( asenhaStats.hideUpgradeNudge ) {
589 $('.asenha-upgrade-nudge').hide();
590 $('#bottom-upgrade-nudge').show();
591 } else {
592 $('.asenha-upgrade-nudge').show();
593 $('#bottom-upgrade-nudge').hide();
594 }
595
596 $('#dismiss-upgrade-nudge').click(function(e) {
597 e.preventDefault();
598 $.ajax({
599 url: ajaxurl,
600 data: {
601 'action':'dismiss_upgrade_nudge'
602 },
603 success:function(data) {
604 $('.asenha-upgrade-nudge').hide();
605 // $('#bottom-upgrade-nudge').show();
606 },
607 error:function(errorThrown) {
608 console.log(errorThrown);
609 }
610 });
611 });
612
613 // =============== SPONSORSHIP =================
614
615 // Stats on saving changes from asenha_admin_scripts() wp_localize_script() is availble in the 'asenhaStats' object-----
616 // console.log( asenhaStats );
617 // alert(JSON.stringify(asenhaStats));
618 if ( asenhaStats.showSponsorshipNudge ) {
619 $('.asenha-sponsorship-nudge').show();
620 } else {
621 $('.asenha-sponsorship-nudge').hide();
622 }
623
624 $('#have-sponsored').click(function(e) {
625 e.preventDefault();
626 $.ajax({
627 url: 'https://bowo.io/asenha-sp-ndg',
628 method: 'GET',
629 dataType: 'jsonp',
630 crossDomain: true
631 });
632 $.ajax({
633 url: ajaxurl,
634 data: {
635 'action':'have_sponsored'
636 },
637 success:function(data) {
638 $('.asenha-sponsorship-nudge').hide();
639 },
640 error:function(errorThrown) {
641 console.log(errorThrown);
642 }
643 });
644 });
645
646 $('#sponsorship-nudge-dismiss').click(function(e) {
647 e.preventDefault();
648 $.ajax({
649 url: 'https://bowo.io/asenha-sp-ndg',
650 method: 'GET',
651 dataType: 'jsonp',
652 crossDomain: true
653 });
654 $.ajax({
655 url: ajaxurl,
656 data: {
657 'action':'dismiss_sponsorship_nudge'
658 },
659 success:function(data) {
660 $('.asenha-sponsorship-nudge').hide();
661 },
662 error:function(errorThrown) {
663 console.log(errorThrown);
664 }
665 });
666 });
667
668 // Expand sponsorship notice | Modified from https://codepen.io/symonsays/pen/rzgEgY
669 $('.asenha-sponsorship-nudge.nudge-show-more > .show-more').click(function(e) {
670
671 e.preventDefault();
672
673 var $this = $(this);
674 $this.toggleClass('show-more');
675 $this.hide();
676
677 if ($this.hasClass('show-more')) {
678 $this.next().removeClass('opened',0);
679 } else {
680 $this.next().addClass('opened',0);
681 }
682
683 });
684
685 // Collapse sponsorship notice | Modified from https://codepen.io/symonsays/pen/rzgEgY
686 $('#sponsorship-nudge-show-less').click(function(e) {
687
688 e.preventDefault();
689
690 $('.nudge-wrapper-show-more').removeClass('opened',0);
691 $('#sponsorship-nudge-show-moreless').addClass('show-more');
692 $('#sponsorship-nudge-show-moreless').show();
693
694 });
695
696
697
698 // Modal for sponsoring plugin dev and maintenance: https://stephanwagner.me/jBox
699
700 // var sponsorModal = new jBox('Modal', {
701 // attach: '#plugin-sponsor',
702 // trigger: 'click', // or 'mouseenter'
703 // // content: 'Test'
704 // content: $('#asenha-sponsor'),
705 // width: 740, // pixels
706 // closeButton: 'box',
707 // addClass: 'plugin-sponsor-modal',
708 // overlayClass: 'plugin-sponsor-modal-overlay',
709 // target: '#wpwrap', // where to anchor the modal
710 // position: {
711 // x: 'center',
712 // y: 'top'
713 // },
714 // // fade: 1000,
715 // animation: {
716 // open: 'slide:top',
717 // close: 'slide:top'
718 // }
719 // });
720
721 // $('#plugin-sponsor').click( function() {
722 // $.ajax({
723 // url: 'https://bowo.io/asenha-sp-btn',
724 // method: 'GET',
725 // dataType: 'jsonp',
726 // crossDomain: true
727 // // success: function(response) {
728 // // console.log(response);
729 // // }
730 // });
731 // });
732
733 }); // END OF $(document).ready()
734
735 })( jQuery );