0 ? round( ( $totals['up'] / $votes ) * 100 ) : 0;
$trend = Tracker::trend( 'view', 30 );
AdminUi::header( __( 'How your FAQs are performing.', 'accordion-faq-plugin' ) );
?>
stat( '👁️', __( 'Views (all time)', 'accordion-faq-plugin' ), number_format_i18n( $totals['view'] ) );
$this->stat( '👍', __( 'Helpful votes', 'accordion-faq-plugin' ), number_format_i18n( $totals['up'] ) );
$this->stat( '👎', __( 'Not helpful', 'accordion-faq-plugin' ), number_format_i18n( $totals['down'] ) );
$this->stat( '⭐', __( 'Helpfulness', 'accordion-faq-plugin' ), $helpful . '%' );
?>
rank( Tracker::top( Tracker::META_VIEWS, 8 ) ); ?>
rank( Tracker::top( Tracker::META_UP, 8 ) ); ?>
search_rank( Searches::top( 10, 30 ) ); ?>
search_rank( Searches::no_results( 10, 30 ), true ); ?>
' . esc_html__( 'No search data yet.', 'accordion-faq-plugin' ) . '';
return;
}
$max = max( array_map( function ( $r ) {
return $r['hits'];
}, $rows ) );
echo '';
foreach ( $rows as $row ) {
$pct = $max > 0 ? round( ( $row['hits'] / $max ) * 100 ) : 0;
$badge = $gaps
? '' . esc_html__( '0 results', 'accordion-faq-plugin' ) . ''
: '';
printf(
'- %1$s %2$s%3$s
',
esc_html( $row['term'] ),
$badge, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static, pre-escaped markup above.
esc_html( number_format_i18n( $row['hits'] ) ),
(int) $pct
);
}
echo '
';
}
/**
* Stat tile.
*
* @param string $icon Icon.
* @param string $label Label.
* @param string $value Value.
* @return void
*/
private function stat( $icon, $label, $value ) {
echo '' . esc_html( $icon ) . '' . esc_html( $label ) . '' . esc_html( $value ) . '
';
}
/**
* Render an inline SVG bar chart.
*
* @param array $series day => hits.
* @return void
*/
private function bar_chart( $series ) {
$values = array_values( $series );
$max = max( 1, max( $values ) );
$count = max( 1, count( $values ) );
$w = 1000;
$h = 180;
$gap = 3;
$bw = ( $w - ( $count - 1 ) * $gap ) / $count;
echo '';
}
/**
* Ranked list.
*
* @param array $rows Rows.
* @return void
*/
private function rank( $rows ) {
if ( empty( $rows ) ) {
echo '' . esc_html__( 'No data yet.', 'accordion-faq-plugin' ) . '
';
return;
}
$max = max( array_map( function ( $r ) {
return $r['value'];
}, $rows ) );
echo '';
foreach ( $rows as $row ) {
$pct = $max > 0 ? round( ( $row['value'] / $max ) * 100 ) : 0;
printf(
'- %2$s%3$s
',
esc_url( (string) get_edit_post_link( $row['id'] ) ),
esc_html( $row['title'] ),
esc_html( number_format_i18n( $row['value'] ) ),
(int) $pct
);
}
echo '
';
}
}