'h2',
'service_heading' => 'h3',
),
$atts
);
$allowed_tags = array( 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'span' );
// Let's make sure the heading tags are valid.
$atts['category_heading'] = in_array( $atts['category_heading'], $allowed_tags, true ) ? $atts['category_heading'] : 'h2';
$atts['service_heading'] = in_array( $atts['service_heading'], $allowed_tags, true ) ? $atts['service_heading'] : 'h3';
$categories = wpconsent()->cookies->get_categories();
$output = '
';
// Get translatable table headers from settings (same as preferences panel).
// Fall back to default strings if the option is empty.
$header_name = wpconsent()->settings->get_option( 'cookie_table_header_name', wpconsent()->strings->get_string( 'cookie_table_header_name' ) );
$header_name = ! empty( $header_name ) ? $header_name : wpconsent()->strings->get_string( 'cookie_table_header_name' );
$header_description = wpconsent()->settings->get_option( 'cookie_table_header_description', wpconsent()->strings->get_string( 'cookie_table_header_description' ) );
$header_description = ! empty( $header_description ) ? $header_description : wpconsent()->strings->get_string( 'cookie_table_header_description' );
$header_duration = wpconsent()->settings->get_option( 'cookie_table_header_duration', wpconsent()->strings->get_string( 'cookie_table_header_duration' ) );
$header_duration = ! empty( $header_duration ) ? $header_duration : wpconsent()->strings->get_string( 'cookie_table_header_duration' );
foreach ( $categories as $category ) {
$cookies = wpconsent()->cookies->get_cookies_by_category( $category['id'] );
if ( empty( $cookies ) ) {
continue;
}
$output .= '<' . esc_attr( $atts['category_heading'] ) . ' class="wpconsent-cookie-category-name">' . esc_html( $category['name'] ) . '' . esc_attr( $atts['category_heading'] ) . '>';
$output .= '
' . esc_html( $category['description'] ) . '
';
$category_table = '
';
$category_table .= '| ' . esc_html( $header_name ) . ' | ' . esc_html( $header_description ) . ' | ' . esc_html( $header_duration ) . ' |
';
$has_cookies = false;
foreach ( $cookies as $cookie ) {
if ( ! in_array( $category['id'], $cookie['categories'], true ) ) {
continue;
}
$has_cookies = true;
$category_table .= '| ' . esc_html( $cookie['cookie_id'] ) . ' | ' . esc_html( $cookie['description'] ) . ' | ' . esc_html( $cookie['duration'] ) . ' |
';
}
$category_table .= '
';
if ( $has_cookies ) {
$output .= $category_table;
}
$services = wpconsent()->cookies->get_services_by_category( $category['id'] );
foreach ( $services as $service ) {
$output .= '<' . esc_attr( $atts['service_heading'] ) . ' class="wpconsent-cookie-service-name">' . esc_html( $service['name'] ) . '' . esc_attr( $atts['service_heading'] ) . '>';
$output .= '
' . esc_html( $service['description'] ) . '
';
if ( ! empty( $service['service_url'] ) ) {
$output .= '
' . esc_html__( 'Learn more', 'wpconsent-cookies-banner-privacy-suite' ) . '';
}
$cookies = wpconsent()->cookies->get_cookies_by_service( $service['id'] );
$output .= '
';
$output .= '| ' . esc_html( $header_name ) . ' | ' . esc_html( $header_description ) . ' | ' . esc_html( $header_duration ) . ' |
';
foreach ( $cookies as $cookie ) {
$output .= '| ' . esc_html( $cookie['cookie_id'] ) . ' | ' . esc_html( $cookie['description'] ) . ' | ' . esc_html( $cookie['duration'] ) . ' |
';
}
$output .= '
';
}
}
$output .= '
';
return $output;
}