WordPress at Your Fingertips
function is not described

WC_Admin_Addons::output_wcs_banner_block() public WC 1.0

Deprecated from version 5.9.0. It is no longer supported and can be removed in future releases. Use d in In-App Marketplace instead.

Handles the outputting of the WooCommerce Services banner block.

{} It's a method of the class: WC_Admin_Addons{}

No Hooks.

Return

null. Nothing.

Usage

$result = WC_Admin_Addons::output_wcs_banner_block( $block );
$block(object)
Block data.
Default: array()

Changelog

Deprecated Since 5.9.0 No longer used in In-App Marketplace

Code of WC_Admin_Addons::output_wcs_banner_block() WC 5.9.0

<?php
public static function output_wcs_banner_block( $block = array() ) {
	$is_active = is_plugin_active( 'woocommerce-services/woocommerce-services.php' );
	$location  = wc_get_base_location();

	if (
		! in_array( $location['country'], array( 'US' ), true ) ||
		$is_active ||
		! current_user_can( 'install_plugins' ) ||
		! current_user_can( 'activate_plugins' )
	) {
		return;
	}

	$button_url = wp_nonce_url(
		add_query_arg(
			array(
				'install-addon' => 'woocommerce-services',
			)
		),
		'install-addon_woocommerce-services'
	);

	$defaults = array(
		'image'       => WC()->plugin_url() . '/assets/images/wcs-extensions-banner-3x.jpg',
		'image_alt'   => __( 'WooCommerce Shipping', 'woocommerce' ),
		'title'       => __( 'Save time and money with WooCommerce Shipping', 'woocommerce' ),
		'description' => __( 'Print discounted USPS and DHL labels straight from your WooCommerce dashboard and save on shipping.', 'woocommerce' ),
		'button'      => __( 'Free - Install now', 'woocommerce' ),
		'href'        => $button_url,
		'logos'       => array(),
	);

	switch ( $location['country'] ) {
		case 'US':
			$local_defaults = array(
				'logos' => array_merge(
					$defaults['logos'],
					array(
						array(
							'link' => WC()->plugin_url() . '/assets/images/wcs-usps-logo.png',
							'alt'  => 'USPS logo',
						),
						array(
							'link' => WC()->plugin_url() . '/assets/images/wcs-dhlexpress-logo.png',
							'alt'  => 'DHL Express logo',
						),
					)
				),
			);
			break;
		default:
			$local_defaults = array();
	}

	$block_data = array_merge( $defaults, $local_defaults, $block );
	?>
	<div class="addons-wcs-banner-block">
		<div class="addons-wcs-banner-block-image is-full-image">
			<img
				class="addons-img"
				src="<?php echo esc_url( $block_data['image'] ); ?>"
				alt="<?php echo esc_attr( $block_data['image_alt'] ); ?>"
			/>
		</div>
		<div class="addons-wcs-banner-block-content">
			<h1><?php echo esc_html( $block_data['title'] ); ?></h1>
			<p><?php echo esc_html( $block_data['description'] ); ?></p>
			<ul class="wcs-logos-container">
				<?php foreach ( $block_data['logos'] as $logo ) : ?>
					<li>
						<img
							alt="<?php echo esc_attr( $logo['alt'] ); ?>"
							class="wcs-service-logo"
							src="<?php echo esc_url( $logo['link'] ); ?>"
						>
					</li>
				<?php endforeach; ?>
			</ul>
			<?php
				self::output_button(
					$block_data['href'],
					$block_data['button'],
					'addons-button-outline-purple'
				);
			?>
		</div>
	</div>
	<?php
}