store = $store; } /** * Registers hooks. */ public function register(): void { add_filter( 'manage_plugins_columns', array( $this, 'add_column' ) ); add_action( 'manage_plugins_custom_column', array( $this, 'render' ), 10, 2 ); } /** * Adds the column. * * @param array $columns Columns. * @return array */ public function add_column( $columns ) { if ( ! current_user_can( 'activate_plugins' ) || null === $this->store->get_results() ) { return $columns; } $columns[ self::COLUMN ] = esc_html__( 'Brachmelder', 'brachmelder' ); return $columns; } /** * Renders a cell. * * @param string $column_name Column. * @param string $plugin_file Plugin basename. */ public function render( $column_name, $plugin_file ): void { if ( self::COLUMN !== $column_name ) { return; } $result = $this->store->get_plugin_result( (string) $plugin_file ); if ( null === $result ) { $result = array( 'status' => 'pending' ); } $url = add_query_arg( 'page', Page::SLUG, admin_url( 'tools.php' ) ) . '#' . Page::anchor( (string) $plugin_file ); printf( '', esc_url( $url ) ); Badge::render( $result ); echo ''; } }