-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from linchpin/release/v1.3.0
Release/v1.3.0
- Loading branch information
Showing
53 changed files
with
4,878 additions
and
419 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
# Frequently Asked Questions # | ||
|
||
## Does this plugin work with Full Page Caching or WordPress Object Caching? ## | ||
|
||
Yes, just be sure to enable the option to load Courier Notices using AJAX | ||
|
||
## I'm looking for a specific type of notice that courier doesn't have, what's next? ## | ||
|
||
The great thing is that Courier Notices is highly extendable and our team is adding new features constantly since release. You can always create a pull request in GitHub or add an issue. You can also take a look at the Pro version which also has some great features. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import jQuery from 'jquery'; | ||
|
||
let $ = jQuery; | ||
|
||
export default function settings() { | ||
|
||
// Extend Serialize Array to also include checkboxes that are not selected | ||
(function ($) { | ||
let _base_serializeArray = $.fn.serializeArray; | ||
|
||
/** | ||
* extract the field name based on key | ||
* | ||
* @param fieldName | ||
* @return {*} | ||
*/ | ||
function cleanupFieldName( fieldName ) { | ||
|
||
let matches = fieldName.match(/\[([a-zA-Z_]*)\]/); | ||
|
||
if ( matches ) { | ||
return matches[1]; | ||
} | ||
|
||
return fieldName; | ||
} | ||
|
||
$.fn.serializeArray = function () { | ||
|
||
let originalArray = _base_serializeArray.apply(this); | ||
let dataCleanup = {}; | ||
|
||
$.each( this.find("input"), function (i, element) { | ||
|
||
if ( "checkbox" === element.type || "radio" === element.type ) { | ||
element.checked | ||
? originalArray[i].value = true | ||
: originalArray.splice( i, 0, { name: element.name, value: false }) | ||
} | ||
|
||
let fieldName = cleanupFieldName( element.name ); | ||
|
||
if ( dataCleanup[ fieldName ] !== undefined ) { // The field exists, if it's not an array create one | ||
if ( ! Array.isArray( dataCleanup[ fieldName ] ) ) { | ||
if ( false !== dataCleanup[ fieldName ] ) { | ||
dataCleanup[ fieldName ] = [ dataCleanup[ fieldName ] ]; | ||
} else { | ||
dataCleanup[ fieldName ] = []; | ||
} | ||
} | ||
|
||
if ( false !== element.value && element.checked ) { | ||
dataCleanup[ fieldName ].push( element.value ); | ||
} | ||
} else { | ||
|
||
if ( "checkbox" === element.type || "radio" === element.type ) { | ||
if ( element.checked ) { | ||
if ( false !== element.value ) { | ||
dataCleanup[ fieldName ] = element.value; | ||
} else { | ||
dataCleanup[ fieldName ] = false; | ||
} | ||
} else { | ||
dataCleanup[ fieldName ] = false; | ||
} | ||
} else { | ||
dataCleanup[ fieldName ] = element.value; | ||
} | ||
} | ||
}); | ||
|
||
for( const field in dataCleanup ) { | ||
if ( typeof dataCleanup[field] !== 'object' ) { | ||
continue; | ||
} | ||
|
||
if ( 0 === dataCleanup[field].length ) { | ||
dataCleanup[field] = false; | ||
} | ||
} | ||
|
||
return dataCleanup; | ||
}; | ||
})(jQuery); | ||
|
||
setup_forms(); | ||
|
||
/** | ||
* Convert our form data to a json object | ||
* | ||
* @param form | ||
* @return {{}} | ||
*/ | ||
function formDataToJSON( form ) { | ||
let formData = $(form).serializeArray(); | ||
|
||
return formData; | ||
} | ||
|
||
/** | ||
* Initialize our dismiss | ||
* Add our events | ||
* | ||
* @since 1.0 | ||
*/ | ||
function setup_forms() { | ||
|
||
let $settings_form = $( '.courier-notices-settings-form' ); | ||
|
||
$settings_form.find( '#submit' ).on('click', function(event ) { | ||
event.preventDefault(); | ||
|
||
$(this).attr({ | ||
'disabled':'disabled', | ||
'value' : 'Saving', | ||
}) | ||
.parents('form').submit(); | ||
}); | ||
|
||
$settings_form.on( 'submit', function(event) { | ||
event.preventDefault(); | ||
event.stopImmediatePropagation(); | ||
|
||
let $form = $(this); | ||
let formData = formDataToJSON(this); | ||
formData['settings_key'] = formData['option_page']; | ||
formData['method'] = 'POST'; | ||
formData._wpnonce = courier_notices_admin_data.settings_nonce; | ||
$.ajax( { | ||
'url' : courier_notices_admin_data.settings_endpoint, | ||
'beforeSend' : function ( xhr ) { | ||
xhr.setRequestHeader( 'X-WP-Nonce', formData._wpnonce ); | ||
}, | ||
'method' : 'POST', | ||
'data' : formData, | ||
} ).done(function ( response ) { | ||
$settings_form.find( '#submit' ).attr({ | ||
'value' : 'Save Changes', | ||
}).removeAttr('disabled'); | ||
}); | ||
} ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.