get_status(); // pagination script wp_enqueue_script( 'cookie-notice-admin-pagination', COOKIE_NOTICE_URL . '/assets/pagination/pagination.min.js', [ 'jquery' ], $cn->defaults['version'] ); wp_enqueue_style( 'cookie-notice-admin-pagination', COOKIE_NOTICE_URL . '/assets/pagination/pagination.css', [], $cn->defaults['version'] ); } /** * Get consent by date via AJAX request. * * @return void */ public function get_consent_logs_by_date() { // valid nonce? if ( ! check_ajax_referer( 'cn-get-consent-logs', 'nonce' ) ) wp_send_json_error(); // check data if ( ! isset( $_POST['action'], $_POST['date'], $_POST['nonce'] ) ) wp_send_json_error(); // check capability if ( ! current_user_can( apply_filters( 'cn_manage_cookie_notice_cap', 'manage_options' ) ) ) wp_send_json_error(); // sanitize date $date = preg_replace( '[^\d-]', '', $_POST['date'] ); // get datetime $dt = DateTime::createFromFormat( 'Y-m-d', $date ); // valid date? if ( $dt && $dt->format( 'Y-m-d' ) === $date ) { $data = Cookie_Notice()->welcome_api->get_consent_logs_by_date( $date ); if ( is_array( $data ) ) wp_send_json_success( $this->get_consent_logs_table( $data ) ); else wp_send_json_error( $data ); } wp_send_json_error(); } /** * Get single row template. * * @return string */ public function get_consent_logs_table( $data ) { $html = '
| ' . esc_html__( 'Consent ID', 'cookie-notice' ) . ' | ' . esc_html__( 'Consent Level', 'cookie-notice' ) . ' | ' . esc_html__( 'Categories', 'cookie-notice' ) . ' | ' . esc_html__( 'Duration', 'cookie-notice' ) . ' | ' . esc_html__( 'Time', 'cookie-notice' ) . ' | ' . esc_html__( 'IP address', 'cookie-notice' ) . ' |
|---|---|---|---|---|---|
| ' . esc_html__( 'No consent logs found.', 'cookie-notice' ) . ' | |||||
| ' . esc_html( $consent_log->ev_eventdetails_consentid ) . ' | ' . sprintf( esc_html__( 'Level %d', 'cookie-notice' ), $consent_log->ev_consentlevel ) . ' | ' . implode( ', ', $categories ) . ' | ' . esc_html( $duration ) . ' | ' . esc_html( $timestamp->format( get_option( 'time_format' ) ) ) . ' | ' . esc_html( implode( '.', $ip_chunks ) ) . ' |
' . esc_html__( 'We were unable to download consent logs due to an error. Please try again later.', 'cookie-notice' ) . '
'; } }