WPSEO_Premium_Upsell_Admin_Block::renderpublicYoast 1.0

Renders the upsell block.

Метод класса: WPSEO_Premium_Upsell_Admin_Block{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WPSEO_Premium_Upsell_Admin_Block = new WPSEO_Premium_Upsell_Admin_Block();
$WPSEO_Premium_Upsell_Admin_Block->render();

Код WPSEO_Premium_Upsell_Admin_Block::render() Yoast 27.4

public function render() {

	$is_woocommerce_active = ( new WooCommerce_Conditional() )->is_met();
	$url                   = ( $is_woocommerce_active ) ? WPSEO_Shortlinker::get( 'https://yoa.st/admin-footer-upsell-woocommerce' ) : WPSEO_Shortlinker::get( 'https://yoa.st/17h' );

	[ $header_text, $header_icon ] = $this->get_header( $is_woocommerce_active );

	$arguments = $this->get_arguments( $is_woocommerce_active );

	$now_including = [ 'Local SEO', 'News SEO', 'Video SEO', __( 'Google Docs add-on (1 seat)', 'wordpress-seo' ) ];
	if ( $is_woocommerce_active ) {
		array_unshift( $now_including, 'Yoast SEO Premium' );
	}

	$header_class   = ( $is_woocommerce_active ) ? 'woo-header' : '';
	$arguments_html = implode( '', array_map( [ $this, 'get_argument_html' ], $arguments ) );
	$badge_class    = ( $is_woocommerce_active ) ? 'woo-badge' : '';

	$class = $this->get_html_class();

	/* translators: %s expands to Yoast SEO Premium */
	$button_text = $this->get_button_text( $is_woocommerce_active );
	/* translators: Hidden accessibility text. */
	$button_text .= '<span class="screen-reader-text">' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . '</span>'
		. '<span aria-hidden="true" class="yoast-button-upsell__caret"></span>';

	$upgrade_button = sprintf(
		'<a id="%1$s" class="yoast-button-upsell" data-action="load-nfd-ctb" data-ctb-id="f6a84663-465f-4cb5-8ba5-f7a6d72224b2" href="%2$s" target="_blank">%3$s</a>',
		esc_attr( 'wpseo-' . $this->identifier . '-popup-button' ),
		esc_url( $url ),
		$button_text,
	);

	echo '<div class="' . esc_attr( $class ) . '">';

	if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-promotion' ) ) {
		$bf_label   = esc_html__( 'BLACK FRIDAY', 'wordpress-seo' );
		$sale_label = esc_html__( '30% OFF', 'wordpress-seo' );
		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Already escaped above.
		echo "<div class='black-friday-container'><span>$sale_label</span> <span style='margin-left: auto;'>$bf_label</span> </div>";
	}

	echo '<div class="' . esc_attr( $class . '--container' ) . '">';
	// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in get_header() method.
	echo '<h2 class="' . esc_attr( $class . '--header' ) . ' ' . esc_attr( $header_class ) . ' ">' . $header_text . $header_icon . '</h2>';

	echo '<div class="' . esc_attr( $class . '--subheader' ) . '">';
	echo '<span style="margin-right: 8px">' . esc_html__( 'Now includes:', 'wordpress-seo' ) . '</span>';
	echo '<div style="display: inline-block;">';
	foreach ( $now_including as $value ) {
		echo '<span class="yoast-badge ' . esc_attr( $class . '--badge' ) . ' ' . esc_attr( $badge_class ) . '">' . esc_html( $value ) . '</span>';
	}
	echo '</div>';
	echo '</div>';
	// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $this->get_argument_html() method.
	echo '<ul class="' . esc_attr( $class . '--motivation' ) . '">' . $arguments_html . '</ul>';

	// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Correctly escaped in $upgrade_button and $button_text above.
	echo '<p style="max-width: inherit; margin-top: 24px; margin-bottom: 0;">' . $upgrade_button . '</p>';
	echo '</div>';

	echo '</div>';
}