이전에 작성한 글 중에 글 발행일을 마지막 수정일 포함해서 반환하게 수정했었다
그 이후 며칠 아무 이상 없이 사이트가 잘 작동하는 줄 알았다
하지만 언제 부턴가 관리자 Dashboard 페이지가 일부만 표시되고 나머지 위젯들이 표시가 되지 않았다
그래서 확인도 할 겸 위 링크를 참조해서 로그를 남겨보니 다음과 같은 로그가 남는다.
[29-Aug-2022 12:00:10 UTC] PHP Fatal error: Uncaught TypeError: gmdate(): Argument #2 ($timestamp) must be of type ?int, string given in wp-admin/includes/dashboard.php:1001
Stack trace:
#0 wp-admin/includes/dashboard.php(1001): gmdate('Y-m-d', 'Last updated Au...')
#1 wp-admin/includes/dashboard.php(930): wp_dashboard_recent_posts(Array)
#2 wp-admin/includes/template.php(1401): wp_dashboard_site_activity('', Array)
#3 wp-admin/includes/dashboard.php(265): do_meta_boxes(Object(WP_Screen), 'normal', '')
#4 wp-admin/index.php(203): wp_dashboard()
#5 {main}
thrown in wp-admin/includes/dashboard.php on line 1001
dashboard.php 1001 번째 코드를 보면 999 번째 라인에서 get_the_time(‘U’) 으로 할당된 $time 변수 때문에 오류가 발생하면서 Dashboard 페이지만 문제가 되었던 것 가다.
이전 포스팅에서 get_the_time 을 일반 텍스트 조합으로 반환되게 수정해서 문제가 되었다 ㅡㅡ;;
그래서 이전 포스팅을 다시 확인해서 관리자가 페이지 제외 조건을 추가해서 해결했다.
$today = current_time( 'Y-m-d' );
$tomorrow = current_datetime()->modify( '+1 day' )->format( 'Y-m-d' );
$year = current_time( 'Y' );
while ( $posts->have_posts() ) {
$posts->the_post();
$time = get_the_time( 'U' );
if ( gmdate( 'Y-m-d', $time ) === $today ) {
$relative = __( 'Today' );
} elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) {
$relative = __( 'Tomorrow' );
} elseif ( gmdate( 'Y', $time ) !== $year ) {
/* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
$relative = date_i18n( __( 'M jS Y' ), $time );
} else {
/* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */
$relative = date_i18n( __( 'M jS' ), $time );
}
The post WordPress Debug 활용 appeared first on kkomzi.