self::SLUG ), admin_url( 'admin.php' ) ); } public function render(): void { if ( ! current_user_can( 'manage_woocommerce' ) ) { return; } echo '
'; ConnectPage::render_header(); $table = null; if ( Options::is_connected() ) { // WP_List_Table is not autoloaded by WordPress; EnrichedTable is only ever loaded from here. require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; $table = new EnrichedTable( self::$hook_suffix ); $table->prepare_items(); } self::render_title( null === $table ? null : $table->total() ); if ( null === $table ) { printf( '

%1$s %3$s

', esc_html__( 'Connect your store to see the products CortexCommerce has enriched.', 'cortexcommerce' ), esc_url( ConnectPage::url() ), esc_html__( 'Go to the CortexCommerce screen', 'cortexcommerce' ) ); echo '
'; return; } if ( $table->unavailable() ) { printf( '

%s

', esc_html__( 'The list can\'t be shown right now. Try again in a minute.', 'cortexcommerce' ) ); } else { echo '
'; printf( '', esc_attr( self::SLUG ) ); $table->display(); echo '
'; } echo ''; } /** * @param int|null $total How many products match, when the list is available. */ private static function render_title( ?int $total ): void { echo '

' . esc_html__( 'Enriched products', 'cortexcommerce' ); if ( null !== $total ) { /* translators: %s: number of products. */ echo ' ' . esc_html( sprintf( _n( '%s product', '%s products', $total, 'cortexcommerce' ), number_format_i18n( $total ) ) ) . ''; } echo '

'; } }