EPHEMERUM:
Vytvor si functions.js (napr. v
mytheme/js/), vloz do toho svuj jQuery code nejlepe obaleny v SIAF.
jQuery.noConflict();
var Module = (function( $,w )
{
$('form.sign-up').on('submit',function(e)
{
// Highjack the submit button, we will do it ourselves
e.preventDefault();
// uncomment next line & check console to see if button works
// console.log('submittonked!');
// store all the form data in a variable
var formData = $(this).serialize();
// Let's make the call!
// Replace the path to your own endpoint!
$.getJSON('http://localhost:8888/cool-cats-optin/mc-end-point.php', formData ,function(data)
{
// uncomment next line to see your data output in console
// console.log(data);
// If it worked...
if(data.status === 'subscribed')
{
// Let us know!
alert('Thanks!');
} else
{
// Otherwise tell us why it didn't
alert("oops error: " + data.detail);
}
});
});
})( jQuery, window, undefined );
Pak ve svem child theme pridej do functions.php nasledujici snippet.
add_action( 'wp_enqueue_scripts', 'register_my_scripts' );
function register_acp_scripts()
{
$dir = get_stylesheet_directory_uri();
wp_register_script( 'acp-functions', $dir . '/js/functions.min.js', array('jquery'), false, true );
wp_enqueue_script( 'acp-functions' );
}