<?php
/**
 * Template: Disabled Component Inner.
 *
 * @package SmartCrawl
 */

namespace SmartCrawl;

$content             = empty( $content ) ? '' : $content;
$image               = empty( $image ) ? 'empty-box.svg' : $image;
$component           = empty( $component ) ? '' : $component;
$is_enabled          = false;
$upgrade_tag         = empty( $upgrade_tag ) ? '' : $upgrade_tag;
$premium_feature     = ! empty( $premium_feature );
$notice              = empty( $notice ) ? '' : $notice;
$button_url          = empty( $button_url ) ? '' : $button_url;
$button_icon         = empty( $button_icon ) ? '' : $button_icon;
$button_disabled     = empty( $button_disabled ) ? false : $button_disabled;
$button_name         = empty( $button_name ) ? '' : $button_name;
$button_text         = empty( $button_text ) ? '' : $button_text;
$upgrade_button_text = empty( $upgrade_button_text ) ? esc_html__( 'Upgrade to Pro', 'smartcrawl-seo' ) : $upgrade_button_text;
$button_class        = empty( $button_class ) ? '' : $button_class;
$button_color        = empty( $button_color ) ? 'blue' : $button_color;

$image_url   = sprintf( '%s/assets/images/%s', SMARTCRAWL_PLUGIN_URL, $image );
$image_url   = \SmartCrawl\Controllers\White_Label::get()->get_wpmudev_hero_image( $image_url );
$upgrade_url = 'https://wpmudev.com/project/smartcrawl-wordpress-seo/?utm_source=smartcrawl&utm_medium=plugin&utm_campaign=' . $upgrade_tag;
?>
<div class="wds-disabled-component">
	<?php if ( ! empty( $image_url ) ) : ?>
		<p>
			<img
				src="<?php echo esc_attr( $image_url ); ?>"
				alt="<?php esc_attr_e( 'Disabled', 'smartcrawl-seo' ); ?>"
				class="wds-disabled-image"
			/>
		</p>
	<?php endif; ?>

	<p><?php echo wp_kses_post( $content ); ?></p>

	<?php if ( $notice ) : ?>
		<div class="wds-notice wds-notice-warning">
			<p><?php echo esc_html( $notice ); ?></p>
		</div>
	<?php endif; ?>

	<?php if ( $component ) : ?>
		<input type="hidden" name="wds-activate-component" value="<?php echo esc_attr( $component ); ?>"/>
		<?php wp_nonce_field( 'wds-settings-nonce', '_wds_nonce' ); ?>
	<?php endif; ?>

	<?php if ( $premium_feature && ! $is_enabled ) : ?>
		<a
			class="sui-button sui-button-purple"
			target="_blank"
			href="<?php echo esc_attr( $upgrade_url ); ?>"
		>
			<?php echo esc_html( $upgrade_button_text ); ?>
		</a>
	<?php else : ?>
		<?php if ( $button_url ) : ?>
			<a
				class="sui-button sui-button-<?php echo esc_attr( $button_color ); ?> <?php echo esc_attr( $button_class ) . ( $button_disabled ? 'disabled' : '' ); ?>"
				href="<?php echo esc_attr( $button_url ); ?>"
			>
				<?php if ( $button_icon ) : ?>
					<span class="<?php echo esc_attr( $button_icon ); ?>" aria-hidden="true"></span>
				<?php endif; ?>
				<?php echo esc_html( $button_text ); ?>
			</a>
		<?php elseif ( $button_name ) : ?>
			<button
				class="sui-button sui-button-<?php echo esc_attr( $button_color ); ?> <?php echo esc_attr( $button_class ) . ( $button_disabled ? 'disabled' : '' ); ?>"
				type="submit"
				name="<?php echo esc_attr( $button_name ); ?>"
				value="1"
			><?php echo esc_attr( $button_text ); ?></button>
		<?php else : ?>
			<input
				class="sui-button sui-button-<?php echo esc_attr( $button_color ); ?> <?php echo esc_attr( $button_class ) . ( $button_disabled ? 'disabled' : '' ); ?>"
				type="submit"
				name="submit"
				value="<?php echo esc_attr( $button_text ); ?>"
			/>
		<?php endif; ?>
	<?php endif; ?>
</div>
