PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.1.0
Forumax – AI Powered Advanced Community Forum Plugin v1.1.0
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / includes / extra.php

extra.php in Forumax – AI Powered Advanced Community Forum Plugin 1.1.0, at includes/extra.php

122 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Check If the Page is Forum page
4 */
5 function bbpc_is_forum_page() {
6 if ( in_array( 'bbpress', get_body_class() ) ) {
7 return true;
8 }
9 }
10
11 /**
12 * Check if the pro plugin and plan is active
13 *
14 * @return bool|void
15 */
16 function bbpc_is_premium() {
17 if ( class_exists('BBPCorePro') && bc_fs()->can_use_premium_code() ) {
18 return true;
19 }
20 }
21
22 /**
23 * Posts Arraty
24 * @param object Post Type
25 */
26 function bbp_core_get_posts( $post_type = 'forum' ) {
27 $posts = get_pages(
28 [
29 'post_type' => $post_type,
30 'parent' => 0,
31 ]
32 );
33
34 $posts_array = [];
35
36 if ( $posts ) {
37 foreach ( $posts as $post ) {
38 $posts_array[ $post->ID ] = $post->post_title;
39 }
40 }
41
42 return $posts_array;
43 }
44
45 /**
46 * Limit letter
47 * @param $string
48 * @param $limit_length
49 * @param string $suffix
50 */
51 function bbp_core_limit_letter( $string, $limit_length, $suffix = '...' ) {
52 if ( strlen( $string ) > $limit_length ) {
53 echo strip_shortcodes( substr( $string, 0, $limit_length ) . $suffix );
54 } else {
55 echo strip_shortcodes( esc_html( $string ) );
56 }
57 }
58
59 /**
60 * Return the topic view count.
61 *
62 * @param int $topic_id Optional. Topic id
63 *
64 * @return int The view count
65 * @uses get_post_meta() To get the view count meta
66 * @uses bbp_get_topic_id() To get the topic id
67 */
68 function bbp_get_topic_view_count( $topic_id = 0 ) {
69 $topic_id = bbp_get_topic_id( $topic_id );
70
71 if ( empty( $topic_id ) ) {
72 return 0;
73 }
74
75 $views = (int) get_post_meta( $topic_id, '_btv_view_count', true );
76
77 return $views;
78 }
79
80 /**
81 * Output the topic view count.
82 *
83 * @param int $topic_id Optional. Topic id
84 *
85 * @uses bbp_get_topic_id() To get the topic id
86 * @uses btv_get_topic_view_count() To get the view count for the topic
87 */
88 function bbp_topic_view_count( $topic_id = 0 ) {
89 $topic_id = bbp_get_topic_id( $topic_id );
90 $view_count = bbp_get_topic_view_count( $topic_id );
91 return $view_count;
92 }
93
94
95 /**
96 * Get forum title
97 * @return string
98 */
99 function bbpc_forum_title(){
100 $forum_id = bbp_get_forum_id();
101 $forum_title = get_the_title( $forum_id );
102 return $forum_title;
103 }
104
105 /**
106 * Get the value of a settings field.
107 *
108 * @param string $option settings field name
109 * @param string $section the section name this field belongs to
110 * @param string $default default text if it's not found
111 *
112 * @return mixed
113 */
114 function bbpc_get_opt( $option, $default = '' ) {
115 $options = get_option( 'bbp_core_settings' );
116
117 if ( isset( $options[ $option ] ) ) {
118 return $options[ $option ];
119 }
120
121 return $default;
122 }