mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +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.
|
* Renders the Sections tab.
|
||||||
*/
|
*/
|
||||||
public function render(): void {
|
public function render(): string {
|
||||||
if ( ! $this->should_render() ) {
|
if ( ! $this->should_render() ) {
|
||||||
return;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<ul class="subsubsub">';
|
$html = '<nav class="nav-tab-wrapper woo-nav-tab-wrapper">';
|
||||||
|
|
||||||
$array_keys = array_keys( $this->sections );
|
|
||||||
|
|
||||||
foreach ( $this->sections as $id => $label ) {
|
foreach ( $this->sections as $id => $label ) {
|
||||||
$url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . $id );
|
$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.
|
// 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 );
|
$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',
|
'woocommerce_sections_checkout',
|
||||||
function() use ( $c ) {
|
function() use ( $c ) {
|
||||||
$section_renderer = $c->get( 'wcgateway.settings.sections-renderer' );
|
$section_renderer = $c->get( 'wcgateway.settings.sections-renderer' );
|
||||||
/**
|
assert( $section_renderer instanceof SectionsRenderer );
|
||||||
* The Section Renderer.
|
|
||||||
*
|
// phpcs:ignore WordPress.Security.EscapeOutput
|
||||||
* @var SectionsRenderer $section_renderer
|
echo $section_renderer->render();
|
||||||
*/
|
},
|
||||||
$section_renderer->render();
|
20
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
add_action(
|
add_action(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue