Astra_Rollback_Version::get_theme_all_versions()

Get Rollback versions.


Description


Return

(array)


Source

File: admin/astra-rollback/class-astra-rollback-version.php

	public static function get_theme_all_versions() {

		$rollback_versions = get_transient( 'astra_theme_rollback_versions_' . ASTRA_THEME_VERSION );
		if ( ! empty( $rollback_versions ) ) {
			return $rollback_versions;
		}

		$max_versions      = apply_filters( 'astra_show_max_rollback_versions', 5 );
		$rollback_versions = array();

		require_once ABSPATH . 'wp-admin/includes/theme-install.php';

		$theme_information = themes_api(
			'theme_information',
			array(
				'slug'   => 'astra',
				'fields' => array(
					'versions' => true,
				),
			)
		);

		if ( empty( $theme_information->versions ) || ! is_array( $theme_information->versions ) ) {
			return $rollback_versions;
		}

		krsort( $theme_information->versions ); // Reverse the order of array elements.

		foreach ( $theme_information->versions as $version => $download_link ) {

			$lowercase_version = strtolower( $version );

			$is_valid_rollback_version = ! preg_match( '/(trunk|beta|rc|dev)/i', $lowercase_version );

			if ( ! $is_valid_rollback_version ) {
				continue;
			}

			if ( version_compare( $version, ASTRA_THEME_VERSION, '>=' ) ) {
				continue;
			}

			$rollback_versions[] = $version;
		}

		$rollback_versions = array_slice( $rollback_versions, 0, $max_versions, true ); // Max verisons to be shown.
		set_transient( 'astra_theme_rollback_versions_' . ASTRA_THEME_VERSION, $rollback_versions, WEEK_IN_SECONDS );

		return $rollback_versions;
	}

Changelog

Changelog
Version Description
3.6.1 Introduced.


User Contributed Notes

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