| @@ -13,26 +13,11 @@ | ||
| 13 | 13 | */ |
| 14 | 14 | public function __construct() |
| 15 | 15 | { |
| 16 | 16 | add_action('wp_enqueue_scripts', [$this, 'frontend_scripts'], 999); |
| 17 | - add_action('elementor/widgets/widgets_registered', [$this, 'bbpc_elementor_script'], 999); | |
| 18 | - | |
| 19 | 17 | } |
| 20 | 18 | |
| 21 | 19 | /** |
| 22 | - * Register scripts and styles [ ELEMENTOR ] | |
| 23 | - */ | |
| 24 | - public function bbpc_elementor_script() | |
| 25 | - { | |
| 26 | - // Elementor widgets scripts | |
| 27 | - wp_enqueue_style('bbpc-el-widgets', FORUMAX_STYLES . 'frontend/el-widgets.css', array(), FORUMAX_VERSION); | |
| 28 | - wp_enqueue_style('elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css'); | |
| 29 | - wp_register_script('bbpc_js', FORUMAX_FRONT_ASS . 'js/forumTab.js', ['jquery'], true, true); | |
| 30 | - wp_register_script('bbpc-frontend-js', FORUMAX_FRONT_ASS . 'js/frontend.js', array('jquery'), FORUMAX_VERSION, true); | |
| 31 | - wp_register_script('bbpc-ajax', FORUMAX_FRONT_ASS . 'js/ajax.js', array('jquery'), FORUMAX_VERSION, true); | |
| 32 | - } | |
| 33 | - | |
| 34 | - /** | |
| 35 | 20 | * Register scripts and styles [ FRONTEND ] |
| 36 | 21 | */ |
| 37 | 22 | public function frontend_scripts() |
| 38 | 23 | { |
| @@ -41,14 +26,14 @@ | ||
| 41 | 26 | return; |
| 42 | 27 | } |
| 43 | 28 | |
| 44 | 29 | // Register front-end scripts/styles first so they are available for Gutenberg/Elementor blocks. |
| 45 | - wp_register_script('bbpc-ajax', FORUMAX_FRONT_ASS . 'js/ajax.js', array('jquery'), FORUMAX_VERSION, true); | |
| 46 | - wp_register_script('bbpc-frontend-js', FORUMAX_FRONT_ASS . 'js/frontend.js', array('jquery'), FORUMAX_VERSION, true); | |
| 30 | + wp_register_script('bbpc-ajax', FORUMAX_FRONT_ASS . 'js/ajax.js', ['jquery'], FORUMAX_VERSION, true); | |
| 31 | + wp_register_script('bbpc-frontend', FORUMAX_FRONT_ASS . 'js/frontend.js', ['jquery'], FORUMAX_VERSION, true); | |
| 47 | 32 | |
| 48 | 33 | // Always localize 'forumax_localize_script' on 'jquery' (since it is loaded everywhere) if bbPress exists. |
| 49 | 34 | // This guarantees that any script requiring these variables won't fail with a ReferenceError. |
| 50 | - wp_localize_script('jquery', 'forumax_localize_script', array( | |
| 35 | + wp_localize_script('jquery', 'forumax_localize_script', [ | |
| 51 | 36 | 'ajaxurl' => admin_url('admin-ajax.php'), |
| 52 | 37 | 'nonce' => wp_create_nonce('forumax-nonce'), |
| 53 | 38 | 'bbpc_subscribed_link' => wp_kses_post(bbp_get_forum_subscription_link()), |
| 54 | 39 | 'bbpc_subscribed_forum_title' => forumax_forum_title(), |
| @@ -53,23 +38,27 @@ | ||
| 53 | 38 | 'bbpc_subscribed_link' => wp_kses_post(bbp_get_forum_subscription_link()), |
| 54 | 39 | 'bbpc_subscribed_forum_title' => forumax_forum_title(), |
| 55 | 40 | 'bbpc_subscribed_forum_id' => bbp_get_forum_id(), |
| 56 | 41 | 'bbp_topic_id' => get_the_ID() |
| 57 | - )); | |
| 42 | + ]); | |
| 58 | 43 | |
| 59 | - wp_register_style('bbpc-single', FORUMAX_STYLES . 'frontend/forum-single.css', array(), FORUMAX_VERSION); | |
| 60 | - wp_register_style('bbpc-forum', FORUMAX_STYLES . 'frontend/forum.css', array(), FORUMAX_VERSION); | |
| 44 | + wp_register_style('bbpc-single', FORUMAX_STYLES . 'frontend/forum-single.css', [], FORUMAX_VERSION); | |
| 45 | + wp_register_style('bbpc-forum', FORUMAX_STYLES . 'frontend/forum.css', [], FORUMAX_VERSION); | |
| 61 | 46 | |
| 47 | + if ( is_rtl() ) { | |
| 48 | + wp_enqueue_style( 'bbpc-main-rtl', FORUMAX_STYLES . 'frontend/main-rtl.css', [], FORUMAX_VERSION ); | |
| 49 | + } | |
| 50 | + | |
| 62 | 51 | if (!function_exists('is_bbpress') || !is_bbpress()) { |
| 63 | 52 | return; |
| 64 | 53 | } |
| 65 | 54 | |
| 66 | 55 | wp_enqueue_style('elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css'); |
| 67 | - wp_register_script('bbpc-wp-widget', FORUMAX_ASSETS . 'frontend/js/wp-widgets.js', array('jquery'), FORUMAX_VERSION, true); | |
| 56 | + wp_register_script('bbpc-wp-widget', FORUMAX_ASSETS . 'frontend/js/wp-widgets.js', ['jquery'], FORUMAX_VERSION, true); | |
| 68 | 57 | |
| 69 | 58 | // Nice Select for frontend (prefixed to avoid conflicts) |
| 70 | 59 | wp_register_style('frmx-nice-select', FORUMAX_VEND . 'frmx-nice-select/nice-select.css'); |
| 71 | - wp_register_script('frmx-nice-select', FORUMAX_VEND . 'frmx-nice-select/jquery.nice-select.min.js', array('jquery'), '1.0', true); | |
| 60 | + wp_register_script('frmx-nice-select', FORUMAX_VEND . 'frmx-nice-select/jquery.nice-select.min.js', ['jquery'], '1.0', true); | |
| 72 | 61 | |
| 73 | 62 | $bbpc_brand_color = forumax_get_opt('bbpc_brand_color'); |
| 74 | 63 | if ( ! empty( $bbpc_brand_color ) ) { |
| 75 | 64 | $dynamic_css = sprintf( |
| @@ -95,9 +84,9 @@ | ||
| 95 | 84 | wp_enqueue_script('forumax-custom'); |
| 96 | 85 | wp_enqueue_script('bbp-replies-sorting'); |
| 97 | 86 | wp_enqueue_script('docy-forum'); |
| 98 | 87 | wp_enqueue_script('bbpc-voting'); |
| 99 | - wp_enqueue_script('bbpc-frontend-js'); | |
| 88 | + wp_enqueue_script('bbpc-frontend'); | |
| 100 | 89 | |
| 101 | 90 | // Ensure TinyMCE scripts are queued early on all forumax editor pages |
| 102 | 91 | if ( bbp_is_single_topic() || bbp_is_single_forum() || bbp_is_reply_edit() || bbp_is_topic_edit() ) { |
| 103 | 92 | wp_enqueue_editor(); |
| @@ -106,13 +95,13 @@ | ||
| 106 | 95 | // Inline edit — only on single topic pages. |
| 107 | 96 | if ( bbp_is_single_topic() ) { |
| 108 | 97 | |
| 109 | 98 | wp_enqueue_script( 'frmx-inline-edit' ); |
| 110 | - wp_localize_script( 'frmx-inline-edit', 'frmxInlineEdit', array( | |
| 99 | + wp_localize_script( 'frmx-inline-edit', 'frmxInlineEdit', [ | |
| 111 | 100 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 112 | 101 | 'nonce' => wp_create_nonce( 'forumax-nonce' ), |
| 113 | 102 | 'topic_id' => bbp_get_topic_id(), |
| 114 | - 'i18n' => array( | |
| 103 | + 'i18n' => [ | |
| 115 | 104 | 'edit' => esc_html__( 'Edit', 'forumax' ), |
| 116 | 105 | 'save' => esc_html__( 'Save', 'forumax' ), |
| 117 | 106 | 'cancel' => esc_html__( 'Cancel', 'forumax' ), |
| 118 | 107 | 'saving' => esc_html__( 'Saving…', 'forumax' ), |
| @@ -128,10 +117,10 @@ | ||
| 128 | 117 | 'unsaved_changes' => esc_html__( 'Unsaved changes', 'forumax' ), |
| 129 | 118 | 'discard_confirm' => esc_html__( 'Discard unsaved changes?', 'forumax' ), |
| 130 | 119 | 'discard' => esc_html__( 'Discard', 'forumax' ), |
| 131 | 120 | 'keep_editing' => esc_html__( 'Keep editing', 'forumax' ), |
| 132 | - ), | |
| 133 | - ) ); | |
| 121 | + ], | |
| 122 | + ] ); | |
| 134 | 123 | } |
| 135 | 124 | |
| 136 | 125 | |
| 137 | 126 | // User page styles |
| @@ -140,11 +129,8 @@ | ||
| 140 | 129 | wp_enqueue_style('bbpc-forum-user', FORUMAX_STYLES . 'frontend/forum-user.css'); |
| 141 | 130 | } |
| 142 | 131 | } |
| 143 | 132 | |
| 144 | - if (is_rtl()) { | |
| 145 | - wp_enqueue_style('bbpc-rtl', FORUMAX_STYLES . 'frontend/bbpc-main-rtl.css'); | |
| 146 | - } | |
| 147 | 133 | } |
| 148 | 134 | } |
| 149 | 135 | |
| 150 | 136 | |