2019-03-07, 09:26:06
@vish93
If you are going to do it with your own plugin (which would indeed be better than in the theme folder),
GS provides some functions for handling AJAX together with auth (
I do AJAX saving in my plugin Components Extended (see my signature below), you can look at the code for inspiration, see this excerpt for example:
If you are going to do it with your own plugin (which would indeed be better than in the theme folder),
GS provides some functions for handling AJAX together with auth (
requestIsAjax
, get_cookie
, and check_nonce
)I do AJAX saving in my plugin Components Extended (see my signature below), you can look at the code for inspiration, see this excerpt for example:
PHP Code:
$global $USR;
if (requestIsAjax()) {
// protect against CSRF, basic check
if (!isset($USR) || $USR != get_cookie('GS_ADMIN_USERNAME'))
die();
// only continue if the request comes from the same domain & nonces match
if (empty($_GET['nonce']) || !check_nonce($_GET['nonce'], 'components_ext_action', 'components_ext.php'))
die();
}