1. Go to this page and download the library: Download bojaghi/admin-ajax library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bojaghi / admin-ajax example snippets
$ajax = new \Bojaghi\AdminAjax\AdminAjax([ /* config */ ], $container);
// 또는
$ajax = new \Bojaghi\AdminAjax\AdminAjax('/path/to/config/file.php', $container);
if (!defined('ABSPATH')) {
exit;
}
return [
'checkContentType' => false, // 기본값: true
// 여기부터 요청하는 액션 설정
[
// 가장 간단한 형태는 문자열 - 이 경우 콜백 함수 'my_action_1'이 있어야 제대로 동작.
'my_action_1',
// 콜백을 명시.
['my_action_2', 'myClass@callback2'],
// 로그인하지 않은 사람도 호출할 수 있게 허용.
['my_action_3', 'myClass@callback3', SubmitBase::ALL_GRANTED],
// 로그인하지 않은 사람만 호출 가능.`
// 자동 NONCE 체크를 진행.
// 요청에 '_my_nonce'를 이름으로 한 NONCE 값을 전달한다.
// wp_create_nonce() 의 입력으로 액션인 'my_action_4'를 입력한다.
['my_action_4', 'myClass@callback4', SubmitBase::ONLY_NOPRIV, '_my_nonce'],
// 로그인한 사용자만 호출 가능.
// 자동 NONCE 체크를 하지 않는다.
// add_action() 우선순위를 20으로 설정한다.
['my_action_5', 'myClass@callback5', SubmitBase::ONLY_PRIV, '', 20],
],
];
wp_nonce_field('my_action_4', '_my_nonce');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.