| 1 |
<?php |
| 2 |
namespace Frontend; |
| 3 |
|
| 4 |
/** |
| 5 |
* Class Assets |
| 6 |
* @package EazyDocs\Admin |
| 7 |
*/ |
| 8 |
class 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', BBPC_FRONT_ASS . 'css/el-widgets.css' ); |
| 24 |
wp_enqueue_style( 'elegant-icon', BBPC_VEND . 'elegant-icon/style.css' ); |
| 25 |
wp_register_script( 'bbpc_js', BBPC_FRONT_ASS . 'js/forumTab.js', ['jquery'], true, true ); |
| 26 |
wp_register_script( 'bbpc-frontend-js', BBPC_FRONT_ASS . 'js/frontend.js', array('jquery'), BBPC_VERSION, true ); |
| 27 |
wp_register_script( 'bbpc-ajax', BBPC_FRONT_ASS . 'js/ajax.js', array('jquery'), BBPC_VERSION, true ); |
| 28 |
|
| 29 |
if ( is_rtl() ) { |
| 30 |
wp_enqueue_style( 'bbpc-rtl', BBPC_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' ) ) { |
| 40 |
return; |
| 41 |
} |
| 42 |
|
| 43 |
wp_register_script( 'bbpc-wp-widget', BBPC_ASSETS . 'frontend/js/wp-widgets.js', array('jquery'), BBPC_VERSION, true ); |
| 44 |
|
| 45 |
// localize script |
| 46 |
wp_localize_script( 'jquery', 'bbpc_localize_script', array( |
| 47 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 48 |
'nonce' => wp_create_nonce( 'bbpc-nonce' ), |
| 49 |
'bbpc_subscribed_link' => wp_kses_post(bbp_get_forum_subscription_link()), |
| 50 |
'bbpc_subscribed_forum_title' => bbpc_forum_title(), |
| 51 |
'bbpc_subscribed_forum_id' => bbp_get_forum_id() |
| 52 |
) ); |
| 53 |
|
| 54 |
$dynamic_css = ":root { --bbpc_brand_color: " . bbpc_get_opt('bbpc_brand_color') . "; }"; |
| 55 |
wp_add_inline_style( 'bbpc_localize_script', $dynamic_css ); |
| 56 |
|
| 57 |
wp_register_script( 'bbpc-voting', BBPC_FRONT_ASS . 'voting/bbpc-voting.js', [ 'jquery' ], BBPC_VERSION ); |
| 58 |
wp_register_style( 'bbpc', BBPC_FRONT_ASS . 'css/bbpc.css' ); |
| 59 |
|
| 60 |
if ( class_exists( 'bbPress' ) && bbpc_forum_and_topic_page() ) { |
| 61 |
wp_enqueue_style( 'bbpc' ); |
| 62 |
wp_enqueue_style( 'bbpc-voting', BBPC_FRONT_ASS . 'voting/bbpc-voting.css' ); |
| 63 |
wp_enqueue_script( 'bbpc-voting' ); |
| 64 |
} |
| 65 |
} |
| 66 |
} |