| 1 |
<?php |
| 2 |
|
| 3 |
namespace admin\Elementor; |
| 4 |
|
| 5 |
use Elementor\Widget_Base; |
| 6 |
use Elementor\Controls_Manager; |
| 7 |
use Elementor\Core\Schemes\Color; |
| 8 |
use Elementor\Core\Schemes\Typography; |
| 9 |
use Elementor\Group_Control_Typography; |
| 10 |
use Elementor\Group_Control_Text_Shadow; |
| 11 |
use WP_Query; |
| 12 |
use WP_Post; |
| 13 |
|
| 14 |
// Exit if accessed directly |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Class Forum_posts |
| 21 |
* |
| 22 |
* @package amaCore\Widgets |
| 23 |
*/ |
| 24 |
class Forum_posts extends Widget_Base { |
| 25 |
|
| 26 |
public function get_name() { |
| 27 |
return 'ama_forum_posts'; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_title() { |
| 31 |
return __( 'BBPC Forum Topics', 'bbp-core' ); |
| 32 |
} |
| 33 |
|
| 34 |
public function get_icon() { |
| 35 |
return 'bbpc_icon_ama_forum_posts'; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_keywords() { |
| 39 |
return [ 'topics', 'replies' ]; |
| 40 |
} |
| 41 |
|
| 42 |
// style dependency |
| 43 |
public function get_style_depends() { |
| 44 |
return [ 'bbpc-el-widgets' ]; |
| 45 |
} |
| 46 |
|
| 47 |
public function get_categories() { |
| 48 |
return [ 'bbp-core' ]; |
| 49 |
} |
| 50 |
|
| 51 |
protected function register_controls() { |
| 52 |
|
| 53 |
// --- Filter Options |
| 54 |
$this->start_controls_section( |
| 55 |
'filter_opt', [ |
| 56 |
'label' => __( 'Filter Options', 'bbp-core' ), |
| 57 |
] |
| 58 |
); |
| 59 |
|
| 60 |
$this->add_control( |
| 61 |
'ppp', [ |
| 62 |
'label' => esc_html__( 'Show Forum Topics', 'bbp-core' ), |
| 63 |
'type' => Controls_Manager::NUMBER, |
| 64 |
'default' => 5 |
| 65 |
] |
| 66 |
); |
| 67 |
|
| 68 |
$this->add_control( |
| 69 |
'order', [ |
| 70 |
'label' => esc_html__( 'Order', 'bbp-core' ), |
| 71 |
'type' => Controls_Manager::SELECT, |
| 72 |
'options' => [ |
| 73 |
'ASC' => 'ASC', |
| 74 |
'DESC' => 'DESC' |
| 75 |
], |
| 76 |
'default' => 'ASC' |
| 77 |
] |
| 78 |
); |
| 79 |
|
| 80 |
$this->end_controls_section(); |
| 81 |
// end Document Setting Section |
| 82 |
} |
| 83 |
|
| 84 |
protected function render() { |
| 85 |
$settings = $this->get_settings(); |
| 86 |
$forum_posts = new WP_Query( array( |
| 87 |
'post_type' => 'topic', |
| 88 |
'posts_per_page' => ! empty( $settings['ppp'] ) ? $settings['ppp'] : - 1, |
| 89 |
'order' => $settings['order'] ? $settings['order'] : 'ASC', |
| 90 |
) ); |
| 91 |
?> |
| 92 |
<div class="community-posts-wrapper"> |
| 93 |
<?php |
| 94 |
while ( $forum_posts->have_posts() ) : $forum_posts->the_post(); |
| 95 |
$favoriters = bbp_get_topic_favoriters(); |
| 96 |
$favorite_count = ! empty( $favoriters ) ? $favoriters[0] : '0'; |
| 97 |
?> |
| 98 |
<div class="community-post wow fadeInUp" data-wow-delay="0.5s"> |
| 99 |
<div class="post-content"> |
| 100 |
<div class="author-avatar"> |
| 101 |
<?php echo get_avatar( get_the_author_meta( 'ID' ), 40 ) ?> |
| 102 |
</div> |
| 103 |
<div class="entry-content"> |
| 104 |
<h3 class="post-title"> |
| 105 |
<a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> |
| 106 |
</h3> |
| 107 |
|
| 108 |
<?php |
| 109 |
esc_html_e( 'Last active: ', 'bbp-core' ); |
| 110 |
echo bbp_get_forum_last_active_time( get_the_ID() ); |
| 111 |
?> |
| 112 |
|
| 113 |
</div> |
| 114 |
</div> |
| 115 |
<div class="post-meta-wrapper"> |
| 116 |
<ul class="post-meta-info"> |
| 117 |
<li> |
| 118 |
<a href="<?php bbp_topic_permalink(); ?>"> |
| 119 |
<svg width="14px" height="14px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 120 |
<path fill="#444" d="M14 14.2c0 0 0 0 0 0 0-0.6 2-1.8 2-3.1 0-1.5-1.4-2.7-3.1-3.2 0.7-0.8 1.1-1.7 1.1-2.8 0-2.8-2.9-5.1-6.6-5.1-3.5 0-7.4 2.1-7.4 5.1 0 2.1 1.6 3.6 2.3 4.2-0.1 1.2-0.6 1.7-0.6 1.7l-1.2 1h1.5c1.6 0 2.9-0.5 3.7-1.1 0 0.1 0 0.1 0 0.2 0 2 2.2 3.6 5 3.6 0.2 0 0.4 0 0.6 0 0.4 0.5 1.7 1.4 3.4 1.4 0.1-0.1-0.7-0.5-0.7-1.9zM7.4 1c3.1 0 5.6 1.9 5.6 4.1s-2.6 4.1-5.8 4.1c-0.2 0-0.6 0-0.8 0h-0.3l-0.1 0.2c-0.3 0.4-1.5 1.2-3.1 1.5 0.1-0.4 0.1-1 0.1-1.8v-0.3c-1-0.8-2.1-2.2-2.1-3.6 0-2.2 3.2-4.2 6.5-4.2z"></path> |
| 121 |
</svg> |
| 122 |
<?php bbp_show_lead_topic() ? bbp_topic_reply_count( get_the_ID() ) : bbp_topic_post_count( get_the_ID() ); ?> |
| 123 |
</a> |
| 124 |
</li> |
| 125 |
<li> |
| 126 |
<a href="<?php bbp_topic_permalink(); ?>"> |
| 127 |
<svg fill="#000000" width="15px" height="15px" viewBox="0 0 24 24" id="star" data-name="Line Color" xmlns="http://www.w3.org/2000/svg" class="icon line-color"> |
| 128 |
<polygon id="primary" points="12 4 9.22 9.27 3 10.11 7.5 14.21 6.44 20 12 17.27 17.56 20 16.5 14.21 21 10.11 14.78 9.27 12 4" style="fill: none; stroke: rgb(0, 0, 0); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;"></polygon> |
| 129 |
</svg> <?php echo esc_html( $favorite_count ); ?> |
| 130 |
</a> |
| 131 |
</li> |
| 132 |
</ul> |
| 133 |
</div> |
| 134 |
</div> |
| 135 |
<?php |
| 136 |
endwhile; |
| 137 |
?> |
| 138 |
</div> |
| 139 |
<?php |
| 140 |
} |
| 141 |
} |