'forumax',
'title' => __( 'Forumax', 'forumax' ),
],
]
);
}
/**
* Enqueue assets for the Gutenberg block editor
* This ensures the AJAX URL is available for block scripts
*/
public function enqueue_editor_assets() {
$is_pro_active = class_exists( 'Forumax_Pro' );
wp_localize_script( 'wp-edit-post', 'bbpc_editor_config', [
'ajaxurl' => admin_url( 'admin-ajax.php' ),
] );
wp_localize_script( 'wp-edit-post', 'bbpc_upsell_config', [
'is_pro_active' => $is_pro_active,
'upsell_image_url' => defined( 'FORUMAX_IMG' ) ? FORUMAX_IMG . 'upsell-forum-ajax.png' : '',
'upgrade_url' => admin_url( 'admin.php?page=forumax-pricing' ),
] );
}
public function blocks_init() {
register_block_type( __DIR__ . '/../../build/forum-posts', [
'render_callback' => [ $this, 'render_forum_posts' ],
] );
register_block_type( __DIR__ . '/../../build/forum-tab', [
'render_callback' => [ $this, 'render_forum_tab' ],
] );
register_block_type( __DIR__ . '/../../build/forums', [
'render_callback' => [ $this, 'render_forums' ],
] );
register_block_type( __DIR__ . '/../../build/search', [
'render_callback' => [ $this, 'render_search' ],
] );
register_block_type( __DIR__ . '/../../build/single-forum', [
'render_callback' => [ $this, 'render_single_forum' ],
] );
register_block_type( __DIR__ . '/../../build/forum-ajax', [
'render_callback' => [ $this, 'render_forum_ajax' ],
] );
}
public function render_forum_posts( $attributes, $content ) {
if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) {
if ( defined( 'FORUMAX_FRONT_ASS' ) ) {
wp_register_style( 'bbpc-el-widgets', FORUMAX_FRONT_ASS . 'css/el-widgets.css' );
}
}
if ( ! wp_style_is( 'elegant-icon', 'registered' ) ) {
wp_register_style( 'elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css' );
}
wp_enqueue_style( 'bbpc-el-widgets' );
wp_enqueue_style( 'elegant-icon' );
$ppp = isset( $attributes['ppp'] ) ? $attributes['ppp'] : 5;
$order = isset( $attributes['order'] ) ? $attributes['order'] : 'ASC';
$show_meta = isset( $attributes['show_meta'] ) ? $attributes['show_meta'] : true;
$title_color = isset( $attributes['title_color'] ) ? $attributes['title_color'] : '';
$meta_color = isset( $attributes['meta_color'] ) ? $attributes['meta_color'] : '';
$bg_color = isset( $attributes['bg_color'] ) ? $attributes['bg_color'] : '';
$unique_id = uniqid( 'bbpc-forum-posts-' );
$forum_posts = new WP_Query( array(
'post_type' => 'topic',
'posts_per_page' => $ppp,
'order' => $order,
) );
$wrapper_attributes = get_block_wrapper_attributes( [
'class' => 'community-posts-wrapper',
'id' => $unique_id,
] );
ob_start();
?>
>
have_posts() ) : $forum_posts->the_post();
$favoriters = bbp_get_topic_favoriters();
$favorite_count = ! empty( $favoriters ) ? $favoriters[0] : '0';
?>
'forum',
'posts_per_page' => $ppp,
'order' => $order,
) );
$topics = new WP_Query( array(
'post_type' => 'topic',
'posts_per_page' => $ppp2,
'order' => $order2,
) );
$unique_id = uniqid();
$this_get_id = $unique_id;
// Enqueue styles/scripts for forum tab (ensure script is available on frontend)
if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) {
wp_register_style( 'bbpc-el-widgets', FORUMAX_FRONT_ASS . 'css/el-widgets.css' );
}
if ( ! wp_style_is( 'elegant-icon', 'registered' ) ) {
wp_register_style( 'elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css' );
}
if ( ! wp_script_is( 'bbpc_js', 'registered' ) ) {
wp_register_script( 'bbpc_js', FORUMAX_FRONT_ASS . 'js/forumTab.js', array( 'jquery' ), FORUMAX_VERSION, true );
}
wp_enqueue_style( 'bbpc-el-widgets' );
wp_enqueue_style( 'elegant-icon' );
wp_enqueue_script( 'bbpc_js' );
ob_start();
?>
'forum',
'posts_per_page' => $ppp,
'order' => $order,
) );
ob_start();
?>
have_posts() ) : $forums->the_post();
?>
'forum',
'posts_per_page' => $ppp2,
'offset' => $ppp,
'order' => $order,
) );
while ( $forums2->have_posts() ) : $forums2->the_post();
?>
'fas fa-search', 'library' => 'solid' ];
$is_keywords = isset( $attributes['is_keywords'] ) ? $attributes['is_keywords'] : true;
$keywords_label = isset( $attributes['keywords_label'] ) ? $attributes['keywords_label'] : 'Popular:';
$keywords_align = isset( $attributes['keywords_align'] ) ? $attributes['keywords_align'] : 'center';
$keywords = isset( $attributes['keywords'] ) ? $attributes['keywords'] : [ [ 'title' => 'Keyword #1' ], [ 'title' => 'Keyword #2' ] ];
$unique_id = uniqid( 'bbpc-search-' );
$cross_position = $submit_btn_align == 'right' ? 'left' : 'right';
// Include dependencies
if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) {
wp_register_style( 'bbpc-el-widgets', FORUMAX_FRONT_ASS . 'css/el-widgets.css' );
}
wp_enqueue_style( 'bbpc-el-widgets' );
wp_enqueue_script( 'bbpc-frontend-js', FORUMAX_FRONT_ASS . 'js/frontend.js', array( 'jquery' ), FORUMAX_VERSION, true );
$wrapper_attributes = get_block_wrapper_attributes( [
'id' => $unique_id,
] );
ob_start();
?>
url) ) {
$url = $cover_image->url;
}
$post_thumbnail_url = !empty($url) ? $url : get_the_post_thumbnail_url($forum_id);
$topics = new \WP_Query(array(
'post_type' => bbp_get_topic_post_type(),
'order' => !empty($settings['order']) ? $settings['order'] : 'DESC',
'posts_per_page' => !empty($settings['ppp']) ? $settings['ppp'] : 3,
'post_parent' => $forum_id,
));
$unique_id = uniqid('bbpc-single-forum-');
if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) {
wp_register_style( 'bbpc-el-widgets', FORUMAX_FRONT_ASS . 'css/el-widgets.css' );
}
wp_enqueue_style( 'bbpc-el-widgets' );
ob_start();
echo '';
if ($forum_id) {
$template_path = __DIR__ . '/../Elementor/inc/single-forum/single-forum-' . $settings['style'] . '.php';
if ( file_exists( $template_path ) ) {
include $template_path;
}
} else {
?>
';
?>
";
if ( $forum_title_color ) {
$style .= "#{$unique_id} .single-forum-post-widget .post-title a { color: {$forum_title_color}; }";
}
if ( $forum_title_hover_color ) {
$style .= "#{$unique_id} .single-forum-post-widget .post-title a:hover { color: {$forum_title_hover_color}; }";
}
if ( $forum_meta_color ) {
$style .= "#{$unique_id} .single-forum-post-widget .post-info .author, #{$unique_id} .single-forum-post-widget .post-info .post-time { color: {$forum_meta_color}; }";
}
if ( $parent_forum_color ) {
$style .= "#{$unique_id} .post-content .post-category a { color: {$parent_forum_color}; }";
}
if ( $parent_forum_color_hover ) {
$style .= "#{$unique_id} .post-content .post-category a:hover { color: {$parent_forum_color_hover}; }";
}
$style .= "";
$topics = new WP_Query( array(
'post_type' => 'topic',
'posts_per_page' => $ppp2,
'order' => $order,
) );
$wrapper_attributes = get_block_wrapper_attributes( [
'class' => 'forum-post-widget',
'id' => $unique_id,
] );
ob_start();
echo $style;
?>
data_id="">
have_posts() ) : $topics->the_post();
$topic_id = $topics->posts[ $i ]->ID;
$vote_count = get_post_meta( $topic_id, "bbpv-votes", true );
// Safe get forum ID
$forum_id = function_exists('bbp_get_topic_forum_id') ? bbp_get_topic_forum_id() : 0;
// Safe get forum title
$forum_title = '';
if ( function_exists('bbp_get_topic_forum_title') ) {
$forum_title = bbp_get_topic_forum_title();
} elseif ( function_exists('bbp_get_forum_title') ) {
$forum_title = bbp_get_forum_title( $forum_id );
}
?>
; ?>)
$topic_id,
'type' => 'name'
)
) );
}
?>
Error rendering block: ' . esc_html( $e->getMessage() ) . '
';
}
}
}