PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 6.1.0
Admin and Site Enhancements (ASE) v6.1.0
9.1.1 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
736 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
114 $('.enable-media-replacement').appendTo('.fields-content-management > table > tbody');
115 $('.enable-svg-upload').appendTo('.fields-content-management > table > tbody');
116 $('.enable-svg-upload-for').appendTo('.fields-content-management .enable-svg-upload .asenha-subfields');
117
118 $('.enable-external-permalinks').appendTo('.fields-content-management > table > tbody');
119 $('.enable-external-permalinks-for').appendTo('.fields-content-management .enable-external-permalinks .asenha-subfields');
120 $('.external-links-new-tab').appendTo('.fields-content-management > table > tbody');
121 $('.custom-nav-menu-items-new-tab').appendTo('.fields-content-management > table > tbody');
122 $('.enable-missed-schedule-posts-auto-publish').appendTo('.fields-content-management > table > tbody');
123
124 // Place fields into "Admin Interface" tab
125 $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody');
126 $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
127 $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
128 $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
129 $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
130 $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
131 $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
132 $('.hide-help-drawer').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields');
133
134 $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody');
135 $('.disable-dashboard-widgets').appendTo('.fields-admin-interface > table > tbody');
136 $('.disabled-dashboard-widgets').appendTo('.fields-admin-interface .disable-dashboard-widgets .asenha-subfields');
137 $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody');
138 $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields');
139 $('.wider-admin-menu').appendTo('.fields-admin-interface > table > tbody');
140 $('.admin-menu-width').appendTo('.fields-admin-interface .wider-admin-menu .asenha-subfields');
141 $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody');
142 $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields');
143
144 $('.enhance-list-tables').appendTo('.fields-admin-interface > table > tbody');
145 $('.show-featured-image-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
146 $('.show-excerpt-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
147 $('.show-id-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
148 $('.show-id-in-action_row').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
149 $('.show-custom-taxonomy-filters').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
150 $('.hide-comments-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
151 $('.hide-post-tags-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields');
152
153 // Place fields into "Log In | Log Out" tab
154 $('.change-login-url').appendTo('.fields-login-logout > table > tbody');
155 $('.custom-login-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields');
156 $('.site-identity-on-login').appendTo('.fields-login-logout > table > tbody');
157 $('.enable-login-logout-menu').appendTo('.fields-login-logout > table > tbody');
158 $('.enable-last-login-column').appendTo('.fields-login-logout > table > tbody');
159 $('.redirect-after-login').appendTo('.fields-login-logout > table > tbody');
160 $('.redirect-after-login-to-slug').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields');
161 $('.redirect-after-login-for').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields');
162 $('.redirect-after-logout').appendTo('.fields-login-logout > table > tbody');
163 $('.redirect-after-logout-to-slug').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields');
164 $('.redirect-after-logout-for').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields');
165
166 // Place fields into "Custom Code" tab
167
168 $('.enable-custom-admin-css').appendTo('.fields-custom-code > table > tbody');
169 $('.custom-admin-css').appendTo('.fields-custom-code .enable-custom-admin-css .asenha-subfields');
170 $('.enable-custom-frontend-css').appendTo('.fields-custom-code > table > tbody');
171
172 $('.custom-frontend-css').appendTo('.fields-custom-code .enable-custom-frontend-css .asenha-subfields');
173 $('.insert-head-body-footer-code').appendTo('.fields-custom-code > table > tbody');
174 $('.head-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
175 $('.head-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
176 $('.body-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
177 $('.body-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
178 $('.footer-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
179 $('.footer-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields');
180 $('.enable-custom-body-class').appendTo('.fields-custom-code > table > tbody');
181 $('.enable-custom-body-class-for').appendTo('.fields-custom-code .enable-custom-body-class .asenha-subfields');
182 $('.manage-ads-appads-txt').appendTo('.fields-custom-code > table > tbody');
183 $('.ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields');
184 $('.app-ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields');
185 $('.manage-robots-txt').appendTo('.fields-custom-code > table > tbody');
186 $('.robots-txt-content').appendTo('.fields-custom-code .manage-robots-txt .asenha-subfields');
187
188 // Place fields into the "Disable Components" tab
189 $('.disable-gutenberg').appendTo('.fields-disable-components > table > tbody');
190 $('.disable-gutenberg-for').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields');
191 $('.disable-gutenberg-frontend-styles').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields');
192 $('.disable-block-widgets').appendTo('.fields-disable-components > table > tbody');
193 $('.disable-comments').appendTo('.fields-disable-components > table > tbody');
194 $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields');
195 $('.disable-rest-api').appendTo('.fields-disable-components > table > tbody');
196 $('.disable-feeds').appendTo('.fields-disable-components > table > tbody');
197 $('.disable-all-updates').appendTo('.fields-disable-components > table > tbody');
198 $('.disable-smaller-components').appendTo('.fields-disable-components > table > tbody');
199 $('.disable-head-generator-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
200 $('.disable-resource-version-number').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
201 $('.disable-head-wlwmanifest-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
202 $('.disable-head-rsd-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
203 $('.disable-head-shortlink-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
204 $('.disable-frontend-dashicons').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
205 $('.disable-emoji-support').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
206 $('.disable-jquery-migrate').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields');
207
208 // Place fields into "Security" tab
209 $('.limit-login-attempts').appendTo('.fields-security > table > tbody');
210 $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields');
211 $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields');
212 $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields');
213 $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody');
214 $('.obfuscate-email-address').appendTo('.fields-security > table > tbody');
215 $('.obfuscate-email-address-description').appendTo('.fields-security .obfuscate-email-address .asenha-subfields');
216 $('.disable-xmlrpc').appendTo('.fields-security > table > tbody');
217
218 // Place fields into "Optimizations" tab
219 $('.image-upload-control').appendTo('.fields-optimizations > table > tbody');
220 $('.image-max-width').appendTo('.fields-optimizations .image-upload-control .asenha-subfields');
221 $('.image-max-height').appendTo('.fields-optimizations .image-upload-control .asenha-subfields');
222
223 $('.image-upload-control-description').appendTo('.fields-optimizations .image-upload-control .asenha-subfields');
224 $('.enable-revisions-control').appendTo('.fields-optimizations > table > tbody');
225 $('.revisions-max-number').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields');
226 $('.enable-revisions-control-for').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields');
227 $('.enable-heartbeat-control').appendTo('.fields-optimizations > table > tbody');
228 $('.heartbeat-control-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
229 $('.heartbeat-interval-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
230 $('.heartbeat-control-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
231 $('.heartbeat-interval-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
232 $('.heartbeat-control-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
233 $('.heartbeat-interval-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields');
234
235 // Place fields into "Utilities" tab
236 $('.smtp-email-delivery').appendTo('.fields-utilities > table > tbody');
237 $('.smtp-default-from-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
238 $('.smtp-default-from-name').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
239 $('.smtp-default-from-email').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
240 $('.smtp-force-from').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
241 $('.smtp--description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
242 $('.smtp-host').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
243 $('.smtp-port').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
244 $('.smtp-security').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
245 $('.smtp-username').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
246 $('.smtp-password').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
247 $('.smtp-debug').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
248 $('.smtp-send-test-email-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
249 $('.smtp-send-test-email-to').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
250 $('.smtp-send-test-email-result').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields');
251 $('.multiple-user-roles').appendTo('.fields-utilities > table > tbody');
252 $('.view-admin-as-role').appendTo('.fields-utilities > table > tbody');
253 $('.view-admin-as-role-description').appendTo('.fields-utilities .view-admin-as-role .asenha-subfields');
254 $('.enable-password-protection').appendTo('.fields-utilities > table > tbody');
255 $('.password-protection-password').appendTo('.fields-utilities .enable-password-protection .asenha-subfields');
256 $('.maintenance-mode').appendTo('.fields-utilities > table > tbody');
257 $('.maintenance-page-heading').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
258 $('.maintenance-page-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
259 $('.maintenance-page-background').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
260 $('.maintenance-mode-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields');
261 $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody');
262 $('.display-system-summary').appendTo('.fields-utilities > table > tbody');
263
264 // Remove empty .form-table that originally holds the fields
265 const formTableCount = $('.form-table').length;
266 // $('.form-table')[formTableCount-1].remove();
267
268 // Enable Custom Admin CSS => Initialize CodeMirror
269 var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]");
270 // if ( typeof CodeMirror != "undefined" ) {
271 // alert('CodeMirror is available');
272 // }
273 var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, {
274 mode: "css",
275 lineNumbers: true,
276 lineWrapping: true
277 });
278
279 adminCssEditor.setSize("100%",600);
280
281 // Enable Custom Frontend CSS => Initialize CodeMirror
282 var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]");
283 var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, {
284 mode: "css",
285 lineNumbers: true,
286 lineWrapping: true
287 });
288
289 frontendCssEditor.setSize("100%",600);
290
291 // Manage ads.txt and app-ads.txt=> Initialize CodeMirror
292 var adsTxtTextarea = document.getElementById("admin_site_enhancements[ads_txt_content]");
293 var adsTxtEditor = CodeMirror.fromTextArea(adsTxtTextarea, {
294 mode: "markdown",
295 lineNumbers: true,
296 lineWrapping: true
297 });
298
299 adsTxtEditor.setSize("100%",300);
300
301 var appAdsTxtTextarea = document.getElementById("admin_site_enhancements[app_ads_txt_content]");
302 var appAdsTxtEditor = CodeMirror.fromTextArea(appAdsTxtTextarea, {
303 mode: "markdown",
304 lineNumbers: true,
305 lineWrapping: true
306 });
307
308 appAdsTxtEditor.setSize("100%",300);
309
310 // Manage robots.txt => Initialize CodeMirror
311 var robotsTxtTextarea = document.getElementById("admin_site_enhancements[robots_txt_content]");
312 var robotsTxtEditor = CodeMirror.fromTextArea(robotsTxtTextarea, {
313 mode: "markdown",
314 lineNumbers: true,
315 lineWrapping: true
316 });
317
318 robotsTxtEditor.setSize("100%",400);
319
320 // Insert <head>, <body> and <footer> code => Initialize CodeMirror
321 var headCodeTextarea = document.getElementById("admin_site_enhancements[head_code]");
322 var headCodeEditor = CodeMirror.fromTextArea(headCodeTextarea, {
323 mode: "htmlmixed",
324 lineNumbers: true,
325 lineWrapping: true
326 });
327 headCodeEditor.setSize("100%",300);
328
329 var bodyCodeTextarea = document.getElementById("admin_site_enhancements[body_code]");
330 var bodyCodeEditor = CodeMirror.fromTextArea(bodyCodeTextarea, {
331 mode: "htmlmixed",
332 lineNumbers: true,
333 lineWrapping: true
334 });
335 bodyCodeEditor.setSize("100%",300);
336
337 var footerCodeTextarea = document.getElementById("admin_site_enhancements[footer_code]");
338 var footerCodeEditor = CodeMirror.fromTextArea(footerCodeTextarea, {
339 mode: "htmlmixed",
340 lineNumbers: true,
341 lineWrapping: true
342 });
343 footerCodeEditor.setSize("100%",300);
344
345 // Show and hide corresponding fields on tab clicks
346
347 $('#tab-content-management + label').click( function() {
348 $('.fields-content-management').show();
349 $('.asenha-fields:not(.fields-content-management)').hide();
350 window.location.hash = 'content-management';
351 Cookies.set('asenha_tab', 'content-management', { expires: 1 }); // expires in 1 day
352 });
353
354 $('#tab-admin-interface + label').click( function() {
355 $('.fields-admin-interface').show();
356 $('.asenha-fields:not(.fields-admin-interface)').hide();
357 window.location.hash = 'admin-interface';
358 Cookies.set('asenha_tab', 'admin-interface', { expires: 1 }); // expires in 1 day
359 });
360
361 $('#tab-login-logout + label').click( function() {
362 $('.fields-login-logout').show();
363 $('.asenha-fields:not(.fields-login-logout)').hide();
364 window.location.hash = 'login-logout';
365 Cookies.set('asenha_tab', 'login-logout', { expires: 1 }); // expires in 1 day
366 });
367
368 $('#tab-custom-code + label').click( function() {
369 $('.fields-custom-code').show();
370 $('.asenha-fields:not(.fields-custom-code)').hide();
371 window.location.hash = 'custom-code';
372 Cookies.set('asenha_tab', 'custom-code', { expires: 1 }); // expires in 1 day
373 adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror
374 frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror
375 adsTxtEditor.refresh(); // Manage ads.txt >> CodeMirror
376 appAdsTxtEditor.refresh(); // Manage app-ads.txt >> CodeMirror
377 headCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror
378 bodyCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror
379 footerCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror
380 robotsTxtEditor.refresh(); // Manage robots.txt >> CodeMirror
381 });
382
383 $('#tab-disable-components + label').click( function() {
384 $('.fields-disable-components').show();
385 $('.asenha-fields:not(.fields-disable-components)').hide();
386 window.location.hash = 'disable-components';
387 Cookies.set('asenha_tab', 'disable-components', { expires: 1 }); // expires in 1 day
388 });
389
390 $('#tab-security + label').click( function() {
391 $('.fields-security').show();
392 $('.asenha-fields:not(.fields-security)').hide();
393 window.location.hash = 'security';
394 Cookies.set('asenha_tab', 'security', { expires: 1 }); // expires in 1 day
395 });
396
397 $('#tab-optimizations + label').click( function() {
398 $('.fields-optimizations').show();
399 $('.asenha-fields:not(.fields-optimizations)').hide();
400 window.location.hash = 'optimizations';
401 Cookies.set('asenha_tab', 'optimizations', { expires: 1 }); // expires in 1 day
402 });
403
404 $('#tab-utilities + label').click( function() {
405 $('.fields-utilities').show();
406 $('.asenha-fields:not(.fields-utilities)').hide();
407 window.location.hash = 'utilities';
408 Cookies.set('asenha_tab', 'utilities', { expires: 1 }); // expires in 1 day
409 });
410
411 // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty
412 var asenhaTabHash = Cookies.get('asenha_tab');
413
414 if (typeof asenhaTabHash === 'undefined') {
415 $('#tab-content-management + label').trigger('click');
416 } else {
417 $('#tab-' + asenhaTabHash + ' + label').trigger('click');
418 }
419
420 // Show or hide subfields on document ready and on toggle click
421
422 function subfieldsToggler( fieldId, fieldClass, sortableId, codeMirrorInstances ) {
423
424 if (document.getElementById('admin_site_enhancements['+fieldId+']')) {
425
426 // Show/hide subfields on document ready, depending on if module is enabled or not
427 if ( document.getElementById('admin_site_enhancements['+fieldId+']').checked ) {
428
429 $('.'+fieldClass+' .asenha-subfields').show();
430 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
431 $('.'+fieldClass+' .asenha-subfield-select-inner').show();
432 }
433 $('.asenha-toggle.'+fieldClass+' td .asenha-field-with-options').addClass('is-enabled');
434 if ( codeMirrorInstances ) {
435 Object.keys(codeMirrorInstances).forEach(function(key) {
436 codeMirrorInstances[key].refresh();
437 });
438 }
439
440 } else {
441
442 $('.'+fieldClass+' .asenha-subfields').hide();
443 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
444 $('.'+fieldClass+' .asenha-subfield-select-inner').hide();
445 }
446
447 }
448
449 // Show/hide subfields on toggle click
450 document.getElementById('admin_site_enhancements['+fieldId+']').addEventListener('click', event => {
451 if (event.target.checked) {
452
453 $('.'+fieldClass+' .asenha-subfields').fadeIn();
454 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
455 $('.'+fieldClass+' .asenha-subfield-select-inner').show();
456 }
457 $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled');
458 if (document.getElementById(sortableId)) {
459 // Initialize sortable elements: https://api.jqueryui.com/sortable/
460 $('#' + sortableId ).sortable();
461 }
462 if ( codeMirrorInstances ) {
463 Object.keys(codeMirrorInstances).forEach(function(key) {
464 codeMirrorInstances[key].refresh();
465 });
466 }
467
468 } else {
469
470 $('.'+fieldClass+' .asenha-subfields').hide();
471 if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) {
472 $('.'+fieldClass+' .asenha-subfield-select-inner').hide();
473 }
474 $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled');
475
476 }
477 });
478
479 }
480
481 }
482
483
484 subfieldsToggler( 'content_order', 'content-order' );
485 subfieldsToggler( 'enable_svg_upload', 'enable-svg-upload' );
486
487 subfieldsToggler( 'enable_external_permalinks', 'enable-external-permalinks' );
488 subfieldsToggler( 'enhance_list_tables', 'enhance-list-tables' );
489 subfieldsToggler( 'wider_admin_menu', 'wider-admin-menu' );
490 subfieldsToggler( 'customize_admin_menu', 'customize-admin-menu', 'custom-admin-menu' );
491 subfieldsToggler( 'disable_dashboard_widgets', 'disable-dashboard-widgets' );
492 // Clean Up Admin Bar
493 subfieldsToggler( 'hide_modify_elements', 'hide-modify-elements' );
494 subfieldsToggler( 'hide_admin_bar', 'hide-admin-bar' );
495 subfieldsToggler( 'change_login_url', 'change-login-url' );
496 subfieldsToggler( 'redirect_after_login', 'redirect-after-login' );
497 subfieldsToggler( 'redirect_after_logout', 'redirect-after-logout' );
498 subfieldsToggler( 'enable_custom_admin_css', 'enable-custom-admin-css', '', {adminCssEditor} );
499 subfieldsToggler( 'enable_custom_frontend_css', 'enable-custom-frontend-css', '', {frontendCssEditor} );
500 subfieldsToggler( 'insert_head_body_footer_code', 'insert-head-body-footer-code', '', {headCodeEditor,bodyCodeEditor,footerCodeEditor} );
501 subfieldsToggler( 'enable_custom_body_class', 'enable-custom-body-class' );
502 subfieldsToggler( 'manage_ads_appads_txt', 'manage-ads-appads-txt', '', {adsTxtEditor,appAdsTxtEditor} );
503 subfieldsToggler( 'manage_robots_txt', 'manage-robots-txt', '', {robotsTxtEditor} );
504 subfieldsToggler( 'disable_gutenberg', 'disable-gutenberg' );
505 subfieldsToggler( 'disable_comments', 'disable-comments' );
506 subfieldsToggler( 'disable_smaller_components', 'disable-smaller-components' );
507 subfieldsToggler( 'limit_login_attempts', 'limit-login-attempts' );
508 subfieldsToggler( 'obfuscate_email_address', 'obfuscate-email-address' );
509 subfieldsToggler( 'image_upload_control', 'image-upload-control' );
510 subfieldsToggler( 'enable_revisions_control', 'enable-revisions-control' );
511 subfieldsToggler( 'enable_heartbeat_control', 'enable-heartbeat-control' );
512
513 // Enable Heartbeat Control => Check if "Modify interval" is chosen/clicked and show/hide the corresponding select field
514 if ( $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]:checked').val() == 'modify' ) {
515 $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show();
516 }
517
518 $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]').click(function() {
519 var radioValue = $(this).attr('value');
520 if ( radioValue == 'modify' ) {
521 $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show();
522 } else {
523 $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').hide();
524 }
525 });
526
527 if ( $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]:checked').val() == 'modify' ) {
528 $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show();
529 }
530
531 $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]').click(function() {
532 var radioValue = $(this).attr('value');
533 if ( radioValue == 'modify' ) {
534 $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show();
535 } else {
536 $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').hide();
537 }
538 });
539
540 if ( $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]:checked').val() == 'modify' ) {
541 $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show();
542 }
543
544 $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]').click(function() {
545 var radioValue = $(this).attr('value');
546 if ( radioValue == 'modify' ) {
547 $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show();
548 } else {
549 $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').hide();
550 }
551 });
552
553 subfieldsToggler( 'smtp_email_delivery', 'smtp-email-delivery' );
554
555 // SMTP Email Delivery => Empty field value on click, so new password can be easily entered
556 var oldSmtpPassValue = '';
557
558 $('input[name="admin_site_enhancements[smtp_password]"]').focusin(function() {
559 oldSmtpPassValue = $(this).val();
560 $(this).val('');
561 });
562
563 $('input[name="admin_site_enhancements[smtp_password]"]').focusout(function() {
564 if ( $(this).val() == '' ) {
565 $(this).val(oldSmtpPassValue);
566 }
567 });
568
569 subfieldsToggler( 'view_admin_as_role', 'view-admin-as-role' );
570 subfieldsToggler( 'enable_password_protection', 'enable-password-protection' );
571
572 // Enable Password protection => Empty field value on click, so new password can be easily entered
573 var oldValue = '';
574 $('input[name="admin_site_enhancements[password_protection_password]"]').focusin(function() {
575 oldValue = $(this).val();
576 $(this).val('');
577 });
578
579 $('input[name="admin_site_enhancements[password_protection_password]"]').focusout(function() {
580 if ( $(this).val() == '' ) {
581 $(this).val(oldValue);
582 }
583 });
584
585 subfieldsToggler( 'maintenance_mode', 'maintenance-mode' );
586
587 // =============== ASE PRO =================
588
589 if ( asenhaStats.hideUpgradeNudge ) {
590 $('.asenha-upgrade-nudge').hide();
591 $('#bottom-upgrade-nudge').show();
592 } else {
593 $('.asenha-upgrade-nudge').show();
594 $('#bottom-upgrade-nudge').hide();
595 }
596
597 $('#dismiss-upgrade-nudge').click(function(e) {
598 e.preventDefault();
599 $.ajax({
600 url: ajaxurl,
601 data: {
602 'action':'dismiss_upgrade_nudge'
603 },
604 success:function(data) {
605 $('.asenha-upgrade-nudge').hide();
606 // $('#bottom-upgrade-nudge').show();
607 },
608 error:function(errorThrown) {
609 console.log(errorThrown);
610 }
611 });
612 });
613
614 // =============== SPONSORSHIP =================
615
616 // Stats on saving changes from asenha_admin_scripts() wp_localize_script() is availble in the 'asenhaStats' object-----
617 // console.log( asenhaStats );
618 // alert(JSON.stringify(asenhaStats));
619 if ( asenhaStats.showSponsorshipNudge ) {
620 $('.asenha-sponsorship-nudge').show();
621 } else {
622 $('.asenha-sponsorship-nudge').hide();
623 }
624
625 $('#have-sponsored').click(function(e) {
626 e.preventDefault();
627 $.ajax({
628 url: 'https://bowo.io/asenha-sp-ndg',
629 method: 'GET',
630 dataType: 'jsonp',
631 crossDomain: true
632 });
633 $.ajax({
634 url: ajaxurl,
635 data: {
636 'action':'have_sponsored'
637 },
638 success:function(data) {
639 $('.asenha-sponsorship-nudge').hide();
640 },
641 error:function(errorThrown) {
642 console.log(errorThrown);
643 }
644 });
645 });
646
647 $('#sponsorship-nudge-dismiss').click(function(e) {
648 e.preventDefault();
649 $.ajax({
650 url: 'https://bowo.io/asenha-sp-ndg',
651 method: 'GET',
652 dataType: 'jsonp',
653 crossDomain: true
654 });
655 $.ajax({
656 url: ajaxurl,
657 data: {
658 'action':'dismiss_sponsorship_nudge'
659 },
660 success:function(data) {
661 $('.asenha-sponsorship-nudge').hide();
662 },
663 error:function(errorThrown) {
664 console.log(errorThrown);
665 }
666 });
667 });
668
669 // Expand sponsorship notice | Modified from https://codepen.io/symonsays/pen/rzgEgY
670 $('.asenha-sponsorship-nudge.nudge-show-more > .show-more').click(function(e) {
671
672 e.preventDefault();
673
674 var $this = $(this);
675 $this.toggleClass('show-more');
676 $this.hide();
677
678 if ($this.hasClass('show-more')) {
679 $this.next().removeClass('opened',0);
680 } else {
681 $this.next().addClass('opened',0);
682 }
683
684 });
685
686 // Collapse sponsorship notice | Modified from https://codepen.io/symonsays/pen/rzgEgY
687 $('#sponsorship-nudge-show-less').click(function(e) {
688
689 e.preventDefault();
690
691 $('.nudge-wrapper-show-more').removeClass('opened',0);
692 $('#sponsorship-nudge-show-moreless').addClass('show-more');
693 $('#sponsorship-nudge-show-moreless').show();
694
695 });
696
697
698
699 // Modal for sponsoring plugin dev and maintenance: https://stephanwagner.me/jBox
700
701 // var sponsorModal = new jBox('Modal', {
702 // attach: '#plugin-sponsor',
703 // trigger: 'click', // or 'mouseenter'
704 // // content: 'Test'
705 // content: $('#asenha-sponsor'),
706 // width: 740, // pixels
707 // closeButton: 'box',
708 // addClass: 'plugin-sponsor-modal',
709 // overlayClass: 'plugin-sponsor-modal-overlay',
710 // target: '#wpwrap', // where to anchor the modal
711 // position: {
712 // x: 'center',
713 // y: 'top'
714 // },
715 // // fade: 1000,
716 // animation: {
717 // open: 'slide:top',
718 // close: 'slide:top'
719 // }
720 // });
721
722 // $('#plugin-sponsor').click( function() {
723 // $.ajax({
724 // url: 'https://bowo.io/asenha-sp-btn',
725 // method: 'GET',
726 // dataType: 'jsonp',
727 // crossDomain: true
728 // // success: function(response) {
729 // // console.log(response);
730 // // }
731 // });
732 // });
733
734 }); // END OF $(document).ready()
735
736 })( jQuery );