Add output methods for search promotion banners
This commit is contained in:
parent
58c26ff11f
commit
0e592e3349
|
@ -523,6 +523,37 @@ class WC_Admin_Addons {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the HTML for the promotion block
|
||||||
|
*
|
||||||
|
* @param array $promotion Array of promotion block data.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function output_search_promotion_block( array $promotion ) {
|
||||||
|
?>
|
||||||
|
<div class="addons-wcs-banner-block">
|
||||||
|
<div class="addons-wcs-banner-block-image">
|
||||||
|
<img
|
||||||
|
class="addons-img"
|
||||||
|
src="<?php echo esc_url( $promotion['image'] ); ?>"
|
||||||
|
alt="<?php echo esc_attr( $promotion['image_alt'] ); ?>"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="addons-wcs-banner-block-content">
|
||||||
|
<h1><?php echo esc_html( $promotion['title'] ); ?></h1>
|
||||||
|
<p><?php echo esc_html( $promotion['description'] ); ?></p>
|
||||||
|
<?php
|
||||||
|
if ( ! empty( $promotion['actions'] ) ) {
|
||||||
|
foreach ( $promotion['actions'] as $action ) {
|
||||||
|
self::output_promotion_action( $action );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the output of a full-width block.
|
* Handles the output of a full-width block.
|
||||||
*
|
*
|
||||||
|
@ -564,7 +595,6 @@ class WC_Admin_Addons {
|
||||||
</div>
|
</div>
|
||||||
<div class="addons-promotion-block-buttons">
|
<div class="addons-promotion-block-buttons">
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ( $section['button_1'] ) {
|
if ( $section['button_1'] ) {
|
||||||
self::output_button(
|
self::output_button(
|
||||||
$section['button_1_href'],
|
$section['button_1_href'],
|
||||||
|
@ -582,7 +612,6 @@ class WC_Admin_Addons {
|
||||||
$section['plugin']
|
$section['plugin']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -681,6 +710,26 @@ class WC_Admin_Addons {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output HTML for a promotion action.
|
||||||
|
*
|
||||||
|
* @param array $action Array of action properties.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function output_promotion_action( array $action ) {
|
||||||
|
if ( empty( $action ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$style = ( ! empty( $action['primary'] ) && $action['primary'] ) ? 'addons-button-solid' : 'addons-button-outline-purple';
|
||||||
|
?>
|
||||||
|
<a
|
||||||
|
class="addons-button <?php echo esc_attr( $style ); ?>"
|
||||||
|
href="<?php echo esc_url( $action['url'] ); ?>">
|
||||||
|
<?php echo esc_html( $action['label'] ); ?>
|
||||||
|
</a>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles output of the addons page in admin.
|
* Handles output of the addons page in admin.
|
||||||
|
@ -853,7 +902,7 @@ class WC_Admin_Addons {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return wp_nonce_url(
|
return wp_nonce_url(
|
||||||
wc_admin_url( $action->url ),
|
admin_url( $action->url ),
|
||||||
$action->nonce
|
$action->nonce
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,10 @@ $current_section_name = __( 'Browse Categories', 'woocommerce' );
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ( '_featured' !== $current_section && $addons ) : ?>
|
<?php if ( '_featured' !== $current_section && $addons ) : ?>
|
||||||
<?php
|
<?php
|
||||||
print_r( $promotions, true );
|
|
||||||
if ( ! empty( $promotions ) && WC()->is_wc_admin_active() ) {
|
if ( ! empty( $promotions ) && WC()->is_wc_admin_active() ) {
|
||||||
|
foreach ( $promotions as $promotion ) {
|
||||||
|
WC_Admin_Addons::output_search_promotion_block( $promotion );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<ul class="products">
|
<ul class="products">
|
||||||
|
|
Loading…
Reference in New Issue