| 1 |
<?php |
| 2 |
namespace Admin; |
| 3 |
|
| 4 |
/** |
| 5 |
* Class Assets |
| 6 |
* @package Forumax_Pro\Admin |
| 7 |
*/ |
| 8 |
class Admin_Assets { |
| 9 |
/** |
| 10 |
* Assets constructor. |
| 11 |
*/ |
| 12 |
public function __construct() { |
| 13 |
add_action('admin_enqueue_scripts', [$this, 'admin_scripts'], 999); |
| 14 |
} |
| 15 |
|
| 16 |
public function admin_scripts() { |
| 17 |
wp_enqueue_style( 'bbpc-admin-notice', FORUMAX_ASSETS . 'admin/css/admin/admin-noticies.css' ); |
| 18 |
wp_register_style( 'bbpc-admin', FORUMAX_ASSETS . 'admin/css/bbpc-admin.css' ); |
| 19 |
|
| 20 |
wp_register_style( 'sweetalert', FORUMAX_VEND . 'sweetalert/sweetalert.css' ); |
| 21 |
wp_register_script( 'sweetalert', FORUMAX_VEND. 'sweetalert/sweetalert.min.js', [ 'jquery' ], '1.0', true ); |
| 22 |
|
| 23 |
wp_register_script( 'bbpc-notify-review', FORUMAX_ASSETS . 'admin/js/review.js', array( 'jquery' ), FORUMAX_VERSION, true ); |
| 24 |
|
| 25 |
if ( forumax_admin_pages('admin') ) { |
| 26 |
wp_enqueue_style( 'bbpc-admin' ); |
| 27 |
wp_enqueue_style( 'nice-select', FORUMAX_VEND . 'nice-select/nice-select.css' ); |
| 28 |
wp_enqueue_style( 'bbpc-admin-ui', FORUMAX_ADMIN_ASS . 'css/admin-ui-style.css' ); |
| 29 |
wp_enqueue_style( 'sweetalert' ); |
| 30 |
|
| 31 |
// Scripts. |
| 32 |
wp_enqueue_script( 'jquery-ui', FORUMAX_ADMIN_ASS . 'js/jquery-ui.js', [ 'jquery' ], '1.12.1', true ); |
| 33 |
wp_enqueue_script( 'mixitup', FORUMAX_VEND . 'mixitup/mixitup.min.js', [ 'jquery' ], '3.3.1', true ); |
| 34 |
wp_enqueue_script( 'mixitup-multifilter', FORUMAX_VEND . 'mixitup/mixitup-multifilter.js', [ 'jquery' ], '3.3.1', true ); |
| 35 |
wp_enqueue_script( 'mixitup-pagination', FORUMAX_VEND . 'mixitup/mixitup-pagination.min.js', [ 'jquery' ], '3.3.2', true ); |
| 36 |
wp_enqueue_script( 'jquery-nice-select', FORUMAX_VEND . 'nice-select/jquery.nice-select.min.js', [ 'jquery' ], '1.0', true ); |
| 37 |
wp_enqueue_script( 'tabby-polyfills', FORUMAX_ADMIN_ASS . 'js/tabby.polyfills.min.js', [ 'jquery' ], '1.0', true ); |
| 38 |
wp_enqueue_script( 'sortable', FORUMAX_ADMIN_ASS . 'js/Sortable.min.js', [ 'jquery' ], '1.0', true ); |
| 39 |
wp_enqueue_script( 'accordion', FORUMAX_ADMIN_ASS . 'js/accordion.min.js', [ 'jquery' ], '1.0', true ); |
| 40 |
wp_enqueue_script( 'bbpc-admin-main', FORUMAX_ADMIN_ASS . 'js/admin-main.js', [ 'jquery' ], '1.0', true ); |
| 41 |
wp_enqueue_script( 'sweetalert' ); |
| 42 |
} |
| 43 |
|
| 44 |
if ( forumax_admin_pages('settings') ) { |
| 45 |
wp_enqueue_style( 'bbpc-admin' ); |
| 46 |
wp_enqueue_style( 'sweetalert' ); |
| 47 |
wp_enqueue_script( 'sweetalert' ); |
| 48 |
wp_enqueue_script( 'bbpc-admin-global', FORUMAX_ADMIN_ASS . 'js/admin-global.js', FORUMAX_VERSION ); |
| 49 |
} |
| 50 |
|
| 51 |
if ( forumax_admin_pages('settings') ) { |
| 52 |
wp_deregister_style('csf-fa5'); |
| 53 |
wp_deregister_style('csf-fa5-v4-shims'); |
| 54 |
} |
| 55 |
|
| 56 |
// Localize the script with new data |
| 57 |
$ajax_url = admin_url('admin-ajax.php'); |
| 58 |
$wpml_current_language = apply_filters('wpml_current_language', null); |
| 59 |
|
| 60 |
if ( !empty($wpml_current_language) ) { |
| 61 |
$ajax_url = add_query_arg('wpml_lang', $wpml_current_language, $ajax_url); |
| 62 |
} |
| 63 |
|
| 64 |
wp_localize_script( 'jquery', 'forumax_local_object', [ |
| 65 |
'ajaxurl' => esc_url( $ajax_url ), |
| 66 |
'create_forum_title' => esc_html__( 'Enter Forum Title', 'forumax' ), |
| 67 |
'create_topic_title' => esc_html__( 'Enter Topic Title', 'forumax' ), |
| 68 |
'forum_delete_title' => esc_html__( 'Are you sure to delete?', 'forumax' ), |
| 69 |
'forum_delete_desc' => esc_html__( "This forum will be deleted with all the topics and you won't be able to revert!", 'forumax' ), |
| 70 |
'topic_delete_desc' => esc_html__( "This topic will be deleted and you won't be able to revert!", 'forumax' ), |
| 71 |
'forumax_assets' => FORUMAX_ASSETS, |
| 72 |
'nonce' => wp_create_nonce('bbpc-admin-nonce') |
| 73 |
] |
| 74 |
); |
| 75 |
} |
| 76 |
} |