BSF_Rollback_Version::bsf_get_product_versions( string $product_id )
Get All versions of product.
Description
Parameters
- $product_id
-
(string) (Required) Product ID.
Source
File: admin/bsf-core/classes/class-bsf-rollback-version.php
public static function bsf_get_product_versions( $product_id ) { if ( empty( $product_id ) ) { return array(); } // Check is transient is expire or User has Enalbed/Disabled the beta version. $versions_transient = get_site_transient( 'bsf-product-versions-' . $product_id ); if ( false !== $versions_transient && false === self::is_beta_enabled_rollback( $product_id ) ) { return $versions_transient; } $per_page = apply_filters( 'bsf_show_versions_to_rollback_' . $product_id, 10 ); $path = bsf_get_api_site( false, true ) . 'versions/' . $product_id . '?per_page=' . $per_page; if ( BSF_Update_Manager::bsf_allow_beta_updates( $product_id ) ) { $path = add_query_arg( 'include_beta', 'true', $path ); } $response = wp_remote_get( $path, array( 'timeout' => '10', ) ); if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) { return array(); } $response_versions = json_decode( wp_remote_retrieve_body( $response ), true ); // Cache product version for 24 hrs. set_site_transient( 'bsf-product-versions-' . $product_id, $response_versions, 24 * HOUR_IN_SECONDS ); return $response_versions; }
Expand full source code Collapse full source code View on Trac