BSF_Rollback_Version_Manager::render_rollback_version_form( string $product_id )

Display Rollback to privious versions form.


Description


Parameters

$product_id

(string) (Required) Product ID.


Source

File: admin/bsf-core/class-bsf-rollback-version-manager.php

	public function render_rollback_version_form( $product_id ) {
		add_action( 'admin_footer', array( $this, 'rollback_version_popup' ) );

		// Enqueue scripts only when this function is called.
		wp_enqueue_script( 'bsf-core-version-rollback' );
		wp_enqueue_style( 'bsf-core-version-rollback-css' );

		$product_details   = get_brainstorm_product( $product_id );
		$installed_version = isset( $product_details['version'] ) ? $product_details['version'] : '';
		$product_versions  = BSF_Rollback_Version::bsf_get_product_versions( $product_id ); // Get Remote versions
		// Show versions above than latest install version of the product.
		$sorted_versions = BSF_Rollback_Version::sort_product_versions( $product_versions, $installed_version );

		if ( empty( $sorted_versions ) ) {
			echo esc_html__( 'No Versions Found! ', 'bsf-core' );
			return;
		}

		$product_name     = isset( $product_details['name'] ) ? $product_details['name'] : '';
		$white_label_name = bsf_get_white_lable_product_name( $product_id, $product_name );
		?>
		<div class="bsf-rollback-version">
			<input type="hidden" name="product-name" id="bsf-product-name" value="<?php echo esc_attr( $white_label_name ); ?>">
			<select class="bsf-rollback-version-select">
			<?php
			foreach ( $sorted_versions as $version ) {
				?>
					<option value="<?php echo esc_attr( $version ); ?>"><?php echo esc_html( $version ); ?> </option>
				<?php
			}
			?>
			</select>
			<a data-placeholder-text=" <?php echo esc_html__( 'Rollback', 'bsf-core' ); ?>" href="<?php echo esc_url( add_query_arg( 'version_no', $sorted_versions[0], wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&product_id=' . $product_id ), 'bsf_rollback' ) ) ); ?>"
			data-placeholder-url="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&version_no=VERSION&product_id=' . $product_id ), 'bsf_rollback' ) ); ?>" class="button bsf-rollback-button"><?php echo esc_html__( 'Rollback', 'bsf-core' ); ?> </a>
		</div>
		<?php
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.