| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | namespace admin\Elementor; |
| 4 | 3 | |
| 5 | 4 | use Elementor\Controls_Manager; |
| 6 | 5 | use Elementor\Widget_Base; |
| @@ -11,52 +10,49 @@ | ||
| 11 | 10 | exit; |
| 12 | 11 | } |
| 13 | 12 | |
| 14 | 13 | class Forum_Ajax extends Widget_Base { |
| 15 | - public function get_name() { | |
| 14 | + public function get_name(): string { | |
| 16 | 15 | return 'ama_ajax_forum'; |
| 17 | 16 | } |
| 18 | 17 | |
| 19 | - public function get_title() { | |
| 20 | - return esc_html__( 'BBPC Ajax Forums', 'bbp-core' ); | |
| 18 | + public function get_title(): string { | |
| 19 | + return esc_html__( 'Ajax Forums (Forumax)', 'forumax' ); | |
| 21 | 20 | } |
| 22 | 21 | |
| 23 | - public function get_icon() { | |
| 24 | - return 'bbpc_icon_ama_ajax_forum'; | |
| 22 | + public function get_icon(): string { | |
| 23 | + return 'bbpc_icon_ama_ajax_forum eicon-posts-group'; | |
| 25 | 24 | } |
| 26 | 25 | |
| 27 | - public function get_keywords() { | |
| 26 | + public function get_keywords(): array { | |
| 28 | 27 | return [ 'forum', 'ajax' ]; |
| 29 | 28 | } |
| 30 | 29 | |
| 31 | - public function get_categories() { | |
| 32 | - return [ 'bbp-core' ]; | |
| 30 | + public function get_categories(): array { | |
| 31 | + return [ 'forumax' ]; | |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | - public function get_style_depends() { | |
| 36 | - return [ 'bbpc-el-widgets' ]; | |
| 34 | + public function get_style_depends(): array { | |
| 35 | + return [ 'bbpc-el-widgets', 'elegant-icon' ]; | |
| 37 | 36 | } |
| 38 | - | |
| 39 | - public function get_script_depends() { | |
| 37 | + | |
| 38 | + public function get_script_depends(): array { | |
| 40 | 39 | return [ 'bbpc-ajax' ]; |
| 41 | 40 | } |
| 42 | 41 | |
| 43 | - protected function register_controls() { | |
| 44 | - /** | |
| 45 | - * Content section | |
| 46 | - */ | |
| 42 | + protected function register_controls(): void { | |
| 43 | + //========================== Filter Options =====================// | |
| 47 | 44 | $this->start_controls_section( |
| 48 | - 'content_sec', [ | |
| 49 | - 'label' => esc_html__( 'Content Section', 'bbp-core' ), | |
| 45 | + 'filter_sec', [ | |
| 46 | + 'label' => esc_html__( 'Filter Options', 'forumax' ), | |
| 50 | 47 | ] |
| 51 | 48 | ); |
| 52 | 49 | |
| 53 | 50 | $this->add_control( |
| 54 | 51 | 'ppp2', [ |
| 55 | - 'label' => esc_html__( 'Show Forums', 'bbp-core' ), | |
| 56 | - 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'bbp-core' ), | |
| 52 | + 'label' => esc_html__( 'Show Forums', 'forumax' ), | |
| 53 | + 'description' => esc_html__( 'Show the forums count at the initial view. Default is 9 forums in a row.', 'forumax' ), | |
| 57 | 54 | 'type' => \Elementor\Controls_Manager::NUMBER, |
| 58 | - 'label_block' => true, | |
| 59 | 55 | 'default' => 9 |
| 60 | 56 | ] |
| 61 | 57 | ); |
| 62 | 58 | |
| @@ -61,9 +57,9 @@ | ||
| 61 | 57 | ); |
| 62 | 58 | |
| 63 | 59 | $this->add_control( |
| 64 | 60 | 'order', [ |
| 65 | - 'label' => esc_html__( 'Order', 'bbp-core' ), | |
| 61 | + 'label' => esc_html__( 'Order', 'forumax' ), | |
| 66 | 62 | 'type' => \Elementor\Controls_Manager::SELECT, |
| 67 | 63 | 'options' => [ |
| 68 | 64 | 'ASC' => 'ASC', |
| 69 | 65 | 'DESC' => 'DESC' |
| @@ -71,8 +67,21 @@ | ||
| 71 | 67 | 'default' => 'ASC' |
| 72 | 68 | ] |
| 73 | 69 | ); |
| 74 | 70 | |
| 71 | + // button show hide switcher | |
| 72 | + $this->add_control( | |
| 73 | + 'filter_btns', | |
| 74 | + [ | |
| 75 | + 'label' => esc_html__( 'Tab Filter', 'forumax' ), | |
| 76 | + 'type' => \Elementor\Controls_Manager::SWITCHER, | |
| 77 | + 'label_on' => esc_html__( 'Show', 'forumax' ), | |
| 78 | + 'label_off' => esc_html__( 'Hide', 'forumax' ), | |
| 79 | + 'return_value' => 'yes', | |
| 80 | + 'default' => 'yes', | |
| 81 | + ] | |
| 82 | + ); | |
| 83 | + | |
| 75 | 84 | $this->end_controls_section(); |
| 76 | 85 | |
| 77 | 86 | /** |
| 78 | 87 | * Styling section starts |
| @@ -78,9 +87,9 @@ | ||
| 78 | 87 | * Styling section starts |
| 79 | 88 | */ |
| 80 | 89 | $this->start_controls_section( |
| 81 | 90 | 'styling_sec', [ |
| 82 | - 'label' => esc_html__( 'Title Style', 'bbp-core' ), | |
| 91 | + 'label' => esc_html__( 'Title Style', 'forumax' ), | |
| 83 | 92 | 'tab' => Controls_Manager::TAB_STYLE, |
| 84 | 93 | ] |
| 85 | 94 | ); |
| 86 | 95 | //forum title |
| @@ -86,10 +95,10 @@ | ||
| 86 | 95 | //forum title |
| 87 | 96 | $this->add_control( |
| 88 | 97 | 'forum_heading', |
| 89 | 98 | [ |
| 90 | - 'label' => esc_html__( 'Forum Title', 'bbp-core' ), | |
| 91 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 99 | + 'label' => esc_html__( 'Forum Title', 'forumax' ), | |
| 100 | + 'type' => \Elementor\Controls_Manager::HEADING, | |
| 92 | 101 | 'separator' => 'before', |
| 93 | 102 | ] |
| 94 | 103 | ); |
| 95 | 104 | |
| @@ -96,9 +105,9 @@ | ||
| 96 | 105 | |
| 97 | 106 | $this->add_control( |
| 98 | 107 | 'forum_title_color', |
| 99 | 108 | [ |
| 100 | - 'label' => esc_html__( 'Color', 'bbp-core' ), | |
| 109 | + 'label' => esc_html__( 'Color', 'forumax' ), | |
| 101 | 110 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 102 | 111 | 'selectors' => [ |
| 103 | 112 | '{{WRAPPER}} .single-forum-post-widget .post-title a' => 'color: {{VALUE}}', |
| 104 | 113 | ], |
| @@ -107,9 +116,9 @@ | ||
| 107 | 116 | |
| 108 | 117 | $this->add_control( |
| 109 | 118 | 'forum_title_hover_color', |
| 110 | 119 | [ |
| 111 | - 'label' => esc_html__( 'Hover Color', 'bbp-core' ), | |
| 120 | + 'label' => esc_html__( 'Hover Color', 'forumax' ), | |
| 112 | 121 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 113 | 122 | 'selectors' => [ |
| 114 | 123 | '{{WRAPPER}} .single-forum-post-widget .post-title a:hover' => 'color: {{VALUE}}', |
| 115 | 124 | ], |
| @@ -127,10 +136,10 @@ | ||
| 127 | 136 | // Forum meta |
| 128 | 137 | $this->add_control( |
| 129 | 138 | 'forum_meta', |
| 130 | 139 | [ |
| 131 | - 'label' => esc_html__( 'Forum Meta', 'bbp-core' ), | |
| 132 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 140 | + 'label' => esc_html__( 'Forum Meta', 'forumax' ), | |
| 141 | + 'type' => \Elementor\Controls_Manager::HEADING, | |
| 133 | 142 | 'separator' => 'before', |
| 134 | 143 | ] |
| 135 | 144 | ); |
| 136 | 145 | |
| @@ -136,9 +145,9 @@ | ||
| 136 | 145 | |
| 137 | 146 | $this->add_control( |
| 138 | 147 | 'forum_meta_color', |
| 139 | 148 | [ |
| 140 | - 'label' => esc_html__( 'Color', 'bbp-core' ), | |
| 149 | + 'label' => esc_html__( 'Color', 'forumax' ), | |
| 141 | 150 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 142 | 151 | 'selectors' => [ |
| 143 | 152 | '{{WRAPPER}} .single-forum-post-widget .post-info .author,{{WRAPPER}} .single-forum-post-widget .post-info .post-time' => 'color: {{VALUE}}', |
| 144 | 153 | ], |
| @@ -144,9 +153,9 @@ | ||
| 144 | 153 | ], |
| 145 | 154 | ] |
| 146 | 155 | ); |
| 147 | 156 | |
| 148 | - | |
| 157 | + | |
| 149 | 158 | $this->add_group_control( |
| 150 | 159 | \Elementor\Group_Control_Typography::get_type(), |
| 151 | 160 | [ |
| 152 | 161 | 'name' => 'forum_meta_typography', |
| @@ -157,10 +166,10 @@ | ||
| 157 | 166 | //parent forum |
| 158 | 167 | $this->add_control( |
| 159 | 168 | 'parent_forum', |
| 160 | 169 | [ |
| 161 | - 'label' => esc_html__( 'Parent Forum', 'bbp-core' ), | |
| 162 | - 'type' => \Elementor\Controls_Manager::HEADING, | |
| 170 | + 'label' => esc_html__( 'Parent Forum', 'forumax' ), | |
| 171 | + 'type' => \Elementor\Controls_Manager::HEADING, | |
| 163 | 172 | 'separator' => 'before', |
| 164 | 173 | ] |
| 165 | 174 | ); |
| 166 | 175 | |
| @@ -166,9 +175,9 @@ | ||
| 166 | 175 | |
| 167 | 176 | $this->add_control( |
| 168 | 177 | 'parent_forum_color', |
| 169 | 178 | [ |
| 170 | - 'label' => esc_html__( 'Color', 'bbp-core' ), | |
| 179 | + 'label' => esc_html__( 'Color', 'forumax' ), | |
| 171 | 180 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 172 | 181 | 'selectors' => [ |
| 173 | 182 | '{{WRAPPER}} .post-content .post-category a' => 'color: {{VALUE}}', |
| 174 | 183 | ], |
| @@ -177,9 +186,9 @@ | ||
| 177 | 186 | |
| 178 | 187 | $this->add_control( |
| 179 | 188 | 'parent_forum_color_hover', |
| 180 | 189 | [ |
| 181 | - 'label' => esc_html__( 'Hover color', 'bbp-core' ), | |
| 190 | + 'label' => esc_html__( 'Hover color', 'forumax' ), | |
| 182 | 191 | 'type' => \Elementor\Controls_Manager::COLOR, |
| 183 | 192 | 'selectors' => [ |
| 184 | 193 | '{{WRAPPER}} .post-content .post-category a:hover' => 'color: {{VALUE}}', |
| 185 | 194 | ], |
| @@ -197,9 +206,10 @@ | ||
| 197 | 206 | $this->end_controls_section(); |
| 198 | 207 | } |
| 199 | 208 | |
| 200 | 209 | protected function render() { |
| 201 | - $settings = $this->get_settings(); | |
| 210 | + $settings = $this->get_settings(); | |
| 211 | + $filter_btns = $settings['filter_btns'] ?? true; | |
| 202 | 212 | |
| 203 | 213 | $topics = new WP_Query( array( |
| 204 | 214 | 'post_type' => 'topic', |
| 205 | 215 | 'posts_per_page' => ! empty( $settings['ppp2'] ) ? $settings['ppp2'] : 9, |
| @@ -207,40 +217,47 @@ | ||
| 207 | 217 | ) ); |
| 208 | 218 | ?> |
| 209 | 219 | |
| 210 | 220 | <div class="forum-post-widget" data_id="<?php echo esc_attr( $this->get_id() ); ?>"> |
| 211 | - <div class="post-filter-widget mb-20 wow fadeInUp"> | |
| 212 | - <div class="single-filter-item"> | |
| 213 | - <a href="#" id="all_filt" data-forum="all" class="data-active"> | |
| 214 | - <i class="icon_grid-2x2"></i><?php _e( 'All', 'bbp-core' ) ?> | |
| 215 | - </a> | |
| 221 | + | |
| 222 | + <?php | |
| 223 | + if ( $filter_btns ) : | |
| 224 | + ?> | |
| 225 | + <div class="post-filter-widget mb-20 wow fadeInUp"> | |
| 226 | + <div class="single-filter-item"> | |
| 227 | + <a href="#" id="all_filt" data-forum="all" class="data-active"> | |
| 228 | + <i class="icon_grid-2x2"></i><?php esc_html_e( 'All', 'forumax' ) ?> | |
| 229 | + </a> | |
| 230 | + </div> | |
| 231 | + <div class="single-filter-item"> | |
| 232 | + <a href="#" id="populer_filt" data-forum="popular"> | |
| 233 | + <i class="icon_easel"></i><?php esc_html_e( 'Popular', 'forumax' ) ?> | |
| 234 | + </a> | |
| 235 | + </div> | |
| 236 | + <div class="single-filter-item"> | |
| 237 | + <a href="#" id="featured_filt" data-forum="featured"> | |
| 238 | + <i class="icon_ribbon_alt"></i><?php esc_html_e( 'Featured', 'forumax' ) ?> | |
| 239 | + </a> | |
| 240 | + </div> | |
| 241 | + <div class="single-filter-item"> | |
| 242 | + <a href="#" id="recent_filt" data-forum="recent"> | |
| 243 | + <i class="icon_clock_alt"></i><?php esc_html_e( 'Recent', 'forumax' ) ?> | |
| 244 | + </a> | |
| 245 | + </div> | |
| 246 | + <div class="single-filter-item"> | |
| 247 | + <a href="#" id="unloved_filt" data-forum="unloved"> | |
| 248 | + <i class="icon_close_alt2"></i><?php esc_html_e( 'Unloved', 'forumax' ) ?> | |
| 249 | + </a> | |
| 250 | + </div> | |
| 251 | + <div class="single-filter-item"> | |
| 252 | + <a href="#" id="loved_filt" data-forum="loved"> | |
| 253 | + <i class="icon_check_alt2"></i><?php esc_html_e( 'Loved', 'forumax' ) ?> | |
| 254 | + </a> | |
| 255 | + </div> | |
| 216 | 256 | </div> |
| 217 | - <div class="single-filter-item"> | |
| 218 | - <a href="#" id="populer_filt" data-forum="popular"> | |
| 219 | - <i class="icon_easel"></i><?php _e( 'Popular', 'bbp-core' ) ?> | |
| 220 | - </a> | |
| 221 | - </div> | |
| 222 | - <div class="single-filter-item"> | |
| 223 | - <a href="#" id="featured_filt" data-forum="featured"> | |
| 224 | - <i class="icon_ribbon_alt"></i><?php _e( 'Featured', 'bbp-core' ) ?> | |
| 225 | - </a> | |
| 226 | - </div> | |
| 227 | - <div class="single-filter-item"> | |
| 228 | - <a href="#" id="recent_filt" data-forum="recent"> | |
| 229 | - <i class="icon_clock_alt"></i><?php _e( 'Recent', 'bbp-core' ) ?> | |
| 230 | - </a> | |
| 231 | - </div> | |
| 232 | - <div class="single-filter-item"> | |
| 233 | - <a href="#" id="unsolved_filt" data-forum="unsolved"> | |
| 234 | - <i class="icon_close_alt2"></i><?php _e( 'Unsolved', 'bbp-core' ) ?> | |
| 235 | - </a> | |
| 236 | - </div> | |
| 237 | - <div class="single-filter-item"> | |
| 238 | - <a href="#" id="solved_filt" data-forum="solved"> | |
| 239 | - <i class="icon_check_alt2"></i><?php _e( 'Solved', 'bbp-core' ) ?> | |
| 240 | - </a> | |
| 241 | - </div> | |
| 242 | - </div> | |
| 257 | + <?php | |
| 258 | + endif; | |
| 259 | + ?> | |
| 243 | 260 | |
| 244 | 261 | <div id="aj-post-filter-widget"> |
| 245 | 262 | <?php |
| 246 | 263 | $delay = 0.0; |
| @@ -245,15 +262,13 @@ | ||
| 245 | 262 | <?php |
| 246 | 263 | $delay = 0.0; |
| 247 | 264 | $i = 0; |
| 248 | 265 | while ( $topics->have_posts() ) : $topics->the_post(); |
| 249 | - $item_id = get_the_ID(); | |
| 250 | - $author_id = get_post_field( 'post_author', $item_id ); | |
| 251 | 266 | $topic_id = $topics->posts[ $i ]->ID; |
| 252 | 267 | $vote_count = get_post_meta( $topic_id, "bbpv-votes", true ); |
| 253 | 268 | $forum_id = bbp_get_topic_forum_id(); |
| 254 | 269 | ?> |
| 255 | - <div class="single-forum-post-widget wow fadeInUp" data-wow-delay="<?php echo $delay ?>s"> | |
| 270 | + <div class="single-forum-post-widget wow fadeInUp" data-wow-delay="<?php echo esc_attr( $delay ); ?>s"> | |
| 256 | 271 | <div class="post-content"> |
| 257 | 272 | <div class="post-title"> |
| 258 | 273 | <h6><a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a></h6> |
| 259 | 274 | </div> |
| @@ -258,68 +273,70 @@ | ||
| 258 | 273 | <h6><a href="<?php the_permalink(); ?>"> <?php the_title() ?> </a></h6> |
| 259 | 274 | </div> |
| 260 | 275 | <div class="post-info"> |
| 261 | 276 | <div class="author"> |
| 262 | - <img src="<?php echo BBPC_IMG ?>/forum_tab/user-circle-alt.svg" alt="<?php esc_attr_e( 'User circle alt icon', 'bbpc-core' ); ?>"> | |
| 263 | - <?php | |
| 264 | - echo bbp_get_topic_author_link( | |
| 265 | - array( | |
| 266 | - 'post_id' => $topic_id, | |
| 267 | - 'type' => 'name' | |
| 277 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/user-circle-alt.svg' ); ?>" alt="<?php esc_attr_e( 'User circle alt icon', | |
| 278 | + 'forumax' ); ?>"> | |
| 279 | + <?php | |
| 280 | + echo wp_kses_post( bbp_get_topic_author_link( | |
| 281 | + array( | |
| 282 | + 'post_id' => $topic_id, | |
| 283 | + 'type' => 'name' | |
| 268 | 284 | ) |
| 269 | - ); | |
| 285 | + ) ); | |
| 270 | 286 | ?> |
| 271 | 287 | </div> |
| 272 | 288 | |
| 273 | 289 | <div class="post-time"> |
| 274 | - <img src="<?php echo BBPC_IMG ?>/forum_tab/time-outline.svg" alt="<?php esc_attr_e( 'Time outline icon', 'bbpc-core' ); ?>"> | |
| 275 | - <?php echo bbp_forum_last_active_time( get_the_ID() ); ?> | |
| 290 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/time-outline.svg' ); ?>" | |
| 291 | + alt="<?php esc_attr_e( 'Time outline icon', 'forumax' ); ?>"> | |
| 292 | + <?php bbp_forum_last_active_time( get_the_ID() ); ?> | |
| 276 | 293 | </div> |
| 277 | 294 | </div> |
| 278 | 295 | |
| 279 | 296 | <div class="post-category"> |
| 280 | - <a href="<?php echo get_the_permalink( $forum_id ) ?>"> | |
| 297 | + <a href="<?php echo esc_url( get_the_permalink( $forum_id ) ); ?>"> | |
| 281 | 298 | <?php echo get_the_post_thumbnail( $forum_id ); ?> |
| 282 | - <?php echo bbp_get_topic_forum_title(); ?> | |
| 299 | + <?php echo esc_html( bbp_get_topic_forum_title() ); ?> | |
| 283 | 300 | </a> |
| 284 | 301 | </div> |
| 285 | 302 | </div> |
| 286 | 303 | <div class="post-reach"> |
| 287 | 304 | <div class="post-view"> |
| 288 | - <img src="<?php echo BBPC_IMG ?>/forum_tab/eye-outline.svg" alt="<?php esc_attr_e( 'Eye outline icon', 'bbpc-core' ); ?>"> | |
| 289 | - | |
| 290 | - <?php | |
| 291 | - bbp_topic_view_count( $topic_id ); | |
| 305 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/eye-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Eye outline icon', 'forumax' ); ?>"> | |
| 306 | + | |
| 307 | + <?php | |
| 308 | + forumax_topic_view_count( $topic_id ); | |
| 292 | 309 | echo ' '; |
| 293 | - _e( 'Views', 'bbp-core' ); | |
| 310 | + esc_html_e( 'Views', 'forumax' ); | |
| 294 | 311 | ?> |
| 295 | 312 | </div> |
| 296 | 313 | <div class="post-like"> |
| 297 | - <img src="<?php echo BBPC_IMG ?>/forum_tab/thumbs-up-outline.svg" alt="<?php esc_attr_e( 'Thumbs-up outline icon', 'bbpc-core' ); ?>"> | |
| 298 | - | |
| 299 | - <?php | |
| 314 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/thumbs-up-outline.svg' ); ?>" | |
| 315 | + alt="<?php esc_attr_e( 'Thumbs-up outline icon', 'forumax' ); ?>"> | |
| 316 | + | |
| 317 | + <?php | |
| 300 | 318 | if ( $vote_count ) { |
| 301 | - echo $vote_count; | |
| 319 | + echo esc_html( $vote_count ); | |
| 302 | 320 | } else { |
| 303 | 321 | echo "0"; |
| 304 | 322 | } |
| 305 | - | |
| 323 | + | |
| 306 | 324 | echo ' '; |
| 307 | - _e( 'Likes', 'bbp-core' ); | |
| 325 | + esc_html_e( 'Likes', 'forumax' ); | |
| 308 | 326 | ?> |
| 309 | 327 | </div> |
| 310 | 328 | <div class="post-comment"> |
| 311 | - <img src="<?php echo BBPC_IMG ?>/forum_tab/chatbubbles-outline.svg" alt="<?php esc_attr_e( 'Chat bubbles icon', 'bbpc-core' ); ?>"> | |
| 312 | - | |
| 313 | - <?php | |
| 329 | + <img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/chatbubbles-outline.svg' ); ?>" | |
| 330 | + alt="<?php esc_attr_e( 'Chat bubbles icon', 'forumax' ); ?>"> | |
| 331 | + <?php | |
| 314 | 332 | bbp_topic_reply_count( $topic_id ); |
| 315 | 333 | echo ' '; |
| 316 | - _e( 'Replies', 'bbp-core' ); | |
| 334 | + esc_html_e( 'Replies', 'forumax' ); | |
| 317 | 335 | ?> |
| 318 | 336 | </div> |
| 319 | 337 | </div> |
| 320 | 338 | </div> |
| 321 | - | |
| 322 | 339 | <?php |
| 323 | 340 | $delay += 0.2; |
| 324 | 341 | if ( $delay > 0.6 ) { |
| 325 | 342 | $delay = 0.0; |