| 1 |
<?php |
| 2 |
|
| 3 |
namespace WP_Social; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
|
| 7 |
class Plugin { |
| 8 |
|
| 9 |
private static $instance; |
| 10 |
|
| 11 |
|
| 12 |
public static function instance() { |
| 13 |
if(!self::$instance) { |
| 14 |
self::$instance = new static(); |
| 15 |
} |
| 16 |
|
| 17 |
return self::$instance; |
| 18 |
} |
| 19 |
|
| 20 |
public function __construct() { |
| 21 |
|
| 22 |
} |
| 23 |
|
| 24 |
public function enqueue() { |
| 25 |
|
| 26 |
add_action( 'admin_enqueue_scripts', [$this, 'load_admin_scripts'] ); |
| 27 |
|
| 28 |
add_action( 'wp_enqueue_scripts', [$this, 'load_public_scripts'] ); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
public function load_admin_scripts() { |
| 33 |
|
| 34 |
wp_register_script( 'wslu_admin', WSLU_LOGIN_PLUGIN_URL. 'assets/js/admin-main.js', array('jquery', 'jquery-ui-sortable')); |
| 35 |
wp_register_script( 'xs_login_custom_js1', WSLU_LOGIN_PLUGIN_URL. 'assets/js/admin-login-custom.js', array('jquery')); |
| 36 |
wp_register_script( 'wp_social_select2_js', WSLU_LOGIN_PLUGIN_URL. 'assets/select2/script/select2-min.js', array('jquery')); |
| 37 |
wp_register_script( 'wp_social_sortable_js', WSLU_LOGIN_PLUGIN_URL. 'assets/js/sortable.min.js', array('jquery')); |
| 38 |
|
| 39 |
|
| 40 |
wp_localize_script('xs_login_custom_js1', 'rest_api_conf', array( |
| 41 |
'siteurl' => get_option('siteurl'), |
| 42 |
'nonce' => wp_create_nonce('wp_rest'), |
| 43 |
'root' => get_rest_url(), |
| 44 |
)); |
| 45 |
|
| 46 |
wp_localize_script('wslu_admin', 'wsluAdminObj', [ |
| 47 |
'resturl' => get_rest_url(), |
| 48 |
'rest_nonce' => wp_create_nonce('wp_rest'), |
| 49 |
]); |
| 50 |
|
| 51 |
wp_enqueue_script( 'xs_login_custom_js1' ); |
| 52 |
wp_enqueue_script( 'wp_social_select2_js' ); |
| 53 |
wp_enqueue_script( 'wp_social_sortable_js' ); |
| 54 |
wp_enqueue_script( 'wslu_admin' ); |
| 55 |
|
| 56 |
|
| 57 |
wp_register_style( 'xs_login_custom_css1', WSLU_LOGIN_PLUGIN_URL. 'assets/css/admin-login-custom.css'); |
| 58 |
wp_register_style( 'wp_social_select2_css', WSLU_LOGIN_PLUGIN_URL. 'assets/select2/css/select2-min.css'); |
| 59 |
wp_register_style( 'xs_login_custom_css_icon', WSLU_LOGIN_PLUGIN_URL. 'assets/css/font-icon.css'); |
| 60 |
wp_register_style( 'xs_login_custom_css2', WSLU_LOGIN_PLUGIN_URL. 'assets/css/admin-style.css'); |
| 61 |
wp_register_style( 'xs_login_custom_css3', WSLU_LOGIN_PLUGIN_URL. 'assets/css/admin-responsive.css'); |
| 62 |
|
| 63 |
wp_enqueue_style( 'xs_login_custom_css1' ); |
| 64 |
wp_enqueue_style( 'wp_social_select2_css' ); |
| 65 |
wp_enqueue_style( 'xs_login_custom_css2' ); |
| 66 |
wp_enqueue_style( 'xs_login_custom_css3' ); |
| 67 |
wp_enqueue_style( 'xs_login_custom_css_icon' ); |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
public function load_public_scripts() { |
| 72 |
|
| 73 |
wp_register_script( 'xs_social_custom', WSLU_LOGIN_PLUGIN_URL. 'assets/js/social-front.js', array('jquery')); |
| 74 |
|
| 75 |
wp_localize_script('xs_social_custom', 'rest_api_conf', array( |
| 76 |
'siteurl' => get_option('siteurl'), |
| 77 |
'nonce' => wp_create_nonce('wp_rest'), |
| 78 |
'root' => get_rest_url(), |
| 79 |
)); |
| 80 |
|
| 81 |
wp_localize_script('xs_social_custom', 'wsluFrontObj', [ |
| 82 |
'resturl' => get_rest_url(), |
| 83 |
'rest_nonce' => wp_create_nonce('wp_rest'), |
| 84 |
]); |
| 85 |
|
| 86 |
wp_enqueue_script( 'xs_social_custom' ); |
| 87 |
} |
| 88 |
} |
| 89 |
|