codemirror
1 year ago
datatables
1 year ago
admin-page.js
1 year ago
content-order-sort.js
1 year ago
custom-admin-menu.js
1 year ago
external-permalinks.js
1 year ago
gutenberg-content-duplication.js
1 year ago
hide-admin-notices.js
1 year ago
jBox.all.min.js
1 year ago
jquery.jsticky.mod.js
1 year ago
jquery.jsticky.mod.min.js
1 year ago
jquery.mjs.nestedSortable.js
1 year ago
jquery.ui.touch-punch.min.js
1 year ago
js.cookie.min.js
1 year ago
media-replace.js
1 year ago
multiple-user-roles.js
1 year ago
toggle-hidden-menu.js
1 year ago
admin-page.js
890 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(adminPageVars.expandText + ' ▼'); |
| 51 | } else { |
| 52 | $this.next().addClass('opened',0); |
| 53 | $this.html(adminPageVars.collapseText + ' ▲'); |
| 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 | order: [[2, 'desc']], |
| 105 | language: { |
| 106 | emptyTable: adminPageVars.dataTable.emptyTable, |
| 107 | info: adminPageVars.dataTable.info, |
| 108 | infoEmpty: adminPageVars.dataTable.infoEmpty, |
| 109 | infoFiltered: adminPageVars.dataTable.infoFiltered, |
| 110 | lengthMenu: adminPageVars.dataTable.lengthMenu, |
| 111 | search: adminPageVars.dataTable.search, |
| 112 | zeroRecords: adminPageVars.dataTable.zeroRecords, |
| 113 | paginate: { |
| 114 | first: adminPageVars.dataTable.paginate.first, |
| 115 | last: adminPageVars.dataTable.paginate.last, |
| 116 | next: adminPageVars.dataTable.paginate.next, |
| 117 | previous: adminPageVars.dataTable.paginate.previous |
| 118 | }, |
| 119 | } |
| 120 | }); |
| 121 | |
| 122 | // Place fields into the "Content Management" tab |
| 123 | |
| 124 | $('.enable-duplication').appendTo('.fields-content-management > table > tbody'); |
| 125 | $('.duplication-redirect-destination').appendTo('.fields-content-management .enable-duplication .asenha-subfields'); |
| 126 | |
| 127 | $('.content-order').appendTo('.fields-content-management > table > tbody'); |
| 128 | // $('.content-order-subfields-heading').appendTo('.fields-content-management .content-order .asenha-subfields'); |
| 129 | $('.content-order-for').appendTo('.fields-content-management .content-order .asenha-subfields'); |
| 130 | |
| 131 | |
| 132 | $('.enable-media-replacement').appendTo('.fields-content-management > table > tbody'); |
| 133 | $('.enable-svg-upload').appendTo('.fields-content-management > table > tbody'); |
| 134 | $('.enable-svg-upload-for').appendTo('.fields-content-management .enable-svg-upload .asenha-subfields'); |
| 135 | $('.enable-avif-upload').appendTo('.fields-content-management > table > tbody'); |
| 136 | $('.avif-support-status').appendTo('.fields-content-management .enable-avif-upload .asenha-subfields'); |
| 137 | $('.enable-external-permalinks').appendTo('.fields-content-management > table > tbody'); |
| 138 | $('.enable-external-permalinks-for').appendTo('.fields-content-management .enable-external-permalinks .asenha-subfields'); |
| 139 | $('.external-links-new-tab').appendTo('.fields-content-management > table > tbody'); |
| 140 | $('.custom-nav-menu-items-new-tab').appendTo('.fields-content-management > table > tbody'); |
| 141 | $('.enable-missed-schedule-posts-auto-publish').appendTo('.fields-content-management > table > tbody'); |
| 142 | |
| 143 | // Place fields into "Admin Interface" tab |
| 144 | $('.hide-modify-elements').appendTo('.fields-admin-interface > table > tbody'); |
| 145 | $('.hide-ab-wp-logo-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 146 | $('.hide-ab-customize-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 147 | $('.hide-ab-updates-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 148 | $('.hide-ab-comments-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 149 | $('.hide-ab-new-content-menu').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 150 | $('.hide-ab-howdy').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 151 | $('.hide-help-drawer').appendTo('.fields-admin-interface .hide-modify-elements .asenha-subfields'); |
| 152 | |
| 153 | $('.hide-admin-notices').appendTo('.fields-admin-interface > table > tbody'); |
| 154 | |
| 155 | $('.disable-dashboard-widgets').appendTo('.fields-admin-interface > table > tbody'); |
| 156 | $('.disable-welcome-panel-in-dashboard').appendTo('.fields-admin-interface .disable-dashboard-widgets .asenha-subfields'); |
| 157 | $('.disabled-dashboard-widgets').appendTo('.fields-admin-interface .disable-dashboard-widgets .asenha-subfields'); |
| 158 | $('.hide-admin-bar').appendTo('.fields-admin-interface > table > tbody'); |
| 159 | |
| 160 | $('.hide-admin-bar-for').appendTo('.fields-admin-interface .hide-admin-bar .asenha-subfields'); |
| 161 | |
| 162 | $('.wider-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 163 | $('.admin-menu-width').appendTo('.fields-admin-interface .wider-admin-menu .asenha-subfields'); |
| 164 | $('.customize-admin-menu').appendTo('.fields-admin-interface > table > tbody'); |
| 165 | $('.custom-menu-order').appendTo('.fields-admin-interface .customize-admin-menu .asenha-subfields'); |
| 166 | |
| 167 | $('.show-custom-taxonomy-filters').appendTo('.fields-admin-interface > table > tbody'); |
| 168 | |
| 169 | $('.enhance-list-tables').appendTo('.fields-admin-interface > table > tbody'); |
| 170 | $('.show-featured-image-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 171 | $('.show-excerpt-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 172 | $('.show-last-modified-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 173 | $('.show-id-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 174 | $('.show-file-size-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 175 | $('.show-id-in-action_row').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 176 | $('.hide-date-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 177 | $('.hide-comments-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 178 | $('.hide-post-tags-column').appendTo('.fields-admin-interface .enhance-list-tables .asenha-subfields'); |
| 179 | $('.various-admin-ui-enhancements').appendTo('.fields-admin-interface > table > tbody'); |
| 180 | $('.media-library-infinite-scrolling').appendTo('.fields-admin-interface .various-admin-ui-enhancements .asenha-subfields'); |
| 181 | $('.display-active-plugins-first').appendTo('.fields-admin-interface .various-admin-ui-enhancements .asenha-subfields'); |
| 182 | |
| 183 | $('.custom-admin-footer-text').appendTo('.fields-admin-interface > table > tbody'); |
| 184 | $('.custom-admin-footer-left').appendTo('.fields-admin-interface .custom-admin-footer-text .asenha-subfields'); |
| 185 | reinitWpEditor('admin_site_enhancements--custom_admin_footer_left'); |
| 186 | $('.custom-admin-footer-right').appendTo('.fields-admin-interface .custom-admin-footer-text .asenha-subfields'); |
| 187 | reinitWpEditor('admin_site_enhancements--custom_admin_footer_right'); |
| 188 | |
| 189 | // Place fields into "Log In | Log Out" tab |
| 190 | $('.change-login-url').appendTo('.fields-login-logout > table > tbody'); |
| 191 | $('.custom-login-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 192 | $('.default-login-redirect-slug').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 193 | $('.change-login-url-description').appendTo('.fields-login-logout .change-login-url .asenha-subfields'); |
| 194 | $('.login-id-type-restriction').appendTo('.fields-login-logout > table > tbody'); |
| 195 | $('.login-id-type').appendTo('.fields-login-logout .login-id-type-restriction .asenha-subfields'); |
| 196 | |
| 197 | $('.site-identity-on-login').appendTo('.fields-login-logout > table > tbody'); |
| 198 | $('.enable-login-logout-menu').appendTo('.fields-login-logout > table > tbody'); |
| 199 | $('.enable-last-login-column').appendTo('.fields-login-logout > table > tbody'); |
| 200 | $('.redirect-after-login').appendTo('.fields-login-logout > table > tbody'); |
| 201 | |
| 202 | $('.redirect-after-login-to-slug').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 203 | $('.redirect-after-login-for').appendTo('.fields-login-logout .redirect-after-login .asenha-subfields'); |
| 204 | |
| 205 | $('.redirect-after-logout').appendTo('.fields-login-logout > table > tbody'); |
| 206 | |
| 207 | $('.redirect-after-logout-to-slug').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 208 | $('.redirect-after-logout-for').appendTo('.fields-login-logout .redirect-after-logout .asenha-subfields'); |
| 209 | |
| 210 | |
| 211 | // Place fields into "Custom Code" tab |
| 212 | |
| 213 | $('.enable-custom-admin-css').appendTo('.fields-custom-code > table > tbody'); |
| 214 | $('.custom-admin-css').appendTo('.fields-custom-code .enable-custom-admin-css .asenha-subfields'); |
| 215 | $('.enable-custom-frontend-css').appendTo('.fields-custom-code > table > tbody'); |
| 216 | |
| 217 | $('.custom-frontend-css').appendTo('.fields-custom-code .enable-custom-frontend-css .asenha-subfields'); |
| 218 | $('.insert-head-body-footer-code').appendTo('.fields-custom-code > table > tbody'); |
| 219 | $('.head-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 220 | $('.head-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 221 | $('.body-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 222 | $('.body-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 223 | $('.footer-code-priority').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 224 | $('.footer-code').appendTo('.fields-custom-code .insert-head-body-footer-code .asenha-subfields'); |
| 225 | $('.enable-custom-body-class').appendTo('.fields-custom-code > table > tbody'); |
| 226 | $('.enable-custom-body-class-for').appendTo('.fields-custom-code .enable-custom-body-class .asenha-subfields'); |
| 227 | $('.manage-ads-appads-txt').appendTo('.fields-custom-code > table > tbody'); |
| 228 | $('.ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 229 | $('.app-ads-txt-content').appendTo('.fields-custom-code .manage-ads-appads-txt .asenha-subfields'); |
| 230 | $('.manage-robots-txt').appendTo('.fields-custom-code > table > tbody'); |
| 231 | $('.robots-txt-content').appendTo('.fields-custom-code .manage-robots-txt .asenha-subfields'); |
| 232 | |
| 233 | // Place fields into the "Disable Components" tab |
| 234 | $('.disable-gutenberg').appendTo('.fields-disable-components > table > tbody'); |
| 235 | |
| 236 | $('.disable-gutenberg-for').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 237 | $('.disable-gutenberg-frontend-styles').appendTo('.fields-disable-components .disable-gutenberg .asenha-subfields'); |
| 238 | $('.disable-comments').appendTo('.fields-disable-components > table > tbody'); |
| 239 | |
| 240 | $('.disable-comments-for').appendTo('.fields-disable-components .disable-comments .asenha-subfields'); |
| 241 | $('.disable-rest-api').appendTo('.fields-disable-components > table > tbody'); |
| 242 | |
| 243 | $('.disable-feeds').appendTo('.fields-disable-components > table > tbody'); |
| 244 | $('.disable-all-updates').appendTo('.fields-disable-components > table > tbody'); |
| 245 | $('.disable-smaller-components').appendTo('.fields-disable-components > table > tbody'); |
| 246 | $('.disable-head-generator-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 247 | $('.disable-feed-generator-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 248 | $('.disable-resource-version-number').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 249 | $('.disable-head-wlwmanifest-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 250 | $('.disable-head-rsd-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 251 | $('.disable-head-shortlink-tag').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 252 | $('.disable-frontend-dashicons').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 253 | $('.disable-emoji-support').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 254 | $('.disable-jquery-migrate').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 255 | $('.disable-block-widgets').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 256 | $('.disable-lazy-load').appendTo('.fields-disable-components .disable-smaller-components .asenha-subfields'); |
| 257 | |
| 258 | // Place fields into "Security" tab |
| 259 | $('.limit-login-attempts').appendTo('.fields-security > table > tbody'); |
| 260 | $('.login-fails-allowed').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 261 | $('.login-lockout-maxcount').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 262 | |
| 263 | $('.login-attempts-log-table').appendTo('.fields-security .limit-login-attempts .asenha-subfields'); |
| 264 | $('.obfuscate-author-slugs').appendTo('.fields-security > table > tbody'); |
| 265 | $('.obfuscate-email-address').appendTo('.fields-security > table > tbody'); |
| 266 | $('.obfuscate-email-address-description').appendTo('.fields-security .obfuscate-email-address .asenha-subfields'); |
| 267 | |
| 268 | $('.disable-xmlrpc').appendTo('.fields-security > table > tbody'); |
| 269 | |
| 270 | // Place fields into "Optimizations" tab |
| 271 | $('.image-upload-control').appendTo('.fields-optimizations > table > tbody'); |
| 272 | $('.image-max-width').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 273 | $('.image-max-height').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 274 | |
| 275 | $('.image-upload-control-description').appendTo('.fields-optimizations .image-upload-control .asenha-subfields'); |
| 276 | $('.enable-revisions-control').appendTo('.fields-optimizations > table > tbody'); |
| 277 | $('.revisions-max-number').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields'); |
| 278 | $('.enable-revisions-control-for').appendTo('.fields-optimizations .enable-revisions-control .asenha-subfields'); |
| 279 | $('.enable-heartbeat-control').appendTo('.fields-optimizations > table > tbody'); |
| 280 | $('.heartbeat-control-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 281 | $('.heartbeat-interval-for-admin-pages').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 282 | $('.heartbeat-control-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 283 | $('.heartbeat-interval-for-post-edit').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 284 | $('.heartbeat-control-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 285 | $('.heartbeat-interval-for-frontend').appendTo('.fields-optimizations .enable-heartbeat-control .asenha-subfields'); |
| 286 | |
| 287 | // Place fields into "Utilities" tab |
| 288 | $('.smtp-email-delivery').appendTo('.fields-utilities > table > tbody'); |
| 289 | $('.smtp-default-from-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 290 | $('.smtp-default-from-name').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 291 | $('.smtp-default-from-email').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 292 | $('.smtp-force-from').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 293 | |
| 294 | $('.smtp--description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 295 | $('.smtp-host').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 296 | $('.smtp-port').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 297 | $('.smtp-security').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 298 | $('.smtp-username').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 299 | $('.smtp-password').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 300 | $('.smtp-bypass-ssl-verification').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 301 | $('.smtp-debug').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 302 | |
| 303 | $('.smtp-send-test-email-description').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 304 | $('.smtp-send-test-email-to').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 305 | $('.smtp-send-test-email-result').appendTo('.fields-utilities .smtp-email-delivery .asenha-subfields'); |
| 306 | |
| 307 | $('.multiple-user-roles').appendTo('.fields-utilities > table > tbody'); |
| 308 | $('.image-sizes-panel').appendTo('.fields-utilities > table > tbody'); |
| 309 | $('.view-admin-as-role').appendTo('.fields-utilities > table > tbody'); |
| 310 | $('.view-admin-as-role-description').appendTo('.fields-utilities .view-admin-as-role .asenha-subfields'); |
| 311 | $('.enable-password-protection').appendTo('.fields-utilities > table > tbody'); |
| 312 | $('.password-protection-password').appendTo('.fields-utilities .enable-password-protection .asenha-subfields'); |
| 313 | |
| 314 | $('.maintenance-mode').appendTo('.fields-utilities > table > tbody'); |
| 315 | |
| 316 | $('.maintenance-page-type-custom').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 317 | |
| 318 | $('.maintenance-page-heading').appendTo('.maintenance-page-type-custom'); |
| 319 | $('.maintenance-page-description').appendTo('.maintenance-page-type-custom'); |
| 320 | |
| 321 | $('.maintenance-page-background').appendTo('.maintenance-page-type-custom'); |
| 322 | |
| 323 | $('.maintenance-mode-description').appendTo('.fields-utilities .maintenance-mode .asenha-subfields'); |
| 324 | $('.redirect-404-to-homepage').appendTo('.fields-utilities > table > tbody'); |
| 325 | |
| 326 | $('.display-system-summary').appendTo('.fields-utilities > table > tbody'); |
| 327 | $('.search-engine-visibility-status').appendTo('.fields-utilities > table > tbody'); |
| 328 | |
| 329 | |
| 330 | // Remove empty .form-table that originally holds the fields |
| 331 | const formTableCount = $('.form-table').length; |
| 332 | // $('.form-table')[formTableCount-1].remove(); |
| 333 | |
| 334 | // Enable Custom Admin CSS => Initialize CodeMirror |
| 335 | var adminCssTextarea = document.getElementById("admin_site_enhancements[custom_admin_css]"); |
| 336 | // if ( typeof CodeMirror != "undefined" ) { |
| 337 | // alert('CodeMirror is available'); |
| 338 | // } |
| 339 | var adminCssEditor = CodeMirror.fromTextArea(adminCssTextarea, { |
| 340 | mode: "css", |
| 341 | lineNumbers: true, |
| 342 | lineWrapping: true |
| 343 | }); |
| 344 | |
| 345 | adminCssEditor.setSize("100%",600); |
| 346 | |
| 347 | // Enable Custom Frontend CSS => Initialize CodeMirror |
| 348 | var frontendCssTextarea = document.getElementById("admin_site_enhancements[custom_frontend_css]"); |
| 349 | var frontendCssEditor = CodeMirror.fromTextArea(frontendCssTextarea, { |
| 350 | mode: "css", |
| 351 | lineNumbers: true, |
| 352 | lineWrapping: true |
| 353 | }); |
| 354 | |
| 355 | frontendCssEditor.setSize("100%",600); |
| 356 | |
| 357 | // Manage ads.txt and app-ads.txt=> Initialize CodeMirror |
| 358 | var adsTxtTextarea = document.getElementById("admin_site_enhancements[ads_txt_content]"); |
| 359 | var adsTxtEditor = CodeMirror.fromTextArea(adsTxtTextarea, { |
| 360 | mode: "markdown", |
| 361 | lineNumbers: true, |
| 362 | lineWrapping: true |
| 363 | }); |
| 364 | |
| 365 | adsTxtEditor.setSize("100%",300); |
| 366 | |
| 367 | var appAdsTxtTextarea = document.getElementById("admin_site_enhancements[app_ads_txt_content]"); |
| 368 | var appAdsTxtEditor = CodeMirror.fromTextArea(appAdsTxtTextarea, { |
| 369 | mode: "markdown", |
| 370 | lineNumbers: true, |
| 371 | lineWrapping: true |
| 372 | }); |
| 373 | |
| 374 | appAdsTxtEditor.setSize("100%",300); |
| 375 | |
| 376 | // Manage robots.txt => Initialize CodeMirror |
| 377 | var robotsTxtTextarea = document.getElementById("admin_site_enhancements[robots_txt_content]"); |
| 378 | var robotsTxtEditor = CodeMirror.fromTextArea(robotsTxtTextarea, { |
| 379 | mode: "markdown", |
| 380 | lineNumbers: true, |
| 381 | lineWrapping: true |
| 382 | }); |
| 383 | |
| 384 | robotsTxtEditor.setSize("100%",400); |
| 385 | |
| 386 | // Insert <head>, <body> and <footer> code => Initialize CodeMirror |
| 387 | var headCodeTextarea = document.getElementById("admin_site_enhancements[head_code]"); |
| 388 | var headCodeEditor = CodeMirror.fromTextArea(headCodeTextarea, { |
| 389 | mode: "htmlmixed", |
| 390 | lineNumbers: true, |
| 391 | lineWrapping: true |
| 392 | }); |
| 393 | headCodeEditor.setSize("100%",300); |
| 394 | |
| 395 | var bodyCodeTextarea = document.getElementById("admin_site_enhancements[body_code]"); |
| 396 | var bodyCodeEditor = CodeMirror.fromTextArea(bodyCodeTextarea, { |
| 397 | mode: "htmlmixed", |
| 398 | lineNumbers: true, |
| 399 | lineWrapping: true |
| 400 | }); |
| 401 | bodyCodeEditor.setSize("100%",300); |
| 402 | |
| 403 | var footerCodeTextarea = document.getElementById("admin_site_enhancements[footer_code]"); |
| 404 | var footerCodeEditor = CodeMirror.fromTextArea(footerCodeTextarea, { |
| 405 | mode: "htmlmixed", |
| 406 | lineNumbers: true, |
| 407 | lineWrapping: true |
| 408 | }); |
| 409 | footerCodeEditor.setSize("100%",300); |
| 410 | |
| 411 | |
| 412 | |
| 413 | // Show and hide corresponding fields on tab clicks |
| 414 | |
| 415 | $('#tab-content-management + label').click( function() { |
| 416 | $('.fields-content-management').show(); |
| 417 | $('.asenha-fields:not(.fields-content-management)').hide(); |
| 418 | window.location.hash = 'content-management'; |
| 419 | Cookies.set('asenha_tab', 'content-management', { expires: 1 }); // expires in 1 day |
| 420 | }); |
| 421 | |
| 422 | $('#tab-admin-interface + label').click( function() { |
| 423 | $('.fields-admin-interface').show(); |
| 424 | $('.asenha-fields:not(.fields-admin-interface)').hide(); |
| 425 | window.location.hash = 'admin-interface'; |
| 426 | Cookies.set('asenha_tab', 'admin-interface', { expires: 1 }); // expires in 1 day |
| 427 | }); |
| 428 | |
| 429 | $('#tab-login-logout + label').click( function() { |
| 430 | $('.fields-login-logout').show(); |
| 431 | $('.asenha-fields:not(.fields-login-logout)').hide(); |
| 432 | window.location.hash = 'login-logout'; |
| 433 | Cookies.set('asenha_tab', 'login-logout', { expires: 1 }); // expires in 1 day |
| 434 | |
| 435 | }); |
| 436 | |
| 437 | $('#tab-custom-code + label').click( function() { |
| 438 | $('.fields-custom-code').show(); |
| 439 | $('.asenha-fields:not(.fields-custom-code)').hide(); |
| 440 | window.location.hash = 'custom-code'; |
| 441 | Cookies.set('asenha_tab', 'custom-code', { expires: 1 }); // expires in 1 day |
| 442 | adminCssEditor.refresh(); // Custom Admin CSS >> CodeMirror |
| 443 | frontendCssEditor.refresh(); // Custom Fronend CSS >> CodeMirror |
| 444 | adsTxtEditor.refresh(); // Manage ads.txt >> CodeMirror |
| 445 | appAdsTxtEditor.refresh(); // Manage app-ads.txt >> CodeMirror |
| 446 | headCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 447 | bodyCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 448 | footerCodeEditor.refresh(); // Insert <head>, <body> and <footer> code >> CodeMirror |
| 449 | robotsTxtEditor.refresh(); // Manage robots.txt >> CodeMirror |
| 450 | }); |
| 451 | |
| 452 | $('#tab-disable-components + label').click( function() { |
| 453 | $('.fields-disable-components').show(); |
| 454 | $('.asenha-fields:not(.fields-disable-components)').hide(); |
| 455 | window.location.hash = 'disable-components'; |
| 456 | Cookies.set('asenha_tab', 'disable-components', { expires: 1 }); // expires in 1 day |
| 457 | }); |
| 458 | |
| 459 | $('#tab-security + label').click( function() { |
| 460 | $('.fields-security').show(); |
| 461 | $('.asenha-fields:not(.fields-security)').hide(); |
| 462 | window.location.hash = 'security'; |
| 463 | Cookies.set('asenha_tab', 'security', { expires: 1 }); // expires in 1 day |
| 464 | }); |
| 465 | |
| 466 | $('#tab-optimizations + label').click( function() { |
| 467 | $('.fields-optimizations').show(); |
| 468 | $('.asenha-fields:not(.fields-optimizations)').hide(); |
| 469 | window.location.hash = 'optimizations'; |
| 470 | Cookies.set('asenha_tab', 'optimizations', { expires: 1 }); // expires in 1 day |
| 471 | }); |
| 472 | |
| 473 | $('#tab-utilities + label').click( function() { |
| 474 | $('.fields-utilities').show(); |
| 475 | $('.asenha-fields:not(.fields-utilities)').hide(); |
| 476 | window.location.hash = 'utilities'; |
| 477 | Cookies.set('asenha_tab', 'utilities', { expires: 1 }); // expires in 1 day |
| 478 | |
| 479 | }); |
| 480 | |
| 481 | // Open tab set in 'asenha_tab' cookie set on saving changes. Defaults to content-management tab when cookie is empty |
| 482 | var asenhaTabHash = Cookies.get('asenha_tab'); |
| 483 | |
| 484 | if (typeof asenhaTabHash === 'undefined') { |
| 485 | $('#tab-content-management + label').trigger('click'); |
| 486 | } else { |
| 487 | $('#tab-' + asenhaTabHash + ' + label').trigger('click'); |
| 488 | } |
| 489 | |
| 490 | // Show or hide subfields on document ready and on toggle click |
| 491 | |
| 492 | function subfieldsToggler( fieldId, fieldClass, sortableId, codeMirrorInstances ) { |
| 493 | |
| 494 | if (document.getElementById('admin_site_enhancements['+fieldId+']')) { |
| 495 | |
| 496 | // Show/hide subfields on document ready, depending on if module is enabled or not |
| 497 | if ( document.getElementById('admin_site_enhancements['+fieldId+']').checked ) { |
| 498 | |
| 499 | $('.'+fieldClass+' .asenha-subfields').show(); |
| 500 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 501 | $('.'+fieldClass+' .asenha-subfield-select-inner').show(); |
| 502 | } |
| 503 | $('.asenha-toggle.'+fieldClass+' td .asenha-field-with-options').addClass('is-enabled'); |
| 504 | if ( codeMirrorInstances ) { |
| 505 | Object.keys(codeMirrorInstances).forEach(function(key) { |
| 506 | if ( codeMirrorInstances[key] ) { |
| 507 | codeMirrorInstances[key].refresh(); |
| 508 | } |
| 509 | }); |
| 510 | } |
| 511 | |
| 512 | } else { |
| 513 | |
| 514 | $('.'+fieldClass+' .asenha-subfields').hide(); |
| 515 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 516 | $('.'+fieldClass+' .asenha-subfield-select-inner').hide(); |
| 517 | } |
| 518 | |
| 519 | } |
| 520 | |
| 521 | // Show/hide subfields on toggle click |
| 522 | document.getElementById('admin_site_enhancements['+fieldId+']').addEventListener('click', event => { |
| 523 | if (event.target.checked) { |
| 524 | |
| 525 | $('.'+fieldClass+' .asenha-subfields').fadeIn(); |
| 526 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 527 | $('.'+fieldClass+' .asenha-subfield-select-inner').show(); |
| 528 | } |
| 529 | $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled'); |
| 530 | if (document.getElementById(sortableId)) { |
| 531 | // Initialize sortable elements: https://api.jqueryui.com/sortable/ |
| 532 | $('#' + sortableId ).sortable(); |
| 533 | } |
| 534 | if ( codeMirrorInstances ) { |
| 535 | Object.keys(codeMirrorInstances).forEach(function(key) { |
| 536 | if ( codeMirrorInstances[key] ) { |
| 537 | codeMirrorInstances[key].refresh(); |
| 538 | } |
| 539 | }); |
| 540 | } |
| 541 | |
| 542 | } else { |
| 543 | |
| 544 | $('.'+fieldClass+' .asenha-subfields').hide(); |
| 545 | if (document.querySelector('.'+fieldClass+' .asenha-subfield-select-inner')) { |
| 546 | $('.'+fieldClass+' .asenha-subfield-select-inner').hide(); |
| 547 | } |
| 548 | $('.'+fieldClass+' .asenha-field-with-options').toggleClass('is-enabled'); |
| 549 | |
| 550 | } |
| 551 | }); |
| 552 | |
| 553 | } |
| 554 | |
| 555 | } |
| 556 | |
| 557 | // Re-init wp_editor for snippet description. Required because the wp_editor was moved in the DOM after document ready. |
| 558 | // Ref: https://stackoverflow.com/a/21519323 |
| 559 | // Ref: https://core.trac.wordpress.org/ticket/19173 |
| 560 | function reinitWpEditor(id) { |
| 561 | tinymce.execCommand('mceRemoveEditor', true, id); |
| 562 | var init = tinymce.extend( {}, tinyMCEPreInit.mceInit[ id ] ); |
| 563 | try { tinymce.init( init ); } catch(e){} |
| 564 | $('textarea[id="' + id + '"]').closest('form').find('input[type="submit"]').click(function(){ |
| 565 | if( getUserSetting( 'editor' ) == 'tmce' ){ |
| 566 | var id = mce.find( 'textarea' ).attr( 'id' ); |
| 567 | tinymce.execCommand( 'mceRemoveEditor', false, id ); |
| 568 | tinymce.execCommand( 'mceAddEditor', false, id ); |
| 569 | } |
| 570 | return true; |
| 571 | }); |
| 572 | } |
| 573 | |
| 574 | |
| 575 | subfieldsToggler( 'enable_duplication', 'enable-duplication' ); |
| 576 | subfieldsToggler( 'content_order', 'content-order' ); |
| 577 | |
| 578 | subfieldsToggler( 'enable_svg_upload', 'enable-svg-upload' ); |
| 579 | subfieldsToggler( 'enable_avif_upload', 'enable-avif-upload' ); |
| 580 | subfieldsToggler( 'enable_external_permalinks', 'enable-external-permalinks' ); |
| 581 | |
| 582 | subfieldsToggler( 'enhance_list_tables', 'enhance-list-tables' ); |
| 583 | subfieldsToggler( 'custom_admin_footer_text', 'custom-admin-footer-text' ); |
| 584 | subfieldsToggler( 'wider_admin_menu', 'wider-admin-menu' ); |
| 585 | subfieldsToggler( 'customize_admin_menu', 'customize-admin-menu', 'custom-admin-menu' ); |
| 586 | subfieldsToggler( 'disable_dashboard_widgets', 'disable-dashboard-widgets' ); |
| 587 | subfieldsToggler( 'various_admin_ui_enhancements', 'various-admin-ui-enhancements' ); |
| 588 | |
| 589 | // Clean Up Admin Bar |
| 590 | subfieldsToggler( 'hide_modify_elements', 'hide-modify-elements' ); |
| 591 | |
| 592 | subfieldsToggler( 'hide_admin_bar', 'hide-admin-bar' ); |
| 593 | subfieldsToggler( 'change_login_url', 'change-login-url' ); |
| 594 | subfieldsToggler( 'login_id_type_restriction', 'login-id-type-restriction' ); |
| 595 | |
| 596 | subfieldsToggler( 'redirect_after_login', 'redirect-after-login' ); |
| 597 | subfieldsToggler( 'redirect_after_logout', 'redirect-after-logout' ); |
| 598 | subfieldsToggler( 'enable_custom_admin_css', 'enable-custom-admin-css', '', {adminCssEditor} ); |
| 599 | subfieldsToggler( 'enable_custom_frontend_css', 'enable-custom-frontend-css', '', {frontendCssEditor} ); |
| 600 | subfieldsToggler( 'insert_head_body_footer_code', 'insert-head-body-footer-code', '', {headCodeEditor,bodyCodeEditor,footerCodeEditor} ); |
| 601 | subfieldsToggler( 'enable_custom_body_class', 'enable-custom-body-class' ); |
| 602 | subfieldsToggler( 'manage_ads_appads_txt', 'manage-ads-appads-txt', '', {adsTxtEditor,appAdsTxtEditor} ); |
| 603 | subfieldsToggler( 'manage_robots_txt', 'manage-robots-txt', '', {robotsTxtEditor} ); |
| 604 | |
| 605 | subfieldsToggler( 'disable_gutenberg', 'disable-gutenberg' ); |
| 606 | subfieldsToggler( 'disable_comments', 'disable-comments' ); |
| 607 | |
| 608 | subfieldsToggler( 'disable_smaller_components', 'disable-smaller-components' ); |
| 609 | subfieldsToggler( 'limit_login_attempts', 'limit-login-attempts' ); |
| 610 | subfieldsToggler( 'obfuscate_email_address', 'obfuscate-email-address' ); |
| 611 | subfieldsToggler( 'image_upload_control', 'image-upload-control' ); |
| 612 | subfieldsToggler( 'enable_revisions_control', 'enable-revisions-control' ); |
| 613 | subfieldsToggler( 'enable_heartbeat_control', 'enable-heartbeat-control' ); |
| 614 | |
| 615 | |
| 616 | // Enable Heartbeat Control => Check if "Modify interval" is chosen/clicked and show/hide the corresponding select field |
| 617 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]:checked').val() == 'modify' ) { |
| 618 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 619 | } |
| 620 | |
| 621 | $('input[name="admin_site_enhancements[heartbeat_control_for_admin_pages]"]').click(function() { |
| 622 | var radioValue = $(this).attr('value'); |
| 623 | if ( radioValue == 'modify' ) { |
| 624 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').show(); |
| 625 | } else { |
| 626 | $('.heartbeat-interval-for-admin-pages .asenha-subfield-select-inner').hide(); |
| 627 | } |
| 628 | }); |
| 629 | |
| 630 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]:checked').val() == 'modify' ) { |
| 631 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 632 | } |
| 633 | |
| 634 | $('input[name="admin_site_enhancements[heartbeat_control_for_post_edit]"]').click(function() { |
| 635 | var radioValue = $(this).attr('value'); |
| 636 | if ( radioValue == 'modify' ) { |
| 637 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').show(); |
| 638 | } else { |
| 639 | $('.heartbeat-interval-for-post-edit .asenha-subfield-select-inner').hide(); |
| 640 | } |
| 641 | }); |
| 642 | |
| 643 | if ( $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]:checked').val() == 'modify' ) { |
| 644 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 645 | } |
| 646 | |
| 647 | $('input[name="admin_site_enhancements[heartbeat_control_for_frontend]"]').click(function() { |
| 648 | var radioValue = $(this).attr('value'); |
| 649 | if ( radioValue == 'modify' ) { |
| 650 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').show(); |
| 651 | } else { |
| 652 | $('.heartbeat-interval-for-frontend .asenha-subfield-select-inner').hide(); |
| 653 | } |
| 654 | }); |
| 655 | |
| 656 | subfieldsToggler( 'smtp_email_delivery', 'smtp-email-delivery' ); |
| 657 | |
| 658 | // SMTP Email Delivery => Empty field value on click, so new password can be easily entered |
| 659 | var oldSmtpPassValue = ''; |
| 660 | |
| 661 | $('input[name="admin_site_enhancements[smtp_password]"]').focusin(function() { |
| 662 | oldSmtpPassValue = $(this).val(); |
| 663 | $(this).val(''); |
| 664 | }); |
| 665 | |
| 666 | $('input[name="admin_site_enhancements[smtp_password]"]').focusout(function() { |
| 667 | if ( $(this).val() == '' ) { |
| 668 | $(this).val(oldSmtpPassValue); |
| 669 | } |
| 670 | }); |
| 671 | |
| 672 | subfieldsToggler( 'view_admin_as_role', 'view-admin-as-role' ); |
| 673 | subfieldsToggler( 'enable_password_protection', 'enable-password-protection' ); |
| 674 | |
| 675 | // Enable Password protection => Empty field value on click, so new password can be easily entered |
| 676 | var oldValue = ''; |
| 677 | $('input[name="admin_site_enhancements[password_protection_password]"]').focusin(function() { |
| 678 | oldValue = $(this).val(); |
| 679 | $(this).val(''); |
| 680 | }); |
| 681 | |
| 682 | $('input[name="admin_site_enhancements[password_protection_password]"]').focusout(function() { |
| 683 | if ( $(this).val() == '' ) { |
| 684 | $(this).val(oldValue); |
| 685 | } |
| 686 | }); |
| 687 | |
| 688 | |
| 689 | subfieldsToggler( 'maintenance_mode', 'maintenance-mode' ); |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | // Media frame handler for image selection / upload fields |
| 697 | // Reference: https://plugins.trac.wordpress.org/browser/bm-custom-login/trunk/bm-custom-login.php |
| 698 | function media_frame_init( selector, button_selector ) { |
| 699 | var theSelector = $(selector); |
| 700 | var button = $(button_selector); |
| 701 | |
| 702 | button.click(function (event) { |
| 703 | event.preventDefault(); |
| 704 | |
| 705 | // Configuration of the media frame new instance |
| 706 | wp.media.frames.frame = wp.media({ |
| 707 | title: adminPageVars.mediaFrameTitle, |
| 708 | multiple: false, |
| 709 | library: { |
| 710 | type: 'image' |
| 711 | }, |
| 712 | button: { |
| 713 | text: adminPageVars.mediaFrameButtonText |
| 714 | } |
| 715 | }); |
| 716 | |
| 717 | // Function used for the image selection and media manager closing |
| 718 | var media_set_image = function() { |
| 719 | var selection = wp.media.frames.frame.state().get('selection'); |
| 720 | |
| 721 | // Nothing is selected |
| 722 | if (!selection) { |
| 723 | return; |
| 724 | } |
| 725 | |
| 726 | // Iterate through selected elements |
| 727 | selection.each(function(attachment) { |
| 728 | // console.log(attachment); |
| 729 | var url = attachment.attributes.url; |
| 730 | url = url.replace( adminPageVars.wpcontentUrl, '' ); |
| 731 | theSelector.val(url); |
| 732 | }); |
| 733 | }; |
| 734 | |
| 735 | wp.media.frames.frame.on('close', media_set_image); |
| 736 | wp.media.frames.frame.on('select', media_set_image); |
| 737 | wp.media.frames.frame.open(); |
| 738 | }); |
| 739 | } |
| 740 | |
| 741 | // =============== ASE PRO ================= |
| 742 | |
| 743 | if ( asenhaStats.hideUpgradeNudge ) { |
| 744 | $('.asenha-upgrade-nudge').hide(); |
| 745 | $('#bottom-upgrade-nudge').show(); |
| 746 | } else { |
| 747 | $('.asenha-upgrade-nudge').show(); |
| 748 | $('#bottom-upgrade-nudge').hide(); |
| 749 | } |
| 750 | |
| 751 | $('#dismiss-upgrade-nudge').click(function(e) { |
| 752 | e.preventDefault(); |
| 753 | $.ajax({ |
| 754 | url: ajaxurl, |
| 755 | data: { |
| 756 | 'action':'dismiss_upgrade_nudge' |
| 757 | }, |
| 758 | success:function(data) { |
| 759 | $('.asenha-upgrade-nudge').hide(); |
| 760 | // $('#bottom-upgrade-nudge').show(); |
| 761 | }, |
| 762 | error:function(errorThrown) { |
| 763 | console.log(errorThrown); |
| 764 | } |
| 765 | }); |
| 766 | }); |
| 767 | |
| 768 | // =============== SPONSORSHIP ================= |
| 769 | |
| 770 | // Stats on saving changes from asenha_admin_scripts() wp_localize_script() is availble in the 'asenhaStats' object----- |
| 771 | // console.log( asenhaStats ); |
| 772 | // alert(JSON.stringify(asenhaStats)); |
| 773 | if ( asenhaStats.showSupportNudge ) { |
| 774 | $('.asenha-support-nudge').show(); |
| 775 | } else { |
| 776 | $('.asenha-support-nudge').hide(); |
| 777 | } |
| 778 | |
| 779 | $('#have-shared,#have-reviewed').click(function(e) { |
| 780 | e.preventDefault(); |
| 781 | $.ajax({ |
| 782 | url: 'https://bowo.io/asenha-sp-ndg', |
| 783 | method: 'GET', |
| 784 | dataType: 'jsonp', |
| 785 | crossDomain: true |
| 786 | }); |
| 787 | $.ajax({ |
| 788 | url: ajaxurl, |
| 789 | data: { |
| 790 | 'action':'have_supported' |
| 791 | }, |
| 792 | success:function(data) { |
| 793 | $('.asenha-support-nudge').hide(); |
| 794 | }, |
| 795 | error:function(errorThrown) { |
| 796 | console.log(errorThrown); |
| 797 | } |
| 798 | }); |
| 799 | }); |
| 800 | |
| 801 | $('#support-nudge-dismiss').click(function(e) { |
| 802 | e.preventDefault(); |
| 803 | $.ajax({ |
| 804 | url: 'https://bowo.io/asenha-sp-ndg', |
| 805 | method: 'GET', |
| 806 | dataType: 'jsonp', |
| 807 | crossDomain: true |
| 808 | }); |
| 809 | $.ajax({ |
| 810 | url: ajaxurl, |
| 811 | data: { |
| 812 | 'action':'dismiss_support_nudge' |
| 813 | }, |
| 814 | success:function(data) { |
| 815 | $('.asenha-support-nudge').hide(); |
| 816 | }, |
| 817 | error:function(errorThrown) { |
| 818 | console.log(errorThrown); |
| 819 | } |
| 820 | }); |
| 821 | }); |
| 822 | |
| 823 | // Expand support notice | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 824 | $('.asenha-support-nudge.nudge-show-more > .show-more').click(function(e) { |
| 825 | |
| 826 | e.preventDefault(); |
| 827 | |
| 828 | var $this = $(this); |
| 829 | $this.toggleClass('show-more'); |
| 830 | $this.hide(); |
| 831 | |
| 832 | if ($this.hasClass('show-more')) { |
| 833 | $this.next().removeClass('opened',0); |
| 834 | } else { |
| 835 | $this.next().addClass('opened',0); |
| 836 | } |
| 837 | |
| 838 | }); |
| 839 | |
| 840 | // Collapse support notice | Modified from https://codepen.io/symonsays/pen/rzgEgY |
| 841 | $('#support-nudge-show-less').click(function(e) { |
| 842 | |
| 843 | e.preventDefault(); |
| 844 | |
| 845 | $('.nudge-wrapper-show-more').removeClass('opened',0); |
| 846 | $('#support-nudge-show-moreless').addClass('show-more'); |
| 847 | $('#support-nudge-show-moreless').show(); |
| 848 | |
| 849 | }); |
| 850 | |
| 851 | |
| 852 | |
| 853 | // Modal for sponsoring plugin dev and maintenance: https://stephanwagner.me/jBox |
| 854 | |
| 855 | // var sponsorModal = new jBox('Modal', { |
| 856 | // attach: '#plugin-sponsor', |
| 857 | // trigger: 'click', // or 'mouseenter' |
| 858 | // // content: 'Test' |
| 859 | // content: $('#asenha-sponsor'), |
| 860 | // width: 740, // pixels |
| 861 | // closeButton: 'box', |
| 862 | // addClass: 'plugin-sponsor-modal', |
| 863 | // overlayClass: 'plugin-sponsor-modal-overlay', |
| 864 | // target: '#wpwrap', // where to anchor the modal |
| 865 | // position: { |
| 866 | // x: 'center', |
| 867 | // y: 'top' |
| 868 | // }, |
| 869 | // // fade: 1000, |
| 870 | // animation: { |
| 871 | // open: 'slide:top', |
| 872 | // close: 'slide:top' |
| 873 | // } |
| 874 | // }); |
| 875 | |
| 876 | // $('#plugin-sponsor').click( function() { |
| 877 | // $.ajax({ |
| 878 | // url: 'https://bowo.io/asenha-sp-btn', |
| 879 | // method: 'GET', |
| 880 | // dataType: 'jsonp', |
| 881 | // crossDomain: true |
| 882 | // // success: function(response) { |
| 883 | // // console.log(response); |
| 884 | // // } |
| 885 | // }); |
| 886 | // }); |
| 887 | |
| 888 | }); // END OF $(document).ready() |
| 889 | |
| 890 | })( jQuery ); |