| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Scripts |
| 5 |
*/ |
| 6 |
|
| 7 |
// Exit if accessed directly |
| 8 |
if (!defined('ABSPATH')) exit; |
| 9 |
|
| 10 |
/** |
| 11 |
* Load admin scripts |
| 12 |
* |
| 13 |
* @since 1.0.0 |
| 14 |
* @global string $post_type The type of post that we are editing |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
function woo_ml_admin_scripts($hook) |
| 18 |
{ |
| 19 |
|
| 20 |
wp_enqueue_script('woo-ml-admin-script', WOO_MAILERLITE_URL . 'public/js/admin.js', ['jquery'], WOO_MAILERLITE_VER); |
| 21 |
wp_enqueue_script('style2-script', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js'); |
| 22 |
wp_enqueue_style('woo-ml-admin-style', WOO_MAILERLITE_URL . 'public/css/admin.css', false, WOO_MAILERLITE_VER); |
| 23 |
wp_enqueue_style('style2-style', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css'); |
| 24 |
wp_enqueue_style('style2-mailerlite-style', WOO_MAILERLITE_URL . 'public/css/mailerlite-select2.css', false, WOO_MAILERLITE_VER); |
| 25 |
|
| 26 |
// Ajax |
| 27 |
wp_localize_script('woo-ml-admin-script', 'woo_ml_post', ['ajax_url' => admin_url('admin-ajax.php')]); |
| 28 |
} |
| 29 |
add_action('admin_enqueue_scripts', 'woo_ml_admin_scripts', 100); |
| 30 |
|
| 31 |
function woo_ml_public_scripts() |
| 32 |
{ |
| 33 |
|
| 34 |
if ( ! get_option('ml_account_authenticated') ) { |
| 35 |
|
| 36 |
return false; |
| 37 |
} |
| 38 |
|
| 39 |
wp_enqueue_script('woo-ml-public-script', WOO_MAILERLITE_URL . 'public/js/public.js', ['jquery'], WOO_MAILERLITE_VER); |
| 40 |
wp_localize_script('woo-ml-public-script', 'woo_ml_public_post', ['ajax_url' => admin_url('admin-ajax.php'), 'language' => get_locale()]); |
| 41 |
} |
| 42 |
add_action('wp_enqueue_scripts', 'woo_ml_public_scripts', 100); |