2018-06-04 19:21:02 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Beta Tester plugin main class
|
|
|
|
*
|
|
|
|
* @package WC_Beta_Tester
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC_Beta_Tester Main Class.
|
|
|
|
*/
|
|
|
|
class WC_Beta_Tester {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Config
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2018-06-25 13:35:10 +00:00
|
|
|
private $plugin_config;
|
2018-06-04 19:21:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plugin instance.
|
|
|
|
*
|
|
|
|
* @var WC_Beta_Tester
|
|
|
|
*/
|
|
|
|
protected static $_instance = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main Instance.
|
|
|
|
*/
|
|
|
|
public static function instance() {
|
|
|
|
self::$_instance = is_null( self::$_instance ) ? new self() : self::$_instance;
|
|
|
|
|
|
|
|
return self::$_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ran on activation to flush update cache
|
|
|
|
*/
|
|
|
|
public static function activate() {
|
|
|
|
delete_site_transient( 'update_plugins' );
|
|
|
|
delete_site_transient( 'woocommerce_latest_tag' );
|
|
|
|
}
|
|
|
|
|
2018-06-06 15:14:32 +00:00
|
|
|
/**
|
|
|
|
* Get plugin settings.
|
|
|
|
*
|
|
|
|
* @return object
|
|
|
|
*/
|
|
|
|
public static function get_settings() {
|
|
|
|
$settings = (object) wp_parse_args(
|
|
|
|
get_option( 'wc_beta_tester_options', array() ),
|
|
|
|
array(
|
2018-06-25 14:00:00 +00:00
|
|
|
'channel' => 'beta',
|
2018-06-06 15:14:32 +00:00
|
|
|
'auto_update' => false,
|
|
|
|
)
|
|
|
|
);
|
2018-06-25 11:35:57 +00:00
|
|
|
|
2018-06-25 13:35:10 +00:00
|
|
|
$settings->channel = $settings->channel;
|
2018-06-06 15:14:32 +00:00
|
|
|
$settings->auto_update = (bool) $settings->auto_update;
|
2018-06-25 11:35:57 +00:00
|
|
|
|
2018-06-06 15:14:32 +00:00
|
|
|
return $settings;
|
|
|
|
}
|
|
|
|
|
2018-06-06 08:02:45 +00:00
|
|
|
/**
|
|
|
|
* Get the plugin url.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function plugin_url() {
|
|
|
|
return untrailingslashit( plugins_url( '/', WC_BETA_TESTER_FILE ) );
|
|
|
|
}
|
|
|
|
|
2018-06-04 19:21:02 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
2018-06-25 13:35:10 +00:00
|
|
|
$this->plugin_name = plugin_basename( WC_BETA_TESTER_FILE );
|
|
|
|
$this->plugin_config = array(
|
2018-06-04 19:21:02 +00:00
|
|
|
'plugin_file' => 'woocommerce/woocommerce.php',
|
|
|
|
'slug' => 'woocommerce',
|
|
|
|
'proper_folder_name' => 'woocommerce',
|
2018-06-05 13:26:59 +00:00
|
|
|
'api_url' => 'https://api.wordpress.org/plugins/info/1.0/woocommerce.json',
|
2018-06-05 17:08:06 +00:00
|
|
|
'repo_url' => 'https://wordpress.org/plugins/woocommerce/',
|
2018-06-04 19:21:02 +00:00
|
|
|
);
|
|
|
|
|
2018-06-07 12:18:29 +00:00
|
|
|
add_filter( "plugin_action_links_{$this->plugin_name}", array( $this, 'plugin_action_links' ), 10, 1 );
|
2020-09-22 18:50:54 +00:00
|
|
|
add_filter( 'auto_update_plugin', array( $this, 'auto_update_woocommerce' ), 100, 2 );
|
2018-06-25 13:35:10 +00:00
|
|
|
|
|
|
|
if ( 'stable' !== $this->get_settings()->channel ) {
|
|
|
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'api_check' ) );
|
|
|
|
add_filter( 'plugins_api_result', array( $this, 'plugins_api_result' ), 10, 3 );
|
|
|
|
add_filter( 'upgrader_source_selection', array( $this, 'upgrader_source_selection' ), 10, 3 );
|
|
|
|
}
|
2018-06-05 08:37:08 +00:00
|
|
|
|
|
|
|
$this->includes();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include any classes we need within admin.
|
|
|
|
*/
|
|
|
|
public function includes() {
|
2018-06-05 17:06:21 +00:00
|
|
|
include_once dirname( __FILE__ ) . '/class-wc-beta-tester-admin-menus.php';
|
2018-06-06 11:29:52 +00:00
|
|
|
include_once dirname( __FILE__ ) . '/class-wc-beta-tester-admin-assets.php';
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-03 18:27:32 +00:00
|
|
|
* Check whether or not the transients need to be overruled and API needs to be called for every single page load
|
2018-06-04 19:21:02 +00:00
|
|
|
*
|
|
|
|
* @return bool overrule or not
|
|
|
|
*/
|
|
|
|
public function overrule_transients() {
|
|
|
|
return defined( 'WC_BETA_TESTER_FORCE_UPDATE' ) && WC_BETA_TESTER_FORCE_UPDATE;
|
|
|
|
}
|
|
|
|
|
2018-06-07 08:52:33 +00:00
|
|
|
/**
|
|
|
|
* Checks if a given version is a pre-release.
|
|
|
|
*
|
2018-06-25 11:35:57 +00:00
|
|
|
* @param string $version Version to compare.
|
2018-06-07 08:52:33 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function is_prerelease( $version ) {
|
|
|
|
return preg_match( '/(.*)?-(beta|rc)(.*)/', $version );
|
|
|
|
}
|
|
|
|
|
2018-06-04 19:21:02 +00:00
|
|
|
/**
|
2018-06-05 13:26:59 +00:00
|
|
|
* Get New Version from WPorg
|
2018-06-04 19:21:02 +00:00
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
* @return int $version the version number
|
|
|
|
*/
|
2018-06-25 13:35:10 +00:00
|
|
|
public function get_latest_channel_release() {
|
|
|
|
$tagged_version = get_site_transient( md5( $this->plugin_config['slug'] ) . '_latest_tag' );
|
2018-06-04 19:21:02 +00:00
|
|
|
|
|
|
|
if ( $this->overrule_transients() || empty( $tagged_version ) ) {
|
|
|
|
|
2018-06-05 21:18:07 +00:00
|
|
|
$data = $this->get_wporg_data();
|
2018-06-04 19:21:02 +00:00
|
|
|
|
2018-06-05 21:18:07 +00:00
|
|
|
$latest_version = $data->version;
|
|
|
|
$versions = (array) $data->versions;
|
2018-06-25 13:35:10 +00:00
|
|
|
$channel = $this->get_settings()->channel;
|
2018-06-04 19:21:02 +00:00
|
|
|
|
2018-06-05 21:18:07 +00:00
|
|
|
foreach ( $versions as $version => $download_url ) {
|
2018-06-25 13:35:10 +00:00
|
|
|
if ( 'trunk' === $version ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
switch ( $channel ) {
|
|
|
|
case 'stable':
|
|
|
|
if ( $this->is_in_stable_channel( $version ) ) {
|
|
|
|
$tagged_version = $version;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'rc':
|
|
|
|
if ( $this->is_in_rc_channel( $version ) ) {
|
|
|
|
$tagged_version = $version;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'beta':
|
|
|
|
if ( $this->is_in_beta_channel( $version ) ) {
|
|
|
|
$tagged_version = $version;
|
|
|
|
}
|
|
|
|
break;
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Refresh every 6 hours.
|
|
|
|
if ( ! empty( $tagged_version ) ) {
|
2018-06-25 13:35:10 +00:00
|
|
|
set_site_transient( md5( $this->plugin_config['slug'] ) . '_latest_tag', $tagged_version, HOUR_IN_SECONDS * 6 );
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tagged_version;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-05 13:26:59 +00:00
|
|
|
* Get Data from .org API.
|
2018-06-04 19:21:02 +00:00
|
|
|
*
|
|
|
|
* @since 1.0
|
2018-06-05 13:26:59 +00:00
|
|
|
* @return array $wporg_data The data.
|
2018-06-04 19:21:02 +00:00
|
|
|
*/
|
2018-06-05 13:26:59 +00:00
|
|
|
public function get_wporg_data() {
|
|
|
|
if ( ! empty( $this->wporg_data ) ) {
|
|
|
|
return $this->wporg_data;
|
|
|
|
}
|
2018-06-04 19:21:02 +00:00
|
|
|
|
2018-06-25 13:35:10 +00:00
|
|
|
$wporg_data = get_site_transient( md5( $this->plugin_config['slug'] ) . '_wporg_data' );
|
2018-06-04 19:21:02 +00:00
|
|
|
|
2018-06-05 13:26:59 +00:00
|
|
|
if ( $this->overrule_transients() || ( ! isset( $wporg_data ) || ! $wporg_data || '' === $wporg_data ) ) {
|
2018-06-25 13:35:10 +00:00
|
|
|
$wporg_data = wp_remote_get( $this->plugin_config['api_url'] );
|
2018-06-04 19:21:02 +00:00
|
|
|
|
2018-06-05 13:26:59 +00:00
|
|
|
if ( is_wp_error( $wporg_data ) ) {
|
|
|
|
return false;
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
|
2018-06-05 13:26:59 +00:00
|
|
|
$wporg_data = json_decode( $wporg_data['body'] );
|
|
|
|
|
|
|
|
// Refresh every 6 hours.
|
2018-06-25 13:35:10 +00:00
|
|
|
set_site_transient( md5( $this->plugin_config['slug'] ) . '_wporg_data', $wporg_data, HOUR_IN_SECONDS * 6 );
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
|
2018-06-05 13:26:59 +00:00
|
|
|
// Store the data in this class instance for future calls.
|
|
|
|
$this->wporg_data = $wporg_data;
|
|
|
|
|
|
|
|
return $wporg_data;
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
2018-06-05 13:31:53 +00:00
|
|
|
|
|
|
|
/**
|
2018-06-05 17:06:21 +00:00
|
|
|
* Get plugin download URL.
|
2018-06-05 13:31:53 +00:00
|
|
|
*
|
|
|
|
* @since 1.0
|
2018-06-05 17:06:21 +00:00
|
|
|
* @param string $version The version.
|
|
|
|
* @return string
|
2018-06-05 13:31:53 +00:00
|
|
|
*/
|
|
|
|
public function get_download_url( $version ) {
|
|
|
|
$data = $this->get_wporg_data();
|
|
|
|
|
|
|
|
if ( empty( $data->versions->$version ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data->versions->$version;
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Plugin data.
|
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
* @return object $data The data.
|
|
|
|
*/
|
|
|
|
public function get_plugin_data() {
|
2018-06-25 13:35:10 +00:00
|
|
|
return get_plugin_data( WP_PLUGIN_DIR . '/' . $this->plugin_config['plugin_file'] );
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-05 13:26:59 +00:00
|
|
|
* Hook into the plugin update check and connect to WPorg.
|
2018-06-04 19:21:02 +00:00
|
|
|
*
|
|
|
|
* @since 1.0
|
|
|
|
* @param object $transient The plugin data transient.
|
|
|
|
* @return object $transient Updated plugin data transient.
|
|
|
|
*/
|
|
|
|
public function api_check( $transient ) {
|
|
|
|
// Clear our transient.
|
2018-06-25 13:35:10 +00:00
|
|
|
delete_site_transient( md5( $this->plugin_config['slug'] ) . '_latest_tag' );
|
2018-06-04 19:21:02 +00:00
|
|
|
|
2018-06-25 13:35:10 +00:00
|
|
|
// Get version data.
|
|
|
|
$plugin_data = $this->get_plugin_data();
|
|
|
|
$version = $plugin_data['Version'];
|
|
|
|
$new_version = $this->get_latest_channel_release();
|
2018-06-04 19:21:02 +00:00
|
|
|
|
|
|
|
// check the version and decide if it's new.
|
2018-06-25 13:35:10 +00:00
|
|
|
$update = version_compare( $new_version, $version, '>' );
|
|
|
|
|
|
|
|
if ( ! $update ) {
|
|
|
|
return $transient;
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 13:35:10 +00:00
|
|
|
// Populate response data.
|
|
|
|
if ( ! isset( $transient->response['woocommerce/woocommerce.php'] ) ) {
|
|
|
|
$transient->response['woocommerce/woocommerce.php'] = (object) $this->plugin_config;
|
|
|
|
}
|
|
|
|
|
|
|
|
$transient->response['woocommerce/woocommerce.php']->new_version = $new_version;
|
|
|
|
$transient->response['woocommerce/woocommerce.php']->zip_url = $this->get_download_url( $new_version );
|
|
|
|
$transient->response['woocommerce/woocommerce.php']->package = $this->get_download_url( $new_version );
|
|
|
|
|
2018-06-04 19:21:02 +00:00
|
|
|
return $transient;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-06-25 13:35:10 +00:00
|
|
|
* Filters the Plugin Installation API response results.
|
2018-06-04 19:21:02 +00:00
|
|
|
*
|
2018-06-25 13:35:10 +00:00
|
|
|
* @param object|WP_Error $response Response object or WP_Error.
|
|
|
|
* @param string $action The type of information being requested from the Plugin Installation API.
|
|
|
|
* @param object $args Plugin API arguments.
|
2018-06-04 19:21:02 +00:00
|
|
|
* @return object
|
|
|
|
*/
|
2018-06-25 13:35:10 +00:00
|
|
|
public function plugins_api_result( $response, $action, $args ) {
|
2018-06-04 19:21:02 +00:00
|
|
|
// Check if this call API is for the right plugin.
|
2018-06-25 13:35:10 +00:00
|
|
|
if ( ! isset( $response->slug ) || $response->slug !== $this->plugin_config['slug'] ) {
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
$new_version = $this->get_latest_channel_release();
|
|
|
|
|
|
|
|
if ( version_compare( $response->version, $new_version, '=' ) ) {
|
|
|
|
return $response;
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 13:35:10 +00:00
|
|
|
if ( $this->is_beta_version( $new_version ) ) {
|
|
|
|
$warning = __( '<h1><span>⚠</span>This is a beta release<span>⚠</span></h1>', 'woocommerce-beta-tester' );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $this->is_rc_version( $new_version ) ) {
|
|
|
|
$warning = __( '<h1><span>⚠</span>This is a pre-release version<span>⚠</span></h1>', 'woocommerce-beta-tester' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we are returning a different version than the stable tag on .org, manipulate the returned data.
|
|
|
|
$response->version = $new_version;
|
|
|
|
$response->download_link = $this->get_download_url( $new_version );
|
|
|
|
|
2018-07-06 18:01:42 +00:00
|
|
|
$response->sections['changelog'] = sprintf(
|
|
|
|
'<p><a target="_blank" href="%s">' . __( 'Read the changelog and find out more about the release on GitHub.', 'woocommerce-beta-tester' ) . '</a></p>',
|
|
|
|
'https://github.com/woocommerce/woocommerce/blob/' . $response->version . '/readme.txt'
|
2018-06-25 13:35:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
foreach ( $response->sections as $key => $section ) {
|
|
|
|
$response->sections[ $key ] = $warning . $section;
|
|
|
|
}
|
2018-06-04 19:21:02 +00:00
|
|
|
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rename the downloaded zip
|
|
|
|
*
|
|
|
|
* @param string $source File source location.
|
|
|
|
* @param string $remote_source Remote file source location.
|
|
|
|
* @param WP_Upgrader $upgrader WordPress Upgrader instance.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function upgrader_source_selection( $source, $remote_source, $upgrader ) {
|
|
|
|
global $wp_filesystem;
|
|
|
|
|
|
|
|
if ( strstr( $source, '/woocommerce-woocommerce-' ) ) {
|
2018-06-25 13:35:10 +00:00
|
|
|
$corrected_source = trailingslashit( $remote_source ) . trailingslashit( $this->plugin_config['proper_folder_name'] );
|
2018-06-04 19:21:02 +00:00
|
|
|
|
|
|
|
if ( $wp_filesystem->move( $source, $corrected_source, true ) ) {
|
|
|
|
return $corrected_source;
|
|
|
|
} else {
|
|
|
|
return new WP_Error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $source;
|
|
|
|
}
|
2018-06-05 22:46:22 +00:00
|
|
|
|
2018-06-06 15:18:34 +00:00
|
|
|
/**
|
|
|
|
* Enable auto updates for WooCommerce.
|
|
|
|
*
|
|
|
|
* @param bool $update Should this autoupdate.
|
|
|
|
* @param object $plugin Plugin being checked.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function auto_update_woocommerce( $update, $plugin ) {
|
2020-09-29 08:42:19 +00:00
|
|
|
if ( true === $this->get_settings()->auto_update && 'woocommerce' === $plugin->slug ) {
|
2018-06-06 15:18:34 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return $update;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-05 22:46:22 +00:00
|
|
|
/**
|
|
|
|
* Return true if version string is a beta version.
|
|
|
|
*
|
|
|
|
* @param string $version_str Version string.
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-06-06 10:58:57 +00:00
|
|
|
protected static function is_beta_version( $version_str ) {
|
2018-06-05 22:46:22 +00:00
|
|
|
return strpos( $version_str, 'beta' ) !== false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if version string is a Release Candidate.
|
|
|
|
*
|
|
|
|
* @param string $version_str Version string.
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-06-06 10:58:57 +00:00
|
|
|
protected static function is_rc_version( $version_str ) {
|
2018-06-05 22:46:22 +00:00
|
|
|
return strpos( $version_str, 'rc' ) !== false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if version string is a stable version.
|
|
|
|
*
|
|
|
|
* @param string $version_str Version string.
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-06-06 10:58:57 +00:00
|
|
|
protected static function is_stable_version( $version_str ) {
|
|
|
|
return ! self::is_beta_version( $version_str ) && ! self::is_rc_version( $version_str );
|
2018-06-05 22:46:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if release's version string belongs to beta channel, i.e.
|
|
|
|
* if it's beta, rc or stable release.
|
|
|
|
*
|
|
|
|
* @param string $version_str Version string of the release.
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-06-06 10:58:57 +00:00
|
|
|
protected static function is_in_beta_channel( $version_str ) {
|
|
|
|
return self::is_beta_version( $version_str ) || self::is_rc_version( $version_str ) || self::is_stable_version( $version_str );
|
2018-06-05 22:46:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if release's version string belongs to release candidate channel, i.e.
|
|
|
|
* if it's rc or stable release.
|
|
|
|
*
|
|
|
|
* @param string $version_str Version string of the release.
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-06-06 10:58:57 +00:00
|
|
|
protected static function is_in_rc_channel( $version_str ) {
|
|
|
|
return self::is_rc_version( $version_str ) || self::is_stable_version( $version_str );
|
2018-06-05 22:46:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if release's version string belongs to stable channel, i.e.
|
|
|
|
* if it's stable release and not a beta or rc.
|
|
|
|
*
|
|
|
|
* @param string $version_str Version string of the release.
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-06-06 10:58:57 +00:00
|
|
|
protected static function is_in_stable_channel( $version_str ) {
|
|
|
|
return self::is_stable_version( $version_str );
|
2018-06-05 22:46:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return available versions from wp.org tags belonging to selected channel.
|
|
|
|
*
|
|
|
|
* @param string $channel Filter versions by channel: all|beta|rc|stable.
|
|
|
|
* @return array(string)
|
|
|
|
*/
|
|
|
|
public function get_tags( $channel = 'all' ) {
|
2018-06-25 11:35:57 +00:00
|
|
|
$data = $this->get_wporg_data();
|
|
|
|
$releases = (array) $data->versions;
|
|
|
|
|
2018-06-05 22:46:22 +00:00
|
|
|
unset( $releases['trunk'] );
|
|
|
|
|
2018-06-25 11:35:57 +00:00
|
|
|
$releases = array_keys( $releases );
|
2020-09-28 18:28:58 +00:00
|
|
|
foreach ( $releases as $index => $version ) {
|
|
|
|
if ( version_compare( $version, '3.6', '<' ) ) {
|
|
|
|
unset( $releases[ $index ] );
|
|
|
|
}
|
|
|
|
}
|
2018-06-25 11:35:57 +00:00
|
|
|
|
2018-06-05 22:46:22 +00:00
|
|
|
if ( 'beta' === $channel ) {
|
2018-06-25 11:35:57 +00:00
|
|
|
$releases = array_filter( $releases, array( __CLASS__, 'is_in_beta_channel' ) );
|
2018-06-05 22:46:22 +00:00
|
|
|
} elseif ( 'rc' === $channel ) {
|
2018-06-25 11:35:57 +00:00
|
|
|
$releases = array_filter( $releases, array( __CLASS__, 'is_in_rc_channel' ) );
|
2018-06-05 22:46:22 +00:00
|
|
|
} elseif ( 'stable' === $channel ) {
|
2018-06-25 11:35:57 +00:00
|
|
|
$releases = array_filter( $releases, array( __CLASS__, 'is_in_stable_channel' ) );
|
2018-06-07 11:12:53 +00:00
|
|
|
}
|
2018-06-05 22:46:22 +00:00
|
|
|
|
2018-06-25 11:35:57 +00:00
|
|
|
return $releases;
|
2018-06-05 22:46:22 +00:00
|
|
|
}
|
2018-06-07 13:34:52 +00:00
|
|
|
|
2018-06-07 12:18:29 +00:00
|
|
|
/**
|
|
|
|
* Show action links on the plugin screen.
|
|
|
|
*
|
|
|
|
* @param mixed $links Plugin Action links.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function plugin_action_links( $links ) {
|
|
|
|
$action_links = array(
|
|
|
|
'switch-version' => sprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
2018-06-25 14:00:00 +00:00
|
|
|
esc_url( admin_url( 'plugins.php?page=wc-beta-tester-version-picker' ) ),
|
2018-06-07 12:47:30 +00:00
|
|
|
esc_html__( 'Switch versions', 'woocommerce-beta-tester' )
|
2018-06-07 12:18:29 +00:00
|
|
|
),
|
2018-06-25 11:35:57 +00:00
|
|
|
'settings' => sprintf(
|
2018-06-07 12:18:29 +00:00
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
esc_url( admin_url( 'plugins.php?page=wc-beta-tester' ) ),
|
2018-06-07 12:47:30 +00:00
|
|
|
esc_html__( 'Settings', 'woocommerce-beta-tester' )
|
2018-06-07 12:18:29 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
return array_merge( $action_links, $links );
|
|
|
|
}
|
2018-06-04 19:21:02 +00:00
|
|
|
}
|