wp-social
Last commit date
app
3 years ago
assets
3 years ago
base
5 years ago
helper
3 years ago
inc
3 years ago
languages
3 years ago
lib
3 years ago
template
3 years ago
traits
5 years ago
xs_migration
3 years ago
autoload.php
5 years ago
instruction.txt
4 years ago
keys.php
4 years ago
phpcs.xml
3 years ago
plugin.php
4 years ago
readme.txt
2 years ago
wp-social.php
3 years ago
plugin.php
113 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Social; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | class Plugin { |
| 8 | |
| 9 | private static $instance; |
| 10 | |
| 11 | public static function instance() { |
| 12 | if(!self::$instance) { |
| 13 | self::$instance = new static(); |
| 14 | } |
| 15 | |
| 16 | return self::$instance; |
| 17 | } |
| 18 | |
| 19 | public function plugin_url() { |
| 20 | |
| 21 | return trailingslashit(plugin_dir_url(__FILE__)); |
| 22 | } |
| 23 | |
| 24 | public function plugin_dir() { |
| 25 | |
| 26 | return trailingslashit(plugin_dir_path(__FILE__)); |
| 27 | } |
| 28 | |
| 29 | public function lib_url() { |
| 30 | |
| 31 | return $this->plugin_url() . 'lib/'; |
| 32 | } |
| 33 | |
| 34 | public function lib_dir() { |
| 35 | |
| 36 | return $this->plugin_dir() . 'lib/'; |
| 37 | } |
| 38 | |
| 39 | public function account_url(){ |
| 40 | return 'https://account.wpmet.com'; |
| 41 | } |
| 42 | |
| 43 | public function package_type() { |
| 44 | return apply_filters( 'wp-social/core/package_type', 'free'); |
| 45 | } |
| 46 | |
| 47 | public function enqueue() { |
| 48 | |
| 49 | add_action( 'admin_enqueue_scripts', [$this, 'load_admin_scripts'] ); |
| 50 | |
| 51 | add_action( 'wp_enqueue_scripts', [$this, 'load_public_scripts'] ); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | public function load_admin_scripts() { |
| 56 | wp_enqueue_style( 'wps-wp-dashboard', WSLU_LOGIN_PLUGIN_URL . 'assets/css/wps-wp-dashboard.css', [], WSLU_VERSION ); |
| 57 | |
| 58 | wp_register_script( 'wslu_admin', WSLU_LOGIN_PLUGIN_URL. 'assets/js/admin-main.js', array('jquery', 'jquery-ui-sortable')); |
| 59 | wp_register_script( 'xs_login_custom_js1', WSLU_LOGIN_PLUGIN_URL. 'assets/js/admin-login-custom.js', array('jquery')); |
| 60 | wp_register_script( 'wp_social_select2_js', WSLU_LOGIN_PLUGIN_URL. 'assets/select2/script/select2-min.js', array('jquery')); |
| 61 | wp_register_script( 'wp_social_sortable_js', WSLU_LOGIN_PLUGIN_URL. 'assets/js/sortable.min.js', array('jquery')); |
| 62 | |
| 63 | |
| 64 | wp_localize_script('xs_login_custom_js1', 'rest_api_conf', array( |
| 65 | 'siteurl' => get_option('siteurl'), |
| 66 | 'nonce' => wp_create_nonce('wp_rest'), |
| 67 | 'root' => get_rest_url(), |
| 68 | )); |
| 69 | |
| 70 | wp_localize_script('wslu_admin', 'wsluAdminObj', [ |
| 71 | 'resturl' => get_rest_url(), |
| 72 | 'rest_nonce' => wp_create_nonce('wp_rest'), |
| 73 | ]); |
| 74 | |
| 75 | wp_enqueue_script( 'xs_login_custom_js1' ); |
| 76 | wp_enqueue_script( 'wp_social_select2_js' ); |
| 77 | wp_enqueue_script( 'wp_social_sortable_js' ); |
| 78 | wp_enqueue_script( 'wslu_admin' ); |
| 79 | |
| 80 | |
| 81 | wp_register_style( 'xs_login_custom_css1', WSLU_LOGIN_PLUGIN_URL. 'assets/css/admin-login-custom.css'); |
| 82 | wp_register_style( 'wp_social_select2_css', WSLU_LOGIN_PLUGIN_URL. 'assets/select2/css/select2-min.css'); |
| 83 | wp_register_style( 'xs_login_custom_css_icon', WSLU_LOGIN_PLUGIN_URL. 'assets/css/font-icon.css'); |
| 84 | wp_register_style( 'xs_login_custom_css2', WSLU_LOGIN_PLUGIN_URL. 'assets/css/admin.css'); |
| 85 | wp_register_style( 'xs_login_custom_css3', WSLU_LOGIN_PLUGIN_URL. 'assets/css/admin-responsive.css'); |
| 86 | |
| 87 | wp_enqueue_style( 'xs_login_custom_css1' ); |
| 88 | wp_enqueue_style( 'wp_social_select2_css' ); |
| 89 | wp_enqueue_style( 'xs_login_custom_css2' ); |
| 90 | wp_enqueue_style( 'xs_login_custom_css3' ); |
| 91 | wp_enqueue_style( 'xs_login_custom_css_icon' ); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | public function load_public_scripts() { |
| 96 | |
| 97 | wp_register_script( 'xs_social_custom', WSLU_LOGIN_PLUGIN_URL. 'assets/js/social-front.js', array('jquery')); |
| 98 | |
| 99 | wp_localize_script('xs_social_custom', 'rest_api_conf', array( |
| 100 | 'siteurl' => get_option('siteurl'), |
| 101 | 'nonce' => wp_create_nonce('wp_rest'), |
| 102 | 'root' => get_rest_url(), |
| 103 | )); |
| 104 | |
| 105 | wp_localize_script('xs_social_custom', 'wsluFrontObj', [ |
| 106 | 'resturl' => get_rest_url(), |
| 107 | 'rest_nonce' => wp_create_nonce('wp_rest'), |
| 108 | ]); |
| 109 | |
| 110 | wp_enqueue_script( 'xs_social_custom' ); |
| 111 | } |
| 112 | } |
| 113 |