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