mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 04:58:28 +08:00
Merge pull request #773 from woocommerce/pcp-515-tabs
Render sections as tabs instead of links
This commit is contained in:
commit
8f16fb92aa
2 changed files with 13 additions and 14 deletions
|
@ -56,14 +56,12 @@ class SectionsRenderer {
|
|||
/**
|
||||
* Renders the Sections tab.
|
||||
*/
|
||||
public function render(): void {
|
||||
public function render(): string {
|
||||
if ( ! $this->should_render() ) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
echo '<ul class="subsubsub">';
|
||||
|
||||
$array_keys = array_keys( $this->sections );
|
||||
$html = '<nav class="nav-tab-wrapper woo-nav-tab-wrapper">';
|
||||
|
||||
foreach ( $this->sections as $id => $label ) {
|
||||
$url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $id );
|
||||
|
@ -73,9 +71,11 @@ class SectionsRenderer {
|
|||
// Other gateways render fields differently, and their pages are not expected to work when gateway is not available.
|
||||
$url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&' . self::KEY . '=' . $id );
|
||||
}
|
||||
echo '<li><a href="' . esc_url( $url ) . '" class="' . ( $this->page_id === $id ? 'current' : '' ) . '">' . esc_html( $label ) . '</a> ' . ( end( $array_keys ) === $id ? '' : '|' ) . ' </li>';
|
||||
$html .= '<a href="' . esc_url( $url ) . '" class="nav-tab ' . ( $this->page_id === $id ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a> ';
|
||||
}
|
||||
|
||||
echo '</ul><br class="clear" />';
|
||||
$html .= '</nav>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,13 +66,12 @@ class WCGatewayModule implements ModuleInterface {
|
|||
'woocommerce_sections_checkout',
|
||||
function() use ( $c ) {
|
||||
$section_renderer = $c->get( 'wcgateway.settings.sections-renderer' );
|
||||
/**
|
||||
* The Section Renderer.
|
||||
*
|
||||
* @var SectionsRenderer $section_renderer
|
||||
*/
|
||||
$section_renderer->render();
|
||||
}
|
||||
assert( $section_renderer instanceof SectionsRenderer );
|
||||
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput
|
||||
echo $section_renderer->render();
|
||||
},
|
||||
20
|
||||
);
|
||||
|
||||
add_action(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue