codemirror
7 months ago
datatables
7 months ago
admin-menu-organizer.js
7 months ago
admin-page.js
7 months ago
content-order-sort.js
7 months ago
custom-admin-menu.js
7 months ago
external-permalinks.js
7 months ago
gutenberg-content-duplication.js
7 months ago
hide-admin-notices.js
7 months ago
jBox.all.min.js
7 months ago
jquery.jsticky.mod.js
7 months ago
jquery.jsticky.mod.min.js
7 months ago
jquery.mjs.nestedSortable.js
7 months ago
jquery.ui.touch-punch.min.js
7 months ago
js.cookie.min.js
7 months ago
list-tables-content-order.js
7 months ago
media-replace.js
7 months ago
multiple-user-roles.js
7 months ago
select2.full.min.js
7 months ago
toggle-hidden-menu.js
7 months ago
admin-page.js
1393 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 | if (typeof $.fn.sticky === 'function') { |
| 8 | $('#asenha-header').sticky({ |
| 9 | topSpacing: 0, // Space between element and top of the viewport (in pixels) |
| 10 | zIndex: 100, // z-index |
| 11 | stopper: '', // Id, class, or number value |
| 12 | stickyClass: 'asenha-sticky' // Class applied to element when it's stuck. Class name or false. |
| 13 | }) |
| 14 | } |
| 15 | |
| 16 | // Clicking on header save button triggers click of the hidden form submit button |
| 17 | $('.asenha-save-button').click( function(e) { |
| 18 | |
| 19 | e.preventDefault(); |
| 20 | |
| 21 | $('.asenha-saving-changes').fadeIn(); |
| 22 | |
| 23 | // Get current tab's URL hash and save it in cookie |
| 24 | var hash = decodeURI(window.location.hash).substr(1); // get hash without the # character |
| 25 | Cookies.set('asenha_tab', hash, { expires: 1 }); // expires in 1 day |
| 26 | |
| 27 | // Submit the settings form |
| 28 | $('input[type="submit"]#asenha-submit').click(); |
| 29 | |
| 30 | }); |
| 31 | |
| 32 | // Search modules |
| 33 | var searchInput = $('#module-search-input'); |
| 34 | |
| 35 | $(searchInput).keyup(delay(function (e) { |
| 36 | var searchVal = $(this).val(); |
| 37 | var filterItems = $('[data-search-filter]'); |
| 38 | |
| 39 | if ( searchVal != '' ) { |
| 40 | setTimeout(function() { |
| 41 | $(searchInput).addClass('has-text-input'); |
| 42 | $('.modules-tab').hide(); |
| 43 | $('.search-tab').show(); |
| 44 | $('.asenha-fields.section-visible').addClass('originally-visible'); |
| 45 | $('.asenha-fields').removeClass('section-visible'); |
| 46 | $('.asenha-fields').removeClass('section-hidden'); |
| 47 | $('.asenha-fields').addClass('section-visible-for-search'); |
| 48 | filterItems.parents('.asenha-toggle').addClass('result-is-hidden'); |
| 49 | $('[data-search-filter][data-module-info*="' + searchVal.toLowerCase() + '"]').parents('.asenha-toggle').removeClass('result-is-hidden'); |
| 50 | }, 250 ); |
| 51 | refreshCodeMirror(); |
| 52 | } else { |
| 53 | setTimeout(function() { |
| 54 | searchInput.removeClass('has-text-input'); |
| 55 | filterItems.parents('.asenha-toggle').removeClass('result-is-hidden'); |
| 56 | clear_search(); |
| 57 | refreshCodeMirror(); |
| 58 | }, 250 ); |
| 59 | } |
| 60 | }, 200)); |
| 61 | |
| 62 | // Restore all results when the x button on search input field is clicked. |
| 63 | // The click triggers a 'search' event we're listening to below |
| 64 | |
| 65 | if ( searchInput.length > 0 ) { |
| 66 | document.getElementById("module-search-input").addEventListener("search", function(event) { |
| 67 | clear_search(); |
| 68 | refreshCodeMirror(); |
| 69 | }); |
| 70 | } |
| 71 | |
| 72 | // Ref: https://stackoverflow.com/a/1909508 |
| 73 | function delay(fn, ms) { |
| 74 | let timer = 0 |
| 75 | return function(...args) { |
| 76 | clearTimeout(timer) |
| 77 | timer = setTimeout(fn.bind(this, ...args), ms || 0) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | function clear_search() { |
| 82 | searchInput.removeClass('has-text-input'); |
| 83 | $('[data-search-filter]').each( function() { |
| 84 | $(this).parents('.asenha-toggle').removeClass('result-is-hidden'); |
| 85 | $('.modules-tab').show(); |
| 86 | $('.search-tab').hide(); |
| 87 | $('.asenha-fields').removeClass('section-visible-for-search'); |
| 88 | $('.asenha-fields').addClass('section-hidden'); |
| 89 | // Has no effect. Compensate with CSS .asenha-fields.section-visible.section-hidden { display: block; } |
| 90 | // $('.asenha-fields.originally-visible').removeClass('section-hidden'); |
| 91 | $('.asenha-fields.originally-visible').addClass('section-visible'); |
| 92 | $('.asenha-fields').removeClass('originally-visible'); |
| 93 | }); |
| 94 | } |
| 95 | |
| 96 | // Show all / less toggler for field options | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 97 | $('.asenha-field-with-options.field-show-more > .show-more').click(function(e) { |
| 98 | |
| 99 | e.preventDefault(); |
| 100 | |
| 101 | var $this = $(this); |
| 102 | $this.toggleClass('show-more'); |
| 103 | |
| 104 | if ($this.hasClass('show-more')) { |
| 105 | $this.next().removeClass('opened',0); |
| 106 | $this.html(adminPageVars.expandText + ' ▼'); |
| 107 | } else { |
| 108 | $this.next().addClass('opened',0); |
| 109 | $this.html(adminPageVars.collapseText + ' ▲'); |
| 110 | } |
| 111 | |
| 112 | }); |
| 113 | |
| 114 | // Email Delivery >> Send test email |
| 115 | $('#send-test-email').click(function(e) { |
| 116 | e.preventDefault(); |
| 117 | var emailTo = $('#test-email-to').val(); |
| 118 | if ( emailTo ) { |
| 119 | $('#ajax-result').show(); |
| 120 | $('.sending-test-email').show(); |
| 121 | $('.test-email-result').hide(); |
| 122 | $('#test-email-success').hide(); |
| 123 | $('#test-email-failed').hide(); |
| 124 | $.ajax({ |
| 125 | url: ajaxurl, |
| 126 | data: { |
| 127 | 'action':'send_test_email', |
| 128 | 'email_to': emailTo, |
| 129 | 'nonce': adminPageVars.sendTestEmailNonce |
| 130 | }, |
| 131 | success:function(data) { |
| 132 | var data = data.slice(0,-1); // remove strange trailing zero in string returned by AJAX call |
| 133 | var response = JSON.parse(data); |
| 134 | if ( response.status == 'success' ) { |
| 135 | setTimeout( function() { |
| 136 | $('.sending-test-email').hide(); |
| 137 | // $('.test-email-result').show(); |
| 138 | $('#test-email-success').show(); |
| 139 | }, 1500); |
| 140 | } |
| 141 | if ( response.status == 'failed' ) { |
| 142 | setTimeout( function() { |
| 143 | $('.sending-test-email').hide(); |
| 144 | // $('.test-email-result').show(); |
| 145 | $('#test-email-failed').show(); |
| 146 | }, 1500); |
| 147 | } |
| 148 | }, |
| 149 | error:function(errorThrown) { |
| 150 | console.log(errorThrown); |
| 151 | setTimeout( function() { |
| 152 | $('.sending-test-email').hide(); |
| 153 | $('.test-email-result').show(); |
| 154 | $('#test-email-failed').show(); |
| 155 | }, 1500); |
| 156 | } |
| 157 | }); |
| 158 | } else { |
| 159 | alert( 'Please enter destination email address first.' ); |
| 160 | } |
| 161 | }); |
| 162 | |
| 163 | // Form Builder >> Send test email |
| 164 | $('#form-builder-send-test-email').click(function(e) { |
| 165 | e.preventDefault(); |
| 166 | var emailTo = $('#form-builder-test-email-to').val(); |
| 167 | var emailTemplate = $('.form-builder-email-template select').val(); |
| 168 | if ( emailTo ) { |
| 169 | $('#form-builder-ajax-result').show(); |
| 170 | $('.form-builder-sending-test-email').show(); |
| 171 | $('.test-email-result').hide(); |
| 172 | $('#form-builder-test-email-success').hide(); |
| 173 | $('#form-builder-test-email-failed').hide(); |
| 174 | $.ajax({ |
| 175 | type: 'POST', |
| 176 | url: ajaxurl, |
| 177 | data: { |
| 178 | action: 'formbuilder_test_email_template', |
| 179 | email_template: emailTemplate, |
| 180 | test_email: emailTo, |
| 181 | nonce: adminPageVars.formBuilderSendTestEmailNonce |
| 182 | }, |
| 183 | success:function(data) { |
| 184 | var response = JSON.parse(data); |
| 185 | if ( response.success ) { |
| 186 | setTimeout( function() { |
| 187 | $('.form-builder-sending-test-email').hide(); |
| 188 | $('#form-builder-test-email-success').show(); |
| 189 | }, 1500); |
| 190 | } |
| 191 | if ( ! response.success ) { |
| 192 | setTimeout( function() { |
| 193 | $('.form-builder-sending-test-email').hide(); |
| 194 | $('#form-builder-test-email-failed').show(); |
| 195 | }, 1500); |
| 196 | } |
| 197 | }, |
| 198 | error:function(errorThrown) { |
| 199 | console.log(errorThrown); |
| 200 | setTimeout( function() { |
| 201 | $('.sending-test-email').hide(); |
| 202 | $('.test-email-result').show(); |
| 203 | $('#test-email-failed').show(); |
| 204 | }, 1500); |
| 205 | } |
| 206 | }); |
| 207 | } else { |
| 208 | alert( 'Please enter destination email address first.' ); |
| 209 | } |
| 210 | }); |
| 211 | |
| 212 | |
| 213 | |
| 214 | // Initialize data tables |
| 215 | var table = $("#login-attempts-log").DataTable({ |
| 216 | pageLength: 10, |
| 217 | order: [[2, 'desc']], |
| 218 | language: { |
| 219 | emptyTable: adminPageVars.dataTable.emptyTable, |
| 220 | info: adminPageVars.dataTable.info, |
| 221 | infoEmpty: adminPageVars.dataTable.infoEmpty, |
| 222 | infoFiltered: adminPageVars.dataTable.infoFiltered, |
| 223 | lengthMenu: adminPageVars.dataTable.lengthMenu, |
| 224 | search: adminPageVars.dataTable.search, |
| 225 | zeroRecords: adminPageVars.dataTable.zeroRecords, |
| 226 | paginate: { |
| 227 | first: adminPageVars.dataTable.paginate.first, |
| 228 | last: adminPageVars.dataTable.paginate.last, |
| 229 | next: adminPageVars.dataTable.paginate.next, |
| 230 | previous: adminPageVars.dataTable.paginate.previous |
| 231 | }, |
| 232 | } |
| 233 | }); |
| 234 | |
| 235 | // Place fields into the "Content Management" tab |
| 236 | |
| 237 | $('.enable-duplication').appendTo('.fields-content-management > table > tbody'); |
| 238 | $('.duplication-redirect-destination').appendTo('.fields-content-management .enable-duplication .asenha-subfields'); |
| 239 | |
| 240 | $('.content-order').appendTo('.fields-content-management > table > tbody'); |
| 241 | // $('.content-order-subfields-heading').appendTo('.fields-content-management .content-order .asenha-subfields'); |
| 242 | $('.content-order-for').appendTo('.fields-content-management .content-order .asenha-subfields'); |
| 243 | |
| 244 | |
| 245 | $('.enable-media-replacement').appendTo('.fields-content-management > table > tbody'); |
| 246 | $('.disable-media-replacement-cache-busting').appendTo('.fields-content-management .enable-media-replacement .asenha-subfields'); |
| 247 | $('.enable-svg-upload').appendTo('.fields-content-management > table > tbody'); |
| 248 | $('.enable-svg-upload-for').appendTo('.fields-content-management .enable-svg-upload .asenha-subfields'); |
| 249 | $('.enable-avif-upload').appendTo('.fields-content-management > table > tbody'); |
| 250 | $('.avif-support-status').appendTo('.fields-content-management .enable-avif-upload .asenha-subfields'); |
| 251 | |
| 252 | $('.enable-external-permalinks').appendTo('.fields-content-management > table > tbody'); |
| 253 | $('.enable-external-permalinks-for').appendTo('.fields-content-management .enable-external-permalinks .asenha-subfields'); |
| 254 | $('.external-links-new-tab').appendTo('.fields-content-management > table > tbody'); |
| 255 | $('.custom-nav-menu-items-new-tab').appendTo('.fields-content-management > table > tbody'); |
| 256 | $('.enable-missed-schedule-posts-auto-publish').appendTo('.fields-content-management > table > tbody'); |
| 257 | |
| 258 | // Place fields into "Admin Interface" tab |
| 259 | $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody'); |
| 260 | $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 261 | $('.hide-ab-site-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 262 | $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 263 | $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 264 | $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 265 | $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 266 | $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 267 | $('.hide-help-drawer').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 268 | |
| 269 | $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody'); |
| 270 | |
| 271 | $('.disable-dashboard-widgets').appendTo('.fields-admin-interface > table > tbody'); |
| 272 | $('.disable-welcome-panel-in-dashboard').appendTo('.fields-admin-interface .disable-dashboard-widgets .asenha-subfields'); |
| 273 | $('.disabled-dashboard-widgets').appendTo('.fields-admin-interface .disable-dashboard-widgets .asenha-subfields'); |
| 274 | $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody'); |
| 275 | |
| 276 | $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 277 | $('.hide-admin-bar-always-show-for-admins').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 278 | |
| 279 | $('.hide-admin-bar-description').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 280 | |
| 281 | $('.wider-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 282 | $('.admin-menu-width').appendTo('.fields-admin-interface .wider-admin-menu .asenha-subfields'); |
| 283 | $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 284 | $('.admin-menu-organizer-sticky-collapse-menu').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields'); |
| 285 | |
| 286 | $('.show-custom-taxonomy-filters').appendTo('.fields-admin-interface > table > tbody'); |
| 287 | |
| 288 | $('.enhance-list-tables').appendTo('.fields-admin-interface > table > tbody'); |
| 289 | $('.show-featured-image-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 290 | $('.show-excerpt-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 291 | $('.show-last-modified-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 292 | $('.show-id-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 293 | $('.show-file-size-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 294 | $('.show-id-in-action_row').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 295 | $('.hide-date-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 296 | $('.hide-comments-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 297 | $('.hide-post-tags-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 298 | $('.various-admin-ui-enhancements').appendTo('.fields-admin-interface > table > tbody'); |
| 299 | $('.media-library-infinite-scrolling').appendTo('.fields-admin-interface .various-admin-ui-enhancements .asenha-subfields'); |
| 300 | $('.display-active-plugins-first').appendTo('.fields-admin-interface .various-admin-ui-enhancements .asenha-subfields'); |
| 301 | |
| 302 | $('.custom-admin-footer-text').appendTo('.fields-admin-interface > table > tbody'); |
| 303 | $('.custom-admin-footer-left').appendTo('.fields-admin-interface .custom-admin-footer-text .asenha-subfields'); |
| 304 | reinitWpEditor('admin_site_enhancements--custom_admin_footer_left'); |
| 305 | $('.custom-admin-footer-right').appendTo('.fields-admin-interface .custom-admin-footer-text .asenha-subfields'); |
| 306 | reinitWpEditor('admin_site_enhancements--custom_admin_footer_right'); |
| 307 | |
| 308 | // Place fields into "Log In | Log Out" tab |
| 309 | $('.change-login-url').appendTo('.fields-login-logout > table > tbody'); |
| 310 | $('.custom-login-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 311 | $('.custom-login-whitelist').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 312 | $('.default-login-redirect-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 313 | $('.change-login-url-description').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 314 | $('.login-id-type-restriction').appendTo('.fields-login-logout > table > tbody'); |
| 315 | $('.login-id-type').appendTo('.fields-login-logout .login-id-type-restriction .asenha-subfields'); |
| 316 | |
| 317 | $('.site-identity-on-login').appendTo('.fields-login-logout > table > tbody'); |
| 318 | $('.enable-login-logout-menu').appendTo('.fields-login-logout > table > tbody'); |
| 319 | |
| 320 | $('.enable-last-login-column').appendTo('.fields-login-logout > table > tbody'); |
| 321 | $('.registration-date-column').appendTo('.fields-login-logout > table > tbody'); |
| 322 | $('.redirect-after-login').appendTo('.fields-login-logout > table > tbody'); |
| 323 | |
| 324 | $('.redirect-after-login-to-slug').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 325 | $('.redirect-after-login-for').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 326 | |
| 327 | $('.redirect-after-logout').appendTo('.fields-login-logout > table > tbody'); |
| 328 | |
| 329 | $('.redirect-after-logout-to-slug').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 330 | $('.redirect-after-logout-for').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 331 | |
| 332 | |
| 333 | // Place fields into "Custom Code" tab |
| 334 | |
| 335 | $('.enable-custom-admin-css').appendTo('.fields-custom-code > table > tbody'); |
| 336 | $('.custom-admin-css').appendTo('.fields-custom-code .enable-custom-admin-css .asenha-subfields'); |
| 337 | $('.enable-custom-frontend-css').appendTo('.fields-custom-code > table > tbody'); |
| 338 | |
| 339 | $('.custom-frontend-css').appendTo('.fields-custom-code .enable-custom-frontend-css .asenha-subfields'); |
| 340 | $('.insert-head-body-footer-code').appendTo('.fields-custom-code > table > tbody'); |
| 341 | $('.disable-code-unslash').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 342 | $('.head-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 343 | $('.head-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 344 | $('.body-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 345 | $('.body-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 346 | $('.footer-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 347 | $('.footer-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 348 | $('.enable-custom-body-class').appendTo('.fields-custom-code > table > tbody'); |
| 349 | $('.enable-custom-body-class-for').appendTo('.fields-custom-code .enable-custom-body-class .asenha-subfields'); |
| 350 | $('.manage-ads-appads-txt').appendTo('.fields-custom-code > table > tbody'); |
| 351 | $('.ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 352 | $('.app-ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 353 | $('.manage-robots-txt').appendTo('.fields-custom-code > table > tbody'); |
| 354 | $('.robots-txt-content').appendTo('.fields-custom-code .manage-robots-txt .asenha-subfields'); |
| 355 | |
| 356 | // Place fields into the "Disable Components" tab |
| 357 | $('.disable-gutenberg').appendTo('.fields-disable-components > table > tbody'); |
| 358 | |
| 359 | $('.disable-gutenberg-for').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 360 | $('.disable-gutenberg-frontend-styles').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 361 | $('.disable-comments').appendTo('.fields-disable-components > table > tbody'); |
| 362 | |
| 363 | $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields'); |
| 364 | $('.disable-comments-all-cpts-description').appendTo('.fields-disable-components .disable-comments .asenha-subfields'); |
| 365 | $('.disable-rest-api').appendTo('.fields-disable-components > table > tbody'); |
| 366 | |
| 367 | $('.disable-feeds').appendTo('.fields-disable-components > table > tbody'); |
| 368 | $('.disable-embeds').appendTo('.fields-disable-components > table > tbody'); |
| 369 | $('.disable-all-updates').appendTo('.fields-disable-components > table > tbody'); |
| 370 | $('.disable-author-archives').appendTo('.fields-disable-components > table > tbody'); |
| 371 | $('.disable-smaller-components').appendTo('.fields-disable-components > table > tbody'); |
| 372 | $('.disable-head-generator-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 373 | $('.disable-feed-generator-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 374 | $('.disable-resource-version-number').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 375 | $('.disable-head-wlwmanifest-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 376 | $('.disable-head-rsd-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 377 | $('.disable-head-shortlink-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 378 | $('.disable-frontend-dashicons').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 379 | $('.disable-emoji-support').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 380 | $('.disable-jquery-migrate').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 381 | $('.disable-block-widgets').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 382 | $('.disable-lazy-load').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 383 | $('.disable-application-passwords').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 384 | $('.disable-plugin-theme-editor').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 385 | |
| 386 | // Place fields into "Security" tab |
| 387 | $('.limit-login-attempts').appendTo('.fields-security > table > tbody'); |
| 388 | $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 389 | $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 390 | |
| 391 | $('.limit-login-attempts-header-override').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 392 | $('.limit-login-attempts-header-override-description').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 393 | $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 394 | |
| 395 | $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody'); |
| 396 | $('.obfuscate-email-address').appendTo('.fields-security > table > tbody'); |
| 397 | $('.obfuscate-email-address-description').appendTo('.fields-security .obfuscate-email-address .asenha-subfields'); |
| 398 | |
| 399 | $('.disable-xmlrpc').appendTo('.fields-security > table > tbody'); |
| 400 | |
| 401 | // Place fields into "Optimizations" tab |
| 402 | $('.image-upload-control').appendTo('.fields-optimizations > table > tbody'); |
| 403 | $('.image-max-width').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 404 | $('.image-max-height').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 405 | |
| 406 | $('.image-upload-control-description').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 407 | |
| 408 | $('.enable-revisions-control').appendTo('.fields-optimizations > table > tbody'); |
| 409 | $('.revisions-max-number').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields'); |
| 410 | $('.enable-revisions-control-for').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields'); |
| 411 | $('.enable-heartbeat-control').appendTo('.fields-optimizations > table > tbody'); |
| 412 | $('.heartbeat-control-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 413 | $('.heartbeat-interval-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 414 | $('.heartbeat-control-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 415 | $('.heartbeat-interval-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 416 | $('.heartbeat-control-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 417 | $('.heartbeat-interval-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 418 | |
| 419 | // Place fields into "Utilities" tab |
| 420 | $('.smtp-email-delivery').appendTo('.fields-utilities > table > tbody'); |
| 421 | $('.smtp-default-from-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 422 | $('.smtp-default-from-name').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 423 | $('.smtp-default-from-email').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 424 | $('.smtp-force-from').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 425 | |
| 426 | $('.smtp--description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 427 | $('.smtp-host').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 428 | $('.smtp-port').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 429 | $('.smtp-security').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 430 | |
| 431 | $('.smtp-username').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 432 | $('.smtp-password').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 433 | $('.smtp-bypass-ssl-verification').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 434 | $('.smtp-debug').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 435 | |
| 436 | $('.smtp-send-test-email-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 437 | $('.smtp-send-test-email-to').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 438 | $('.smtp-send-test-email-result').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 439 | |
| 440 | $('.multiple-user-roles').appendTo('.fields-utilities > table > tbody'); |
| 441 | $('.image-sizes-panel').appendTo('.fields-utilities > table > tbody'); |
| 442 | $('.view-admin-as-role').appendTo('.fields-utilities > table > tbody'); |
| 443 | $('.view-admin-as-role-description').appendTo('.fields-utilities .view-admin-as-role .asenha-subfields'); |
| 444 | $('.enable-password-protection').appendTo('.fields-utilities > table > tbody'); |
| 445 | $('.password-protection-password').appendTo('.fields-utilities .enable-password-protection .asenha-subfields'); |
| 446 | |
| 447 | $('.password-protection-notes').appendTo('.fields-utilities .enable-password-protection .asenha-subfields'); |
| 448 | $('.maintenance-mode').appendTo('.fields-utilities > table > tbody'); |
| 449 | |
| 450 | $('.maintenance-page-type-custom').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 451 | |
| 452 | $('.maintenance-page-heading').appendTo('.maintenance-page-type-custom'); |
| 453 | $('.maintenance-page-description').appendTo('.maintenance-page-type-custom'); |
| 454 | |
| 455 | $('.maintenance-page-background').appendTo('.maintenance-page-type-custom'); |
| 456 | |
| 457 | $('.maintenance-mode-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 458 | |
| 459 | $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody'); |
| 460 | |
| 461 | $('.display-system-summary').appendTo('.fields-utilities > table > tbody'); |
| 462 | $('.search-engine-visibility-status').appendTo('.fields-utilities > table > tbody'); |
| 463 | |
| 464 | |
| 465 | // Remove empty .form-table that originally holds the fields |
| 466 | const formTableCount = $('.form-table').length; |
| 467 | // $('.form-table')[formTableCount-1].remove(); |
| 468 | |
| 469 | // Enable Custom Admin CSS => Initialize CodeMirror |
| 470 | var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]"); |
| 471 | // if ( typeof CodeMirror != "undefined" ) { |
| 472 | // alert('CodeMirror is available'); |
| 473 | // } |
| 474 | var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, { |
| 475 | mode: "css", |
| 476 | lineNumbers: true, |
| 477 | lineWrapping: true |
| 478 | }); |
| 479 | |
| 480 | adminCssEditor.setSize("100%",600); |
| 481 | |
| 482 | // Enable Custom Frontend CSS => Initialize CodeMirror |
| 483 | var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]"); |
| 484 | var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, { |
| 485 | mode: "css", |
| 486 | lineNumbers: true, |
| 487 | lineWrapping: true |
| 488 | }); |
| 489 | |
| 490 | frontendCssEditor.setSize("100%",600); |
| 491 | |
| 492 | // Manage ads.txt and app-ads.txt=> Initialize CodeMirror |
| 493 | var adsTxtTextarea = document.getElementById("admin_site_enhancements[ads_txt_content]"); |
| 494 | var adsTxtEditor = CodeMirror.fromTextArea(adsTxtTextarea, { |
| 495 | mode: "markdown", |
| 496 | lineNumbers: true, |
| 497 | lineWrapping: true |
| 498 | }); |
| 499 | |
| 500 | adsTxtEditor.setSize("100%",300); |
| 501 | |
| 502 | var appAdsTxtTextarea = document.getElementById("admin_site_enhancements[app_ads_txt_content]"); |
| 503 | var appAdsTxtEditor = CodeMirror.fromTextArea(appAdsTxtTextarea, { |
| 504 | mode: "markdown", |
| 505 | lineNumbers: true, |
| 506 | lineWrapping: true |
| 507 | }); |
| 508 | |
| 509 | appAdsTxtEditor.setSize("100%",300); |
| 510 | |
| 511 | // Manage robots.txt => Initialize CodeMirror |
| 512 | var robotsTxtTextarea = document.getElementById("admin_site_enhancements[robots_txt_content]"); |
| 513 | var robotsTxtEditor = CodeMirror.fromTextArea(robotsTxtTextarea, { |
| 514 | mode: "markdown", |
| 515 | lineNumbers: true, |
| 516 | lineWrapping: true |
| 517 | }); |
| 518 | |
| 519 | robotsTxtEditor.setSize("100%",400); |
| 520 | |
| 521 | // Insert <head>, <body> and <footer> code => Initialize CodeMirror |
| 522 | var headCodeTextarea = document.getElementById("admin_site_enhancements[head_code]"); |
| 523 | var headCodeEditor = CodeMirror.fromTextArea(headCodeTextarea, { |
| 524 | mode: "htmlmixed", |
| 525 | lineNumbers: true, |
| 526 | lineWrapping: true |
| 527 | }); |
| 528 | headCodeEditor.setSize("100%",300); |
| 529 | |
| 530 | var bodyCodeTextarea = document.getElementById("admin_site_enhancements[body_code]"); |
| 531 | var bodyCodeEditor = CodeMirror.fromTextArea(bodyCodeTextarea, { |
| 532 | mode: "htmlmixed", |
| 533 | lineNumbers: true, |
| 534 | lineWrapping: true |
| 535 | }); |
| 536 | bodyCodeEditor.setSize("100%",300); |
| 537 | |
| 538 | var footerCodeTextarea = document.getElementById("admin_site_enhancements[footer_code]"); |
| 539 | var footerCodeEditor = CodeMirror.fromTextArea(footerCodeTextarea, { |
| 540 | mode: "htmlmixed", |
| 541 | lineNumbers: true, |
| 542 | lineWrapping: true |
| 543 | }); |
| 544 | footerCodeEditor.setSize("100%",300); |
| 545 | |
| 546 | |
| 547 | |
| 548 | function refreshCodeMirror() { |
| 549 | |
| 550 | adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror |
| 551 | frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror |
| 552 | adsTxtEditor.refresh(); // Manage ads.txt >> CodeMirror |
| 553 | appAdsTxtEditor.refresh(); // Manage app-ads.txt >> CodeMirror |
| 554 | headCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 555 | bodyCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 556 | footerCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 557 | robotsTxtEditor.refresh(); // Manage robots.txt >> CodeMirror |
| 558 | |
| 559 | } |
| 560 | |
| 561 | // Show and hide corresponding fields on tab clicks |
| 562 | |
| 563 | function tabSwitcher( tabSlug ) { |
| 564 | $('.asenha-fields.fields-'+tabSlug).addClass('section-visible'); |
| 565 | $('.asenha-fields.fields-'+tabSlug).removeClass('section-hidden'); |
| 566 | $('.asenha-fields:not(.fields-'+tabSlug+')').removeClass('section-visible'); |
| 567 | $('.asenha-fields:not(.fields-'+tabSlug+')').addClass('section-hidden'); |
| 568 | window.location.hash = tabSlug; |
| 569 | Cookies.set('asenha_tab', tabSlug, { expires: 1 }); // expires in 1 day |
| 570 | } |
| 571 | |
| 572 | $('#tab-content-management + label').click( function() { |
| 573 | tabSwitcher('content-management'); |
| 574 | }); |
| 575 | |
| 576 | $('#tab-admin-interface + label').click( function() { |
| 577 | tabSwitcher('admin-interface'); |
| 578 | }); |
| 579 | |
| 580 | $('#tab-login-logout + label').click( function() { |
| 581 | tabSwitcher('login-logout'); |
| 582 | refreshCodeMirror(); |
| 583 | }); |
| 584 | |
| 585 | $('#tab-custom-code + label').click( function() { |
| 586 | tabSwitcher('custom-code'); |
| 587 | refreshCodeMirror(); |
| 588 | }); |
| 589 | |
| 590 | $('#tab-disable-components + label').click( function() { |
| 591 | tabSwitcher('disable-components'); |
| 592 | }); |
| 593 | |
| 594 | $('#tab-security + label').click( function() { |
| 595 | tabSwitcher('security'); |
| 596 | }); |
| 597 | |
| 598 | $('#tab-optimizations + label').click( function() { |
| 599 | tabSwitcher('optimizations'); |
| 600 | }); |
| 601 | |
| 602 | $('#tab-utilities + label').click( function() { |
| 603 | tabSwitcher('utilities'); |
| 604 | refreshCodeMirror(); |
| 605 | }); |
| 606 | |
| 607 | // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty |
| 608 | var asenhaTabHash = Cookies.get('asenha_tab'); |
| 609 | |
| 610 | if (typeof asenhaTabHash === 'undefined') { |
| 611 | $('#tab-content-management + label').trigger('click'); |
| 612 | } else { |
| 613 | $('#tab-' + asenhaTabHash + ' + label').trigger('click'); |
| 614 | } |
| 615 | |
| 616 | // Show or hide subfields on document ready and on toggle click |
| 617 | |
| 618 | function subfieldsToggler( fieldId, fieldClass, sortableId, codeMirrorInstances ) { |
| 619 | |
| 620 | if (document.getElementById('admin_site_enhancements['+fieldId+']')) { |
| 621 | |
| 622 | // Show/hide subfields on document ready, depending on if module is enabled or not |
| 623 | if ( document.getElementById('admin_site_enhancements['+fieldId+']').checked ) { |
| 624 | |
| 625 | $('.'+fieldClass+' .asenha-subfields').show(); |
| 626 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 627 | $('.'+fieldClass+' .asenha-subfield-select-inner').show(); |
| 628 | } |
| 629 | $('.asenha-toggle.'+fieldClass+' td .asenha-field-with-options').addClass('is-enabled'); |
| 630 | if ( codeMirrorInstances ) { |
| 631 | Object.keys(codeMirrorInstances).forEach(function(key) { |
| 632 | if ( codeMirrorInstances[key] ) { |
| 633 | codeMirrorInstances[key].refresh(); |
| 634 | } |
| 635 | }); |
| 636 | } |
| 637 | |
| 638 | } else { |
| 639 | |
| 640 | $('.'+fieldClass+' .asenha-subfields').hide(); |
| 641 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 642 | $('.'+fieldClass+' .asenha-subfield-select-inner').hide(); |
| 643 | } |
| 644 | |
| 645 | } |
| 646 | |
| 647 | // Show/hide subfields on toggle click |
| 648 | document.getElementById('admin_site_enhancements['+fieldId+']').addEventListener('click', event => { |
| 649 | if (event.target.checked) { |
| 650 | |
| 651 | $('.'+fieldClass+' .asenha-subfields').fadeIn(); |
| 652 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 653 | $('.'+fieldClass+' .asenha-subfield-select-inner').show(); |
| 654 | } |
| 655 | $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled'); |
| 656 | if (document.getElementById(sortableId)) { |
| 657 | // Initialize sortable elements: https://api.jqueryui.com/sortable/ |
| 658 | $('#' + sortableId ).sortable(); |
| 659 | } |
| 660 | if ( codeMirrorInstances ) { |
| 661 | Object.keys(codeMirrorInstances).forEach(function(key) { |
| 662 | if ( codeMirrorInstances[key] ) { |
| 663 | codeMirrorInstances[key].refresh(); |
| 664 | } |
| 665 | }); |
| 666 | } |
| 667 | |
| 668 | } else { |
| 669 | |
| 670 | $('.'+fieldClass+' .asenha-subfields').hide(); |
| 671 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 672 | $('.'+fieldClass+' .asenha-subfield-select-inner').hide(); |
| 673 | } |
| 674 | $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled'); |
| 675 | |
| 676 | } |
| 677 | }); |
| 678 | |
| 679 | } |
| 680 | |
| 681 | } |
| 682 | |
| 683 | // Re-init wp_editor for snippet description. Required because the wp_editor was moved in the DOM after document ready. |
| 684 | // Ref: https://stackoverflow.com/a/21519323 |
| 685 | // Ref: https://core.trac.wordpress.org/ticket/19173 |
| 686 | function reinitWpEditor(id) { |
| 687 | tinymce.execCommand('mceRemoveEditor', true, id); |
| 688 | var init = tinymce.extend( {}, tinyMCEPreInit.mceInit[ id ] ); |
| 689 | try { tinymce.init( init ); } catch(e){} |
| 690 | $('textarea[id="' + id + '"]').closest('form').find('input[type="submit"]').click(function(){ |
| 691 | if( getUserSetting( 'editor' ) == 'tmce' ){ |
| 692 | var id = mce.find( 'textarea' ).attr( 'id' ); |
| 693 | tinymce.execCommand( 'mceRemoveEditor', false, id ); |
| 694 | tinymce.execCommand( 'mceAddEditor', false, id ); |
| 695 | } |
| 696 | return true; |
| 697 | }); |
| 698 | } |
| 699 | |
| 700 | |
| 701 | subfieldsToggler( 'enable_duplication', 'enable-duplication' ); |
| 702 | subfieldsToggler( 'content_order', 'content-order' ); |
| 703 | |
| 704 | subfieldsToggler( 'enable_media_replacement', 'enable-media-replacement' ); |
| 705 | subfieldsToggler( 'enable_svg_upload', 'enable-svg-upload' ); |
| 706 | subfieldsToggler( 'enable_avif_upload', 'enable-avif-upload' ); |
| 707 | |
| 708 | subfieldsToggler( 'enable_external_permalinks', 'enable-external-permalinks' ); |
| 709 | |
| 710 | subfieldsToggler( 'enhance_list_tables', 'enhance-list-tables' ); |
| 711 | subfieldsToggler( 'custom_admin_footer_text', 'custom-admin-footer-text' ); |
| 712 | subfieldsToggler( 'wider_admin_menu', 'wider-admin-menu' ); |
| 713 | subfieldsToggler( 'customize_admin_menu', 'customize-admin-menu', 'custom-admin-menu' ); |
| 714 | subfieldsToggler( 'disable_dashboard_widgets', 'disable-dashboard-widgets' ); |
| 715 | subfieldsToggler( 'various_admin_ui_enhancements', 'various-admin-ui-enhancements' ); |
| 716 | |
| 717 | // Clean Up Admin Bar |
| 718 | subfieldsToggler( 'hide_modify_elements', 'hide-modify-elements' ); |
| 719 | |
| 720 | subfieldsToggler( 'hide_admin_bar', 'hide-admin-bar' ); |
| 721 | subfieldsToggler( 'change_login_url', 'change-login-url' ); |
| 722 | subfieldsToggler( 'login_id_type_restriction', 'login-id-type-restriction' ); |
| 723 | |
| 724 | subfieldsToggler( 'redirect_after_login', 'redirect-after-login' ); |
| 725 | subfieldsToggler( 'redirect_after_logout', 'redirect-after-logout' ); |
| 726 | subfieldsToggler( 'enable_custom_admin_css', 'enable-custom-admin-css', '', {adminCssEditor} ); |
| 727 | subfieldsToggler( 'enable_custom_frontend_css', 'enable-custom-frontend-css', '', {frontendCssEditor} ); |
| 728 | subfieldsToggler( 'insert_head_body_footer_code', 'insert-head-body-footer-code', '', {headCodeEditor,bodyCodeEditor,footerCodeEditor} ); |
| 729 | subfieldsToggler( 'enable_custom_body_class', 'enable-custom-body-class' ); |
| 730 | subfieldsToggler( 'manage_ads_appads_txt', 'manage-ads-appads-txt', '', {adsTxtEditor,appAdsTxtEditor} ); |
| 731 | subfieldsToggler( 'manage_robots_txt', 'manage-robots-txt', '', {robotsTxtEditor} ); |
| 732 | |
| 733 | subfieldsToggler( 'disable_gutenberg', 'disable-gutenberg' ); |
| 734 | subfieldsToggler( 'disable_comments', 'disable-comments' ); |
| 735 | |
| 736 | subfieldsToggler( 'disable_smaller_components', 'disable-smaller-components' ); |
| 737 | subfieldsToggler( 'limit_login_attempts', 'limit-login-attempts' ); |
| 738 | |
| 739 | subfieldsToggler( 'obfuscate_email_address', 'obfuscate-email-address' ); |
| 740 | subfieldsToggler( 'image_upload_control', 'image-upload-control' ); |
| 741 | subfieldsToggler( 'enable_revisions_control', 'enable-revisions-control' ); |
| 742 | subfieldsToggler( 'enable_heartbeat_control', 'enable-heartbeat-control' ); |
| 743 | |
| 744 | |
| 745 | // Enable Heartbeat Control => Check if "Modify interval" is chosen/clicked and show/hide the corresponding select field |
| 746 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]:checked').val() == 'modify' ) { |
| 747 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 748 | } |
| 749 | |
| 750 | $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]').click(function() { |
| 751 | var radioValue = $(this).attr('value'); |
| 752 | if ( radioValue == 'modify' ) { |
| 753 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 754 | } else { |
| 755 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').hide(); |
| 756 | } |
| 757 | }); |
| 758 | |
| 759 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]:checked').val() == 'modify' ) { |
| 760 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 761 | } |
| 762 | |
| 763 | $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]').click(function() { |
| 764 | var radioValue = $(this).attr('value'); |
| 765 | if ( radioValue == 'modify' ) { |
| 766 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 767 | } else { |
| 768 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').hide(); |
| 769 | } |
| 770 | }); |
| 771 | |
| 772 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]:checked').val() == 'modify' ) { |
| 773 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 774 | } |
| 775 | |
| 776 | $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]').click(function() { |
| 777 | var radioValue = $(this).attr('value'); |
| 778 | if ( radioValue == 'modify' ) { |
| 779 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 780 | } else { |
| 781 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').hide(); |
| 782 | } |
| 783 | }); |
| 784 | |
| 785 | subfieldsToggler( 'smtp_email_delivery', 'smtp-email-delivery' ); |
| 786 | |
| 787 | |
| 788 | |
| 789 | // SMTP Email Delivery => Empty field value on click, so new password can be easily entered |
| 790 | var oldSmtpPassValue = ''; |
| 791 | |
| 792 | $('input[name="admin_site_enhancements[smtp_password]"]').focusin(function() { |
| 793 | oldSmtpPassValue = $(this).val(); |
| 794 | $(this).val(''); |
| 795 | }); |
| 796 | |
| 797 | $('input[name="admin_site_enhancements[smtp_password]"]').focusout(function() { |
| 798 | if ( $(this).val() == '' ) { |
| 799 | $(this).val(oldSmtpPassValue); |
| 800 | } |
| 801 | }); |
| 802 | |
| 803 | subfieldsToggler( 'view_admin_as_role', 'view-admin-as-role' ); |
| 804 | subfieldsToggler( 'enable_password_protection', 'enable-password-protection' ); |
| 805 | |
| 806 | // Enable Password protection => Empty field value on click, so new password can be easily entered |
| 807 | var oldValue = ''; |
| 808 | $('input[name="admin_site_enhancements[password_protection_password]"]').focusin(function() { |
| 809 | oldValue = $(this).val(); |
| 810 | $(this).val(''); |
| 811 | }); |
| 812 | |
| 813 | $('input[name="admin_site_enhancements[password_protection_password]"]').focusout(function() { |
| 814 | if ( $(this).val() == '' ) { |
| 815 | $(this).val(oldValue); |
| 816 | } |
| 817 | }); |
| 818 | |
| 819 | |
| 820 | subfieldsToggler( 'maintenance_mode', 'maintenance-mode' ); |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | // CAPTCHA Protection |
| 826 | // CAPTCHA Type conditional show/hide |
| 827 | $(document).on('change', 'select[name="admin_site_enhancements[captcha_protection_types]"]', function() { |
| 828 | var selectValue = this.value; |
| 829 | if ( 'altcha' == selectValue ) { |
| 830 | $('.captcha-protection-altcha-wrapper').show(); |
| 831 | $('.captcha-protection-recaptcha-wrapper').hide(); |
| 832 | $('.captcha-protection-turnstile-wrapper').hide(); |
| 833 | // $('input#captcha_woo_locations_woo_checkout_form').prop('disabled', ''); |
| 834 | // $('input#captcha_woo_locations_woo_checkout_form').show(); |
| 835 | // $('label[for="captcha_woo_locations_woo_checkout_form"]').show(); |
| 836 | } else if ( 'recaptcha' == selectValue ) { |
| 837 | $('.captcha-protection-altcha-wrapper').hide(); |
| 838 | $('.captcha-protection-recaptcha-wrapper').show(); |
| 839 | $('.captcha-protection-turnstile-wrapper').hide(); |
| 840 | // $('input#captcha_woo_locations_woo_checkout_form').prop('disabled', ''); |
| 841 | // $('input#captcha_woo_locations_woo_checkout_form').show(); |
| 842 | // $('label[for="captcha_woo_locations_woo_checkout_form"]').show(); |
| 843 | } else if ( 'turnstile' == selectValue ) { |
| 844 | $('.captcha-protection-altcha-wrapper').hide(); |
| 845 | $('.captcha-protection-recaptcha-wrapper').hide(); |
| 846 | $('.captcha-protection-turnstile-wrapper').show(); |
| 847 | // $('input#captcha_woo_locations_woo_checkout_form').prop('disabled', 'disabled'); |
| 848 | // $('input#captcha_woo_locations_woo_checkout_form').hide(); |
| 849 | // $('label[for="captcha_woo_locations_woo_checkout_form"]').hide(); |
| 850 | } |
| 851 | }); |
| 852 | |
| 853 | if ( 'altcha' == $('select[name="admin_site_enhancements[captcha_protection_types]"]').val() ) { |
| 854 | $('.captcha-protection-altcha-wrapper').show(); |
| 855 | $('.captcha-protection-recaptcha-wrapper').hide(); |
| 856 | $('.captcha-protection-turnstile-wrapper').hide(); |
| 857 | $('input#captcha_woo_locations_woo_checkout_form').prop('disabled', ''); |
| 858 | $('input#captcha_woo_locations_woo_checkout_form').show(); |
| 859 | $('label[for="captcha_woo_locations_woo_checkout_form"]').show(); |
| 860 | } else if ( 'recaptcha' == $('select[name="admin_site_enhancements[captcha_protection_types]"]').val() ) { |
| 861 | $('.captcha-protection-altcha-wrapper').hide(); |
| 862 | $('.captcha-protection-recaptcha-wrapper').show(); |
| 863 | $('.captcha-protection-turnstile-wrapper').hide(); |
| 864 | $('input#captcha_woo_locations_woo_checkout_form').prop('disabled', ''); |
| 865 | $('input#captcha_woo_locations_woo_checkout_form').show(); |
| 866 | $('label[for="captcha_woo_locations_woo_checkout_form"]').show(); |
| 867 | } else if ( 'turnstile' == $('select[name="admin_site_enhancements[captcha_protection_types]"]').val() ) { |
| 868 | $('.captcha-protection-altcha-wrapper').hide(); |
| 869 | $('.captcha-protection-recaptcha-wrapper').hide(); |
| 870 | $('.captcha-protection-turnstile-wrapper').show(); |
| 871 | $('input#captcha_woo_locations_woo_checkout_form').prop('disabled', 'disabled'); |
| 872 | $('input#captcha_woo_locations_woo_checkout_form').hide(); |
| 873 | $('label[for="captcha_woo_locations_woo_checkout_form"]').hide(); |
| 874 | } |
| 875 | |
| 876 | // ALTCHA Floating UI conditional value selection |
| 877 | $(document).on('change', 'select[name="admin_site_enhancements[altcha_widget]"]', function() { |
| 878 | var selectValue = this.value; |
| 879 | if ( 'checkbox' == selectValue ) { |
| 880 | $('select[name="admin_site_enhancements[altcha_auto_verification]"]').val(''); |
| 881 | } else if ( 'invisible' == selectValue ) { |
| 882 | $('select[name="admin_site_enhancements[altcha_auto_verification]"]').val('onsubmit'); |
| 883 | } |
| 884 | }); |
| 885 | |
| 886 | if ( 'checkbox' == $('select[name="admin_site_enhancements[altcha_widget]"]').val() ) { |
| 887 | $('select[name="admin_site_enhancements[altcha_auto_verification]"]').val(''); |
| 888 | } else if ( 'invisible' == $('select[name="admin_site_enhancements[altcha_widget]"]').val() ) { |
| 889 | $('select[name="admin_site_enhancements[altcha_auto_verification]"]').val('onsubmit'); |
| 890 | } |
| 891 | |
| 892 | // reCAPTCHA Type conditional show/hide |
| 893 | $(document).on('change', 'select[name="admin_site_enhancements[recaptcha_widget]"]', function() { |
| 894 | var selectValue = this.value; |
| 895 | if ( 'v2_checkbox' == selectValue ) { |
| 896 | $('.recaptcha-site-key-v2-checkbox').show(); |
| 897 | $('.recaptcha-secret-key-v2-checkbox').show(); |
| 898 | $('.recaptcha-site-key-v3-invisible').hide(); |
| 899 | $('.recaptcha-secret-key-v3-invisible').hide(); |
| 900 | } else if ( 'v3_invisible' == selectValue ) { |
| 901 | $('.recaptcha-site-key-v2-checkbox').hide(); |
| 902 | $('.recaptcha-secret-key-v2-checkbox').hide(); |
| 903 | $('.recaptcha-site-key-v3-invisible').show(); |
| 904 | $('.recaptcha-secret-key-v3-invisible').show(); |
| 905 | } |
| 906 | }); |
| 907 | |
| 908 | if ( 'v2_checkbox' == $('select[name="admin_site_enhancements[recaptcha_widget]"]').val() ) { |
| 909 | $('.recaptcha-site-key-v2-checkbox').show(); |
| 910 | $('.recaptcha-secret-key-v2-checkbox').show(); |
| 911 | $('.recaptcha-site-key-v3-invisible').hide(); |
| 912 | $('.recaptcha-secret-key-v3-invisible').hide(); |
| 913 | } else if ( 'v3_invisible' == $('select[name="admin_site_enhancements[recaptcha_widget]"]').val() ) { |
| 914 | $('.recaptcha-site-key-v2-checkbox').hide(); |
| 915 | $('.recaptcha-secret-key-v2-checkbox').hide(); |
| 916 | $('.recaptcha-site-key-v3-invisible').show(); |
| 917 | $('.recaptcha-secret-key-v3-invisible').show(); |
| 918 | } |
| 919 | |
| 920 | // Email Address Obfuscator |
| 921 | if ( $('input[name="admin_site_enhancements[obfuscate_email_address_in_content]"]').is(':checked') ) { |
| 922 | $('.obfuscate-email-address-visitor-only').show(); |
| 923 | } else { |
| 924 | $('.obfuscate-email-address-visitor-only').hide(); |
| 925 | } |
| 926 | |
| 927 | $('input[name="admin_site_enhancements[obfuscate_email_address_in_content]"]').click(function() { |
| 928 | if ($(this).is(':checked')) { |
| 929 | $('.obfuscate-email-address-visitor-only').show(); |
| 930 | } else { |
| 931 | $('.obfuscate-email-address-visitor-only').hide(); |
| 932 | } |
| 933 | }); |
| 934 | |
| 935 | // Image Upload Control |
| 936 | if ( $('input[name="admin_site_enhancements[convert_to_webp]"]').is(':checked') ) { |
| 937 | $('.convert-to-jpg-quality').hide(); |
| 938 | $('.convert-to-webp-quality').show(); |
| 939 | } else { |
| 940 | $('.convert-to-jpg-quality').show(); |
| 941 | $('.convert-to-webp-quality').hide(); |
| 942 | } |
| 943 | |
| 944 | $('input[name="admin_site_enhancements[convert_to_webp]"]').click(function() { |
| 945 | if ($(this).is(':checked')) { |
| 946 | $('.convert-to-jpg-quality').hide(); |
| 947 | $('.convert-to-webp-quality').show(); |
| 948 | } else { |
| 949 | $('.convert-to-jpg-quality').show(); |
| 950 | $('.convert-to-webp-quality').hide(); |
| 951 | } |
| 952 | }); |
| 953 | |
| 954 | if ( $('input[name="admin_site_enhancements[disable_image_conversion]"]').is(':checked') ) { |
| 955 | $('.image-conversion-wrapper').hide(); |
| 956 | } else { |
| 957 | $('.image-conversion-wrapper').show(); |
| 958 | } |
| 959 | |
| 960 | $('input[name="admin_site_enhancements[disable_image_conversion]"]').click(function() { |
| 961 | if ($(this).is(':checked')) { |
| 962 | $('.image-conversion-wrapper').hide(); |
| 963 | } else { |
| 964 | $('.image-conversion-wrapper').show(); |
| 965 | } |
| 966 | }); |
| 967 | |
| 968 | function field_value_initial_sync( originSelector, targetSelector ) { |
| 969 | if ( $(originSelector).val() != '' ) { |
| 970 | $(targetSelector).val($(originSelector).val()); |
| 971 | } |
| 972 | } |
| 973 | |
| 974 | function field_value_live_sync( originSelector, targetSelector ) { |
| 975 | $('.asenha-body').on('input', originSelector, function() { |
| 976 | var originValue = $(this).val(); |
| 977 | $(targetSelector).val(originValue); |
| 978 | }); |
| 979 | } |
| 980 | |
| 981 | function field_value_syncing( originSelector, targetSelector ) { |
| 982 | field_value_initial_sync( originSelector, targetSelector ); |
| 983 | field_value_live_sync( originSelector, targetSelector ); |
| 984 | } |
| 985 | |
| 986 | // Form Builder site and secret keys syncing |
| 987 | field_value_syncing('input[name="admin_site_enhancements[altcha_secret_key]"]', 'input[name="admin_site_enhancements[form_builder_altcha_secret_key]"]'); |
| 988 | field_value_syncing('input[name="admin_site_enhancements[recaptcha_site_key_v2_checkbox]"]', 'input[name="admin_site_enhancements[form_builder_recaptcha_site_key_v2_checkbox]"]'); |
| 989 | field_value_syncing('input[name="admin_site_enhancements[recaptcha_secret_key_v2_checkbox]"]', 'input[name="admin_site_enhancements[form_builder_recaptcha_secret_key_v2_checkbox]"]'); |
| 990 | field_value_syncing('input[name="admin_site_enhancements[recaptcha_site_key_v3_invisible]"]', 'input[name="admin_site_enhancements[form_builder_recaptcha_site_key_v3_invisible]"]'); |
| 991 | field_value_syncing('input[name="admin_site_enhancements[recaptcha_secret_key_v3_invisible]"]', 'input[name="admin_site_enhancements[form_builder_recaptcha_secret_key_v3_invisible]"]'); |
| 992 | field_value_syncing('input[name="admin_site_enhancements[turnstile_site_key]"]', 'input[name="admin_site_enhancements[form_builder_turnstile_site_key]"]'); |
| 993 | field_value_syncing('input[name="admin_site_enhancements[turnstile_secret_key]"]', 'input[name="admin_site_enhancements[form_builder_turnstile_secret_key]"]'); |
| 994 | |
| 995 | // Maintenance Mode => Use a customizable page vs Use an existing page |
| 996 | if ( $('input[name="admin_site_enhancements[maintenance_page_type]"]:checked').val() == 'custom' ) { |
| 997 | $('.maintenance-page-type-custom').show(); |
| 998 | $('tr.maintenance-page-slug').hide(); |
| 999 | } else if ( $('input[name="admin_site_enhancements[maintenance_page_type]"]:checked').val() == 'existing' ) { |
| 1000 | $('.maintenance-page-type-custom').hide(); |
| 1001 | $('tr.maintenance-page-slug').show(); |
| 1002 | } else { |
| 1003 | $('.maintenance-page-type-custom').show(); |
| 1004 | $('tr.maintenance-page-slug').hide(); |
| 1005 | } |
| 1006 | |
| 1007 | $('input[name="admin_site_enhancements[maintenance_page_type]"]').click(function() { |
| 1008 | var radioValue = $(this).attr('value'); |
| 1009 | if ( radioValue == 'custom' ) { |
| 1010 | $('.maintenance-page-type-custom').show(); |
| 1011 | $('tr.maintenance-page-slug').hide(); |
| 1012 | } else if ( radioValue == 'existing' ) { |
| 1013 | $('.maintenance-page-type-custom').hide(); |
| 1014 | $('tr.maintenance-page-slug').show(); |
| 1015 | } else { |
| 1016 | $('.maintenance-page-type-custom').show(); |
| 1017 | $('tr.maintenance-page-slug').hide(); |
| 1018 | } |
| 1019 | }); |
| 1020 | |
| 1021 | // Maintenance Mode => Check if 'Image' or 'Color' is chosen/clicked and show/hide the corresponding select field |
| 1022 | if ( $('input[name="admin_site_enhancements[maintenance_page_background]"]:checked').val() == 'pattern' ) { |
| 1023 | $('tr.maintenance-page-background-pattern').show(); |
| 1024 | $('tr.maintenance-page-background-image').hide(); |
| 1025 | $('tr.maintenance-page-background-color').hide(); |
| 1026 | } else if( $('input[name="admin_site_enhancements[maintenance_page_background]"]:checked').val() == 'image' ) { |
| 1027 | $('tr.maintenance-page-background-pattern').hide(); |
| 1028 | $('tr.maintenance-page-background-image').show(); |
| 1029 | $('tr.maintenance-page-background-color').hide(); |
| 1030 | } else if ( $('input[name="admin_site_enhancements[maintenance_page_background]"]:checked').val() == 'solid_color' ) { |
| 1031 | $('tr.maintenance-page-background-pattern').hide(); |
| 1032 | $('tr.maintenance-page-background-image').hide(); |
| 1033 | $('tr.maintenance-page-background-color').show(); |
| 1034 | } else { |
| 1035 | $('tr.maintenance-page-background-pattern').hide(); |
| 1036 | $('tr.maintenance-page-background-image').hide(); |
| 1037 | $('tr.maintenance-page-background-color').hide(); |
| 1038 | } |
| 1039 | |
| 1040 | $('input[name="admin_site_enhancements[maintenance_page_background]"]').click(function() { |
| 1041 | var radioValue = $(this).attr('value'); |
| 1042 | if ( radioValue == 'pattern' ) { |
| 1043 | $('tr.maintenance-page-background-pattern').show(); |
| 1044 | $('tr.maintenance-page-background-image').hide(); |
| 1045 | $('tr.maintenance-page-background-color').hide(); |
| 1046 | } else if ( radioValue == 'image' ) { |
| 1047 | $('tr.maintenance-page-background-pattern').hide(); |
| 1048 | $('tr.maintenance-page-background-image').show(); |
| 1049 | $('tr.maintenance-page-background-color').hide(); |
| 1050 | } else if ( radioValue == 'solid_color' ) { |
| 1051 | $('tr.maintenance-page-background-pattern').hide(); |
| 1052 | $('tr.maintenance-page-background-image').hide(); |
| 1053 | $('tr.maintenance-page-background-color').show(); |
| 1054 | } else { |
| 1055 | $('tr.maintenance-page-background-pattern').hide(); |
| 1056 | $('tr.maintenance-page-background-image').hide(); |
| 1057 | $('tr.maintenance-page-background-color').hide(); |
| 1058 | } |
| 1059 | }); |
| 1060 | /*! </fs_premium_only> */ |
| 1061 | |
| 1062 | // Content Toggler |
| 1063 | $('.asenha-body').on('click', '.asenha-content-toggler', function(e) { |
| 1064 | e.preventDefault(); |
| 1065 | var targetSelector = $(this).data('target-selector'); |
| 1066 | var showText = $(this).data('show-text'); |
| 1067 | var hideText = $(this).data('hide-text'); |
| 1068 | var expanded = $(this).attr('data-expanded'); |
| 1069 | // $(targetSelector).toggle(); |
| 1070 | if (expanded == 'no') { |
| 1071 | $(targetSelector).slideDown(200); |
| 1072 | $(this).html(hideText + ' <span>▲</span>'); |
| 1073 | $(this).attr('data-expanded','yes'); |
| 1074 | } else { |
| 1075 | $(targetSelector).slideUp(200); |
| 1076 | $(this).html(showText + ' <span>▼</span>'); |
| 1077 | $(this).attr('data-expanded','no'); |
| 1078 | } |
| 1079 | }); |
| 1080 | |
| 1081 | // Media frame handler for image selection / upload fields |
| 1082 | // Reference: https://plugins.trac.wordpress.org/browser/bm-custom-login/trunk/bm-custom-login.php |
| 1083 | function media_frame_init( selector, button_selector ) { |
| 1084 | // media_frame_init( '#login-page-logo-image', '#login-page-logo-image-button' ); |
| 1085 | var theSelector = $(selector); |
| 1086 | var button = $(button_selector); |
| 1087 | |
| 1088 | button.click(function (event) { |
| 1089 | event.preventDefault(); |
| 1090 | |
| 1091 | // Configuration of the media frame new instance |
| 1092 | wp.media.frames.frame = wp.media({ |
| 1093 | title: adminPageVars.mediaFrameTitle, |
| 1094 | multiple: false, |
| 1095 | library: { |
| 1096 | type: 'image' |
| 1097 | }, |
| 1098 | button: { |
| 1099 | text: adminPageVars.mediaFrameButtonText |
| 1100 | } |
| 1101 | }); |
| 1102 | |
| 1103 | // Function used for the image selection and media manager closing |
| 1104 | var media_set_image = function() { |
| 1105 | var selection = wp.media.frames.frame.state().get('selection'); |
| 1106 | |
| 1107 | // Nothing is selected |
| 1108 | if (!selection) { |
| 1109 | return; |
| 1110 | } |
| 1111 | |
| 1112 | // Iterate through selected elements |
| 1113 | selection.each(function(attachment) { |
| 1114 | // console.log(attachment); |
| 1115 | var url = attachment.attributes.url; |
| 1116 | url = url.replace( adminPageVars.wpcontentUrl, '' ); |
| 1117 | theSelector.val(url); |
| 1118 | |
| 1119 | if ( '#login-page-logo-image' == selector ) { |
| 1120 | var attachmentId = $('.login-page-logo-image-attachment-id input'); |
| 1121 | var originalWidthInput = $('.login-page-logo-image-width-original input'); |
| 1122 | var originalHeightInput = $('.login-page-logo-image-height-original input'); |
| 1123 | var widthInput = $('.login-page-logo-image-width input'); |
| 1124 | var heightInput = $('.login-page-logo-image-height input'); |
| 1125 | attachmentId.val(attachment.attributes.id); |
| 1126 | originalWidthInput.val(attachment.attributes.width); |
| 1127 | originalHeightInput.val(attachment.attributes.height); |
| 1128 | widthInput.val(attachment.attributes.width); |
| 1129 | heightInput.val(attachment.attributes.height); |
| 1130 | } |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | if ( '#form-builder-email-header-image' == selector ) { |
| 1135 | var attachmentId = $('.form-builder-email-header-image-attachment-id input'); |
| 1136 | attachmentId.val(attachment.attributes.id); |
| 1137 | } |
| 1138 | }); |
| 1139 | }; |
| 1140 | |
| 1141 | wp.media.frames.frame.on('close', media_set_image); |
| 1142 | wp.media.frames.frame.on('select', media_set_image); |
| 1143 | wp.media.frames.frame.open(); |
| 1144 | }); |
| 1145 | } |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | // Form Builder - Empty out stored/hidden attachment ID when "Email header image" field is emptied |
| 1150 | var emailHeaderImage = $('#form-builder-email-header-image'); |
| 1151 | var emailHeaderImageAttachmentId = $('.form-builder-email-header-image-attachment-id input'); |
| 1152 | |
| 1153 | $(emailHeaderImage).keyup(delay(function (e) { |
| 1154 | if ($(this).val().length === 0) { |
| 1155 | emailHeaderImageAttachmentId.val(""); |
| 1156 | } |
| 1157 | }, 200)); |
| 1158 | |
| 1159 | // =============== Image Ratio Calculator / Preservation for Login Page Customizer >> Logo Image ================= |
| 1160 | |
| 1161 | // Code modified from: https://codepen.io/tobiasdev/pen/XNjxdZ by Tobias Bogliolo |
| 1162 | |
| 1163 | var initialWidth, initialHeight, newWidth, newHeight, aspectRatio; |
| 1164 | |
| 1165 | //Get new values: |
| 1166 | function getValues(){ |
| 1167 | initialWidth = $(".login-page-logo-image-width-original input").val(); |
| 1168 | initialHeight = $(".login-page-logo-image-height-original input").val(); |
| 1169 | newWidth = $(".login-page-logo-image-width input").val(); |
| 1170 | newHeight = $(".login-page-logo-image-height input").val(); |
| 1171 | }; |
| 1172 | |
| 1173 | //Aspect ratio: |
| 1174 | function getAspectRatio(){ |
| 1175 | // Formula: "Aspect Ratio = Width / Height". |
| 1176 | return aspectRatio = initialWidth/initialHeight; |
| 1177 | }; |
| 1178 | |
| 1179 | //Get new height: |
| 1180 | $(".login-page-logo-image-width input").on("change keyup", function(){ |
| 1181 | // Refresh data. |
| 1182 | getValues(); |
| 1183 | getAspectRatio(); |
| 1184 | // New height = new width / (original width / original height). |
| 1185 | newHeight = Math.round(newWidth/aspectRatio); |
| 1186 | // Output: |
| 1187 | $(".login-page-logo-image-height input").val(newHeight); |
| 1188 | }); |
| 1189 | |
| 1190 | //Get new width: |
| 1191 | $(".login-page-logo-image-height input").on("change keyup", function(){ |
| 1192 | // Refresh data. |
| 1193 | getValues(); |
| 1194 | getAspectRatio(); |
| 1195 | // New width = (original width / original height) * new height. |
| 1196 | newWidth = Math.round(newHeight*aspectRatio); |
| 1197 | // Output: |
| 1198 | $(".login-page-logo-image-width input").val(newWidth); |
| 1199 | }); |
| 1200 | |
| 1201 | //Reset: |
| 1202 | $(".login-page-logo-image-width-original input, .login-page-logo-image-height-original input").on("change keyup", function(){ |
| 1203 | // Output: |
| 1204 | $(".login-page-logo-image-width input").val(""); |
| 1205 | $(".login-page-logo-image-height input").val(""); |
| 1206 | }); |
| 1207 | |
| 1208 | // =============== ASE PRO ================= |
| 1209 | |
| 1210 | if ( asenhaStats.isYearEndPromoPeriod ) { |
| 1211 | |
| 1212 | // Promo nudge |
| 1213 | if ( asenhaStats.hidePromoNudge ) { |
| 1214 | $('.asenha-promo-nudge').hide(); |
| 1215 | $('#bottom-upgrade-nudge').show(); |
| 1216 | } else { |
| 1217 | $('.asenha-promo-nudge').show(); |
| 1218 | $('#bottom-upgrade-nudge').hide(); |
| 1219 | } |
| 1220 | |
| 1221 | $('#dismiss-promo-nudge').click(function(e) { |
| 1222 | e.preventDefault(); |
| 1223 | $.ajax({ |
| 1224 | url: ajaxurl, |
| 1225 | data: { |
| 1226 | 'action':'dismiss_promo_nudge', |
| 1227 | 'nonce': adminPageVars.nonce |
| 1228 | }, |
| 1229 | success:function(data) { |
| 1230 | $('.asenha-promo-nudge').hide(); |
| 1231 | }, |
| 1232 | error:function(errorThrown) { |
| 1233 | console.log(errorThrown); |
| 1234 | } |
| 1235 | }); |
| 1236 | }); |
| 1237 | |
| 1238 | } else { |
| 1239 | |
| 1240 | // Upgrade nudge to Pro |
| 1241 | if ( asenhaStats.hideUpgradeNudge ) { |
| 1242 | $('.asenha-upgrade-nudge').hide(); |
| 1243 | $('#bottom-upgrade-nudge').show(); |
| 1244 | } else { |
| 1245 | $('.asenha-upgrade-nudge').show(); |
| 1246 | $('#bottom-upgrade-nudge').hide(); |
| 1247 | } |
| 1248 | |
| 1249 | $('#dismiss-upgrade-nudge').click(function(e) { |
| 1250 | e.preventDefault(); |
| 1251 | $.ajax({ |
| 1252 | url: ajaxurl, |
| 1253 | data: { |
| 1254 | 'action':'dismiss_upgrade_nudge', |
| 1255 | 'nonce': adminPageVars.nonce |
| 1256 | }, |
| 1257 | success:function(data) { |
| 1258 | $('.asenha-upgrade-nudge').hide(); |
| 1259 | // $('#bottom-upgrade-nudge').show(); |
| 1260 | }, |
| 1261 | error:function(errorThrown) { |
| 1262 | console.log(errorThrown); |
| 1263 | } |
| 1264 | }); |
| 1265 | }); |
| 1266 | |
| 1267 | } |
| 1268 | |
| 1269 | // =============== SPONSORSHIP ================= |
| 1270 | |
| 1271 | // Stats on saving changes from asenha_admin_scripts() wp_localize_script() is availble in the 'asenhaStats' object----- |
| 1272 | // console.log( asenhaStats ); |
| 1273 | // alert(JSON.stringify(asenhaStats)); |
| 1274 | if ( asenhaStats.showSupportNudge ) { |
| 1275 | $('.asenha-support-nudge').show(); |
| 1276 | } else { |
| 1277 | $('.asenha-support-nudge').hide(); |
| 1278 | } |
| 1279 | |
| 1280 | $('#have-shared,#have-reviewed').click(function(e) { |
| 1281 | e.preventDefault(); |
| 1282 | // $.ajax({ |
| 1283 | // url: 'https://bowo.io/asenha-sp-ndg', |
| 1284 | // method: 'GET', |
| 1285 | // dataType: 'jsonp', |
| 1286 | // crossDomain: true |
| 1287 | // }); |
| 1288 | $.ajax({ |
| 1289 | url: ajaxurl, |
| 1290 | data: { |
| 1291 | 'action':'have_supported', |
| 1292 | 'nonce': adminPageVars.nonce |
| 1293 | }, |
| 1294 | success:function(data) { |
| 1295 | $('.asenha-support-nudge').hide(); |
| 1296 | }, |
| 1297 | error:function(errorThrown) { |
| 1298 | console.log(errorThrown); |
| 1299 | } |
| 1300 | }); |
| 1301 | }); |
| 1302 | |
| 1303 | $('#support-nudge-dismiss').click(function(e) { |
| 1304 | e.preventDefault(); |
| 1305 | // $.ajax({ |
| 1306 | // url: 'https://bowo.io/asenha-sp-ndg', |
| 1307 | // method: 'GET', |
| 1308 | // dataType: 'jsonp', |
| 1309 | // crossDomain: true |
| 1310 | // }); |
| 1311 | $.ajax({ |
| 1312 | url: ajaxurl, |
| 1313 | data: { |
| 1314 | 'action':'dismiss_support_nudge', |
| 1315 | 'nonce': adminPageVars.nonce |
| 1316 | }, |
| 1317 | success:function(data) { |
| 1318 | $('.asenha-support-nudge').hide(); |
| 1319 | }, |
| 1320 | error:function(errorThrown) { |
| 1321 | console.log(errorThrown); |
| 1322 | } |
| 1323 | }); |
| 1324 | }); |
| 1325 | |
| 1326 | // Expand support notice | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 1327 | $('.asenha-support-nudge.nudge-show-more > .show-more').click(function(e) { |
| 1328 | |
| 1329 | e.preventDefault(); |
| 1330 | |
| 1331 | var $this = $(this); |
| 1332 | $this.toggleClass('show-more'); |
| 1333 | $this.hide(); |
| 1334 | |
| 1335 | if ($this.hasClass('show-more')) { |
| 1336 | $this.next().removeClass('opened',0); |
| 1337 | } else { |
| 1338 | $this.next().addClass('opened',0); |
| 1339 | } |
| 1340 | |
| 1341 | }); |
| 1342 | |
| 1343 | // Collapse support notice | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 1344 | $('#support-nudge-show-less').click(function(e) { |
| 1345 | |
| 1346 | e.preventDefault(); |
| 1347 | |
| 1348 | $('.nudge-wrapper-show-more').removeClass('opened',0); |
| 1349 | $('#support-nudge-show-moreless').addClass('show-more'); |
| 1350 | $('#support-nudge-show-moreless').show(); |
| 1351 | |
| 1352 | }); |
| 1353 | |
| 1354 | |
| 1355 | |
| 1356 | // Modal for sponsoring plugin dev and maintenance: https://stephanwagner.me/jBox |
| 1357 | |
| 1358 | // var sponsorModal = new jBox('Modal', { |
| 1359 | // attach: '#plugin-sponsor', |
| 1360 | // trigger: 'click', // or 'mouseenter' |
| 1361 | // // content: 'Test' |
| 1362 | // content: $('#asenha-sponsor'), |
| 1363 | // width: 740, // pixels |
| 1364 | // closeButton: 'box', |
| 1365 | // addClass: 'plugin-sponsor-modal', |
| 1366 | // overlayClass: 'plugin-sponsor-modal-overlay', |
| 1367 | // target: '#wpwrap', // where to anchor the modal |
| 1368 | // position: { |
| 1369 | // x: 'center', |
| 1370 | // y: 'top' |
| 1371 | // }, |
| 1372 | // // fade: 1000, |
| 1373 | // animation: { |
| 1374 | // open: 'slide:top', |
| 1375 | // close: 'slide:top' |
| 1376 | // } |
| 1377 | // }); |
| 1378 | |
| 1379 | // $('#plugin-sponsor').click( function() { |
| 1380 | // $.ajax({ |
| 1381 | // url: 'https://bowo.io/asenha-sp-btn', |
| 1382 | // method: 'GET', |
| 1383 | // dataType: 'jsonp', |
| 1384 | // crossDomain: true |
| 1385 | // // success: function(response) { |
| 1386 | // // console.log(response); |
| 1387 | // // } |
| 1388 | // }); |
| 1389 | // }); |
| 1390 | |
| 1391 | }); // END OF $(document).ready() |
| 1392 | |
| 1393 | })( jQuery ); |