repository = $repository; $this->formatter = $formatter; } /** * Registers the widget on the Dashboard. * * @return void */ public function register(): void { if ( ! current_user_can( ReportPage::capability() ) ) { return; } wp_add_dashboard_widget( self::WIDGET_ID, __( 'Block Visibility', 'blocksieve' ), array( $this, 'render' ) ); } /** * Renders the widget body. * * @return void */ public function render(): void { $report = $this->repository->get(); $report_url = add_query_arg( 'page', ReportPage::SLUG, admin_url( 'tools.php' ) ); $total = $report->total_blocks(); $warnings = $report->total_warnings(); echo '
'; return; } $locations = $report->total_locations(); // Two counts, two plural forms: "1 block across 3 locations" and // "4 blocks across 1 location" must both read correctly. $blocks_text = sprintf( /* translators: %s: number of blocks. */ _n( '%s controlled block', '%s controlled blocks', $total, 'blocksieve' ), number_format_i18n( $total ) ); $locations_text = sprintf( /* translators: %s: number of locations (posts, templates, widgets). */ _n( '%s location', '%s locations', $locations, 'blocksieve' ), number_format_i18n( $locations ) ); printf( '', esc_html( sprintf( /* translators: 1: block count phrase, e.g. 3 controlled blocks; 2: location count phrase, e.g. 2 locations. */ __( '%1$s across %2$s.', 'blocksieve' ), $blocks_text, $locations_text ) ) ); $this->render_top_types( $report->counts_by_condition_type() ); if ( $warnings > 0 ) { printf( '', esc_url( add_query_arg( 'view', 'warnings', $report_url ) ), esc_html( sprintf( /* translators: %s: number of blocks needing attention. */ _n( '%s block needs attention', '%s blocks need attention', $warnings, 'blocksieve' ), number_format_i18n( $warnings ) ) ) ); } printf( '', esc_url( $report_url ), esc_html__( 'View full report', 'blocksieve' ) ); echo ''; } /** * Renders the most-used condition types. * * @param array