run_event 를 직접 추가도 가능한가요 ?
본문
제가 방법을 몰라서 그런지 모르겠지만.
특정 파일에 run_event('이름');
add_event로 호출 했는데 백지가 되어버리더라구요
혹시 훅을 세팅해두는 파일이 있나요 (훅 이름 같은거)
찾아봐도 안보여서요..ㅠ.ㅠ
답변 2
다음 코드가 도움이 될지 모르겠습니다.
<?php
include 'common.php';
function hook_fn_0() {
print('<fieldset>');
print('<legend>' . __FUNCTION__ . '</legend>');
print('</fieldset>');
}
function hook_fn_2($arg1, $arg2) {
print('<fieldset>');
print('<legend>' . __FUNCTION__ . '</legend>');
print('<pre>');
print_r(func_get_args());
print('</pre>');
print('</fieldset>');
}
add_event('foo_0', 'hook_fn_0', G5_HOOK_DEFAULT_PRIORITY, 0);
add_event('foo_2', 'hook_fn_2', G5_HOOK_DEFAULT_PRIORITY, 2);
run_event('foo_0');
run_event('foo_2', 1, 'a');
?>
HOOK 을 세팅해 두는 파일은 없는 것으로 알고 있습니다.
백지로 나온다면 PHP 에러 가능성이 높으니
에러 내용부터 확인해 보는 것이 좋습니다. (에러 출력 X 설정인 경우)
ini_set('display_errors', 1);
error_reporting(E_ALL);
다음으로 참고해 볼 수 있는 사항은,
add_event() 가 먼저 수행되고,
run_event() 가 나중에 수행되어야 한다는 점입니다.
답변을 작성하시기 전에 로그인 해주세요.