get('Name')); if ('docy' === $theme_name) { return 'docy_forums'; } elseif ('docly' === $theme_name) { return 'Docly_forums'; } return 'ama_forums'; } /** * Get widget title. * * @return string Widget title. */ public function get_title() { return __('Forums (Forumax)', 'forumax'); } /** * Get widget icon. * * @return string Widget icon. */ public function get_icon() { return 'eicon-comments'; } /** * Get widget categories. * * @return array Widget categories. */ public function get_categories() { return ['forumax']; } /** * Get script dependencies. * * @return array Script dependencies. */ public function get_script_depends() { return ['bbpc-ajax']; } /** * Get style dependencies. * * @return array Style dependencies. */ public function get_style_depends() { return ['bbpc-el-widgets']; } /** * Register widget controls. * * @return void */ protected function register_controls() { // Select Style. $this->start_controls_section( 'style_sec', [ 'label' => esc_html__('Preset Skins', 'forumax'), ] ); $this->add_control( 'style', [ 'label' => esc_html__('Forums Style', 'forumax'), 'type' => Controls_Manager::VISUAL_CHOICE, 'options' => [ '1' => [ 'image' => FORUMAX_ASSETS . '/admin/images/skins/docy-forums-1.jpg', 'title' => esc_html__('01 : Forums', 'forumax'), ], '2' => [ 'image' => FORUMAX_ASSETS . '/admin/images/skins/docy-forums-2.jpg', 'title' => esc_html__('02 : Forums', 'forumax'), ], '3' => [ 'image' => FORUMAX_ASSETS . '/admin/images/skins/forums-3.png', 'title' => esc_html__('03 : Help Center', 'forumax'), ], ], 'default' => '1', 'label_block' => true, ] ); $this->end_controls_section(); // End Style. // Filter Options. $this->start_controls_section( 'filter_opt',[ 'label' => __('Filter Options', 'forumax'), ] ); $this->add_control( 'ppp', [ 'label' => esc_html__('Show Forums', 'forumax'), 'description' => esc_html__('Show the forums count at the initial view. Default is 5 forums in a row.', 'forumax'), 'type' => Controls_Manager::NUMBER, 'default' => 6, ] ); $this->add_control( 'ppp2', [ 'label' => esc_html__('Hidden Forums', 'forumax'), 'description' => esc_html__('Hidden forums will show on clicking on the More button.', 'forumax'), 'type' => Controls_Manager::NUMBER, 'default' => 10, 'condition' => [ 'style!' => '3', ], ] ); $this->add_control( 'order', [ 'label' => esc_html__('Order', 'forumax'), 'type' => Controls_Manager::SELECT, 'options' => [ 'ASC' => 'ASC', 'DESC' => 'DESC', ], 'default' => 'ASC', ] ); $this->end_controls_section(); // --- Read More Options $this->start_controls_section( 'button_opt', [ 'label' => __('Read More Options', 'forumax'), 'condition' => [ 'style!' => '3', ], ] ); $this->add_control( 'more_txt', [ 'label' => esc_html__('Read More Text', 'forumax'), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => 'More Communities', ] ); $this->add_control( 'less_txt', [ 'label' => esc_html__('Read Less Text', 'forumax'), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => 'Less Communities', ] ); $this->end_controls_section(); // Background shape Image. $this->start_controls_section( 'style_shapes', [ 'label' => __('Shape Images', 'forumax'), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'style' => '1', ], ] ); $this->add_control( 'shape1', [ 'label' => esc_html__('Shape', 'forumax'), 'type' => Controls_Manager::MEDIA, 'default' => [ 'url' => plugins_url('inc/forums/images/shap_white.png', __FILE__), ], ] ); $this->end_controls_section(); // ── Help Center: Content ──────────────────────────────────────────────── // Group 1 — Typography & text for all content elements. $this->start_controls_section( 'style_contents', [ 'label' => esc_html__( 'Content', 'forumax' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'style' => '3', ], ] ); // Title. $this->add_control( 'title_head', [ 'label' => esc_html__( 'Title', 'forumax' ), 'type' => Controls_Manager::HEADING, ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typo', 'selector' => '{{WRAPPER}} .bbpc-hc-title', ] ); $this->add_control( 'title_color', [ 'label' => esc_html__( 'Color', 'forumax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .bbpc-hc-title' => 'color: {{VALUE}};' ], ] ); // Description. $this->add_control( 'desc_head', [ 'label' => esc_html__( 'Description', 'forumax' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'desc_typo', 'selector' => '{{WRAPPER}} .bbpc-hc-desc', ] ); $this->add_control( 'desc_color', [ 'label' => esc_html__( 'Color', 'forumax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .bbpc-hc-desc' => 'color: {{VALUE}};' ], ] ); // Article Count. $this->add_control( 'count_head', [ 'label' => esc_html__( 'Article Count', 'forumax' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'count_typo', 'selector' => '{{WRAPPER}} .bbpc-hc-count', ] ); $this->add_control( 'count_color', [ 'label' => esc_html__( 'Color', 'forumax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .bbpc-hc-count' => 'color: {{VALUE}};' ], ] ); $this->add_control( 'count_singular', [ 'label' => esc_html__( 'Singular Label', 'forumax' ), 'description' => esc_html__( 'Shown when count is 1, e.g. "article"', 'forumax' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => 'article', 'separator' => 'before', 'condition' => [ 'style' => '3', ], ] ); $this->add_control( 'count_plural', [ 'label' => esc_html__( 'Plural Label', 'forumax' ), 'description' => esc_html__( 'Shown when count is 0 or more than 1, e.g. "articles"', 'forumax' ), 'type' => Controls_Manager::TEXT, 'label_block' => true, 'default' => 'articles', 'condition' => [ 'style' => '3', ], ] ); $this->end_controls_section(); // ── Help Center: Background ────────────────────────────────────────────── // Group 2 — Background, border, shadow and spacing for card & grid. $this->start_controls_section( 'style_background', [ 'label' => esc_html__( 'Background', 'forumax' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'style' => '3' ], ] ); // Card. $this->add_control( 'card_head', [ 'label' => esc_html__( 'Card', 'forumax' ), 'type' => Controls_Manager::HEADING, ] ); $this->start_controls_tabs( 'card_bg_tabs' ); $this->start_controls_tab( 'card_bg_normal', [ 'label' => esc_html__( 'Normal', 'forumax' ) ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'card_bg', 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .bbpc-hc-card', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'card_bg_hover', [ 'label' => esc_html__( 'Hover', 'forumax' ) ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'card_bg_hover', 'types' => [ 'classic', 'gradient' ], 'selector' => '{{WRAPPER}} .bbpc-hc-card:hover', ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'card_border', 'selector' => '{{WRAPPER}} .bbpc-hc-card', 'separator' => 'before', ] ); $this->add_control( 'card_radius', [ 'label' => esc_html__( 'Border Radius', 'forumax' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', '%', 'em' ], 'selectors' => [ '{{WRAPPER}} .bbpc-hc-card' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'card_shadow', 'selector' => '{{WRAPPER}} .bbpc-hc-card', ] ); $this->add_control( 'item_padding', [ 'label' => esc_html__( 'Padding', 'forumax' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .bbpc-hc-card' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); // Grid. $this->add_control( 'grid_head_option', [ 'label' => esc_html__( 'Grid', 'forumax' ), 'type' => Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'grid_gap_color', [ 'label' => esc_html__( 'Gap Color', 'forumax' ), 'description' => esc_html__( 'Color of the divider lines between cards.', 'forumax' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .bbpc-hc-grid' => 'background-color: {{VALUE}};' ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'grid_box_shadow', 'selector' => '{{WRAPPER}} .bbpc-hc-grid', ] ); $this->end_controls_section(); } /** * Render widget output. * * @return void */ protected function render() { $settings = $this->get_settings(); $forums = new WP_Query( [ 'post_type' => 'forum', 'posts_per_page' => !empty($settings['ppp']) ? $settings['ppp'] : 5, 'order' => $settings['order'], ] ); // Whitelist valid style values to prevent Local File Inclusion. $allowed_styles = ['1', '2', '3']; $style = isset($settings['style']) && in_array($settings['style'], $allowed_styles, true) ? $settings['style'] : '1'; // File Include. include __DIR__ . "/inc/forums/forums-{$style}.php"; } }