2018-06-06 08:02:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Beta Tester Admin Assets class
|
|
|
|
*
|
|
|
|
* @package WC_Beta_Tester
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC_Beta_Tester_Admin_Assets Class.
|
|
|
|
*/
|
|
|
|
class WC_Beta_Tester_Admin_Assets {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook in tabs.
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueue scripts.
|
|
|
|
*/
|
|
|
|
public function admin_scripts() {
|
2021-02-02 16:45:57 +00:00
|
|
|
$screen = get_current_screen();
|
|
|
|
$screen_id = $screen ? $screen->id : '';
|
|
|
|
|
|
|
|
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
|
|
|
$version = WC_VERSION;
|
2018-06-06 08:02:45 +00:00
|
|
|
|
2018-06-06 08:25:27 +00:00
|
|
|
// Need admin styles for the modal.
|
2020-09-22 16:42:51 +00:00
|
|
|
wp_register_style( 'wc-beta-tester-admin', WC_Beta_Tester::instance()->plugin_url() . '/assets/css/admin.css', array( 'woocommerce_admin_styles' ) );
|
2018-06-06 08:25:27 +00:00
|
|
|
|
2021-02-02 16:45:57 +00:00
|
|
|
// Register scripts.
|
2018-06-06 08:16:28 +00:00
|
|
|
wp_register_script( 'wc-beta-tester-version-info', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-information' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION );
|
2018-06-06 16:26:48 +00:00
|
|
|
wp_register_script( 'wc-beta-tester-version-picker', WC_Beta_Tester::instance()->plugin_url() . '/assets/js/version-picker' . $suffix . '.js', array( 'wc-backbone-modal' ), WC_BETA_TESTER_VERSION );
|
2018-06-06 08:02:45 +00:00
|
|
|
|
|
|
|
wp_localize_script(
|
|
|
|
'wc-beta-tester-version-info',
|
|
|
|
'wc_beta_tester_version_info_params',
|
|
|
|
array(
|
|
|
|
'version' => $version,
|
2018-07-06 18:01:42 +00:00
|
|
|
/* translators: %s: Release version number */
|
|
|
|
'description' => sprintf( __( 'Release of version %s', 'woocommerce-beta-tester' ), $version ),
|
2018-06-06 08:02:45 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2018-06-06 16:26:48 +00:00
|
|
|
wp_localize_script(
|
|
|
|
'wc-beta-tester-version-picker',
|
|
|
|
'wc_beta_tester_version_picker_params',
|
|
|
|
array(
|
2019-03-13 19:54:47 +00:00
|
|
|
'i18n_pick_version' => __( 'Please pick a WooCommerce version.', 'woocommerce-beta-tester' ),
|
2018-06-06 16:26:48 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-09-23 18:26:56 +00:00
|
|
|
if ( in_array( $screen_id, array( 'plugins_page_wc-beta-tester', 'plugins_page_wc-beta-tester-version-picker' ) ) ) {
|
2021-02-02 16:45:57 +00:00
|
|
|
wp_enqueue_style( 'wc-beta-tester-admin' );
|
|
|
|
wp_enqueue_script( 'wc-beta-tester-version-info' );
|
|
|
|
wp_enqueue_script( 'wc-beta-tester-version-picker' );
|
|
|
|
}
|
2018-06-06 08:02:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new WC_Beta_Tester_Admin_Assets();
|