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