PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 All 30 releases
← All changes | includes/Frontend/Frontend_Assets.php +136 -81 2.0.0 → 2.5.0 View file →
@@ -1,81 +1,136 @@
1 -<?php
2 -namespace Frontend;
3 -
4 -/**
5 - * Class Assets
6 - * @package EazyDocs\Admin
7 - */
8 -class Frontend_Assets {
9 -
10 - /**
11 - * Assets constructor.
12 - */
13 - public function __construct() {
14 - add_action('wp_enqueue_scripts', [$this, 'frontend_scripts'], 999 );
15 - add_action('elementor/widgets/widgets_registered', [$this, 'bbpc_elementor_script'], 999 );
16 - }
17 -
18 - /**
19 - * Register scripts and styles [ ELEMENTOR ]
20 - */
21 - public function bbpc_elementor_script(){
22 - // Elementor widgets scripts
23 - wp_enqueue_style( 'bbpc-el-widgets', FORUMAX_FRONT_ASS . 'css/el-widgets.css' );
24 - wp_enqueue_style( 'elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css' );
25 - wp_register_script( 'bbpc_js', FORUMAX_FRONT_ASS . 'js/forumTab.js', ['jquery'], true, true );
26 - wp_register_script( 'bbpc-frontend-js', FORUMAX_FRONT_ASS . 'js/frontend.js', array('jquery'), FORUMAX_VERSION, true );
27 - wp_register_script( 'bbpc-ajax', FORUMAX_FRONT_ASS . 'js/ajax.js', array('jquery'), FORUMAX_VERSION, true );
28 -
29 - if ( is_rtl() ) {
30 - wp_enqueue_style( 'bbpc-rtl', FORUMAX_FRONT_ASS . 'css/bbpc-main-rtl.css' );
31 - }
32 - }
33 -
34 - /**
35 - * Register scripts and styles [ FRONTEND ]
36 - */
37 - public function frontend_scripts() {
38 -
39 - if ( ! class_exists( 'bbPress' ) || ! class_exists( 'Forumax' ) ) {
40 - return;
41 - }
42 - wp_enqueue_style( 'elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css' );
43 - wp_register_script( 'bbpc-wp-widget', FORUMAX_ASSETS . 'frontend/js/wp-widgets.js', array('jquery'), FORUMAX_VERSION, true );
44 -
45 - // localize script
46 - wp_localize_script( 'jquery', 'forumax_localize_script', array(
47 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
48 - 'nonce' => wp_create_nonce( 'forumax-nonce' ),
49 - 'bbpc_subscribed_link' => wp_kses_post(bbp_get_forum_subscription_link()),
50 - 'bbpc_subscribed_forum_title' => forumax_forum_title(),
51 - 'bbpc_subscribed_forum_id' => bbp_get_forum_id(),
52 - 'bbp_topic_id' => get_the_ID()
53 - ) );
54 -
55 - $dynamic_css = ":root { --bbpc_brand_color: " . forumax_get_opt('bbpc_brand_color') . "; }";
56 - wp_add_inline_style( 'forumax_localize_script', $dynamic_css );
57 -
58 - wp_register_style( 'bbpc', FORUMAX_FRONT_ASS . 'css/bbpc.css' );
59 - wp_register_style( 'bbpc-single', FORUMAX_FRONT_ASS . 'css/forum-single.css' );
60 - wp_register_style( 'bbpc-forum', FORUMAX_FRONT_ASS . 'css/forum.css' );
61 -
62 -
63 - wp_register_script( 'bbpc-voting', FORUMAX_FRONT_ASS . 'voting/bbpc-voting.js', [ 'jquery' ], FORUMAX_VERSION );
64 - wp_register_script( 'forumax-custom', FORUMAX_FRONT_ASS . 'js/custom.js', [ 'jquery' ], FORUMAX_VERSION );
65 - wp_register_script( 'bbp-replies-sorting', FORUMAX_FRONT_ASS . 'js/bbp-replies-sorting.js', [ 'jquery' ], FORUMAX_VERSION );
66 - wp_register_script( 'docy-forum', FORUMAX_FRONT_ASS . 'js/forum.js', [ 'jquery' ], FORUMAX_VERSION );
67 -
68 - if ( class_exists( 'bbPress' ) || class_exists( 'Forumax' ) ) {
69 - wp_enqueue_style( 'bbpc' );
70 - wp_enqueue_style( 'bbpc-single' );
71 - wp_enqueue_style( 'bbpc-forum' );
72 - wp_enqueue_style( 'bbpc-voting', FORUMAX_FRONT_ASS . 'voting/bbpc-voting.css' );
73 -
74 - wp_enqueue_script( 'forumax-custom' );
75 - wp_enqueue_script( 'bbp-replies-sorting' );
76 - wp_enqueue_script( 'docy-forum' );
77 - wp_enqueue_script( 'bbpc-voting' );
78 - }
79 - }
80 -}
81 -
1 +<?php
2 +namespace Frontend;
3 +
4 +/**
5 + * Class Assets
6 + * @package EazyDocs\Admin
7 + */
8 +class Frontend_Assets
9 +{
10 +
11 + /**
12 + * Assets constructor.
13 + */
14 + public function __construct()
15 + {
16 + add_action('wp_enqueue_scripts', [$this, 'frontend_scripts'], 999);
17 + }
18 +
19 + /**
20 + * Register scripts and styles [ FRONTEND ]
21 + */
22 + public function frontend_scripts()
23 + {
24 +
25 + if (!class_exists('bbPress') || !class_exists('Forumax')) {
26 + return;
27 + }
28 +
29 + // Register front-end scripts/styles first so they are available for Gutenberg/Elementor blocks.
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);
32 +
33 + // Always localize 'forumax_localize_script' on 'jquery' (since it is loaded everywhere) if bbPress exists.
34 + // This guarantees that any script requiring these variables won't fail with a ReferenceError.
35 + wp_localize_script('jquery', 'forumax_localize_script', [
36 + 'ajaxurl' => admin_url('admin-ajax.php'),
37 + 'nonce' => wp_create_nonce('forumax-nonce'),
38 + 'bbpc_subscribed_link' => wp_kses_post(bbp_get_forum_subscription_link()),
39 + 'bbpc_subscribed_forum_title' => forumax_forum_title(),
40 + 'bbpc_subscribed_forum_id' => bbp_get_forum_id(),
41 + 'bbp_topic_id' => get_the_ID()
42 + ]);
43 +
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);
46 +
47 + if ( is_rtl() ) {
48 + wp_enqueue_style( 'bbpc-main-rtl', FORUMAX_STYLES . 'frontend/main-rtl.css', [], FORUMAX_VERSION );
49 + }
50 +
51 + if (!function_exists('is_bbpress') || !is_bbpress()) {
52 + return;
53 + }
54 +
55 + wp_enqueue_style('elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css');
56 + wp_register_script('bbpc-wp-widget', FORUMAX_ASSETS . 'frontend/js/wp-widgets.js', ['jquery'], FORUMAX_VERSION, true);
57 +
58 + // Nice Select for frontend (prefixed to avoid conflicts)
59 + wp_register_style('frmx-nice-select', FORUMAX_VEND . 'frmx-nice-select/nice-select.css');
60 + wp_register_script('frmx-nice-select', FORUMAX_VEND . 'frmx-nice-select/jquery.nice-select.min.js', ['jquery'], '1.0', true);
61 +
62 + $bbpc_brand_color = forumax_get_opt('bbpc_brand_color');
63 + if ( ! empty( $bbpc_brand_color ) ) {
64 + $dynamic_css = sprintf(
65 + ':root { --bbpc_brand_color: %s; }',
66 + sanitize_hex_color( $bbpc_brand_color )
67 + );
68 + wp_add_inline_style( 'bbpc-single', $dynamic_css );
69 + }
70 +
71 +
72 + wp_register_script('bbpc-voting', FORUMAX_FRONT_ASS . 'voting/bbpc-voting.js', ['jquery'], FORUMAX_VERSION);
73 + wp_register_script('forumax-custom', FORUMAX_FRONT_ASS . 'js/custom.js', ['jquery'], FORUMAX_VERSION);
74 + wp_register_script('bbp-replies-sorting', FORUMAX_FRONT_ASS . 'js/bbp-replies-sorting.js', ['jquery'], FORUMAX_VERSION);
75 + wp_register_script('docy-forum', FORUMAX_FRONT_ASS . 'js/forum.js', ['jquery'], FORUMAX_VERSION);
76 + wp_register_script('frmx-inline-edit', FORUMAX_FRONT_ASS . 'js/frmx-inline-edit.js', ['jquery'], FORUMAX_VERSION, true);
77 +
78 + wp_enqueue_style('bbpc-single');
79 + wp_enqueue_style('bbpc-forum');
80 + wp_enqueue_style('bbpc-voting', FORUMAX_FRONT_ASS . 'voting/bbpc-voting.css');
81 + wp_enqueue_style('frmx-nice-select');
82 +
83 + wp_enqueue_script('frmx-nice-select');
84 + wp_enqueue_script('forumax-custom');
85 + wp_enqueue_script('bbp-replies-sorting');
86 + wp_enqueue_script('docy-forum');
87 + wp_enqueue_script('bbpc-voting');
88 + wp_enqueue_script('bbpc-frontend');
89 +
90 + // Ensure TinyMCE scripts are queued early on all forumax editor pages
91 + if ( bbp_is_single_topic() || bbp_is_single_forum() || bbp_is_reply_edit() || bbp_is_topic_edit() ) {
92 + wp_enqueue_editor();
93 + }
94 +
95 + // Inline edit — only on single topic pages.
96 + if ( bbp_is_single_topic() ) {
97 +
98 + wp_enqueue_script( 'frmx-inline-edit' );
99 + wp_localize_script( 'frmx-inline-edit', 'frmxInlineEdit', [
100 + 'ajaxurl' => admin_url( 'admin-ajax.php' ),
101 + 'nonce' => wp_create_nonce( 'forumax-nonce' ),
102 + 'topic_id' => bbp_get_topic_id(),
103 + 'i18n' => [
104 + 'edit' => esc_html__( 'Edit', 'forumax' ),
105 + 'save' => esc_html__( 'Save', 'forumax' ),
106 + 'cancel' => esc_html__( 'Cancel', 'forumax' ),
107 + 'saving' => esc_html__( 'Saving…', 'forumax' ),
108 + 'loading' => esc_html__( 'Loading…', 'forumax' ),
109 + 'title_label' => esc_html__( 'Topic Title', 'forumax' ),
110 + 'content_label' => esc_html__( 'Topic Content', 'forumax' ),
111 + 'title_required' => esc_html__( 'Title cannot be empty.', 'forumax' ),
112 + 'content_required' => esc_html__( 'Content cannot be empty.', 'forumax' ),
113 + 'error' => esc_html__( 'Something went wrong. Please try again.', 'forumax' ),
114 + 'editing_reply' => esc_html__( 'Editing reply', 'forumax' ),
115 + 'to_save' => esc_html__( 'to save', 'forumax' ),
116 + 'to_cancel' => esc_html__( 'to cancel', 'forumax' ),
117 + 'unsaved_changes' => esc_html__( 'Unsaved changes', 'forumax' ),
118 + 'discard_confirm' => esc_html__( 'Discard unsaved changes?', 'forumax' ),
119 + 'discard' => esc_html__( 'Discard', 'forumax' ),
120 + 'keep_editing' => esc_html__( 'Keep editing', 'forumax' ),
121 + ],
122 + ] );
123 + }
124 +
125 +
126 + // User page styles
127 + if ( function_exists( 'bbp_is_single_user' ) ) {
128 + if ( bbp_is_single_user() || bbp_is_favorites() || bbp_is_subscriptions() || bbp_is_single_user_engagements() || bbp_is_single_user_topics() || bbp_is_single_user_replies() || bbp_is_single_user_edit() || bbp_is_single_user_profile() ) {
129 + wp_enqueue_style('bbpc-forum-user', FORUMAX_STYLES . 'frontend/forum-user.css');
130 + }
131 + }
132 +
133 + }
134 +}
135 +
136 +