PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.2.0
Forumax – AI Powered Advanced Community Forum Plugin v2.2.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
← All changes | includes/features/bbpc_attachments/code/shared.php +127 -127 1.3.02.2.0 View file →
@@ -1,127 +1,127 @@
1 -<?php
2 -
3 -if ( ! defined( 'ABSPATH' ) ) {
4 - exit;
5 -}
6 -
7 -if ( ! class_exists( 'gdbbp_Error' ) ) {
8 - class gdbbp_Error {
9 - var $errors = [];
10 -
11 - function __construct() {
12 - }
13 -
14 - function add( $code, $message, $data ) {
15 - $this->errors[ $code ][] = [ $message, $data ];
16 - }
17 - }
18 -}
19 -
20 -if ( ! function_exists( 'bbpc_bbpress_get_user_roles' ) ) {
21 - function bbpc_bbpress_get_user_roles() {
22 - $roles = [];
23 -
24 - $dynamic_roles = bbp_get_dynamic_roles();
25 -
26 - foreach ( $dynamic_roles as $role => $obj ) {
27 - $roles[ $role ] = $obj['name'];
28 - }
29 -
30 - return $roles;
31 - }
32 -}
33 -
34 -if ( ! function_exists( 'bbpc_has_bbpress' ) ) {
35 - function bbpc_has_bbpress() {
36 - if ( function_exists( 'bbp_version' ) ) {
37 - $version = bbp_get_version();
38 - $version = intval( substr( str_replace( '.', '', $version ), 0, 2 ) );
39 -
40 - return $version > 22;
41 - } else {
42 - return false;
43 - }
44 - }
45 -}
46 -
47 -if ( ! function_exists( 'bbpc_bbpress_version' ) ) {
48 - function bbpc_bbpress_version( $ret = 'code' ) {
49 - if ( ! bbpc_has_bbpress() ) {
50 - return null;
51 - }
52 -
53 - $version = bbp_get_version();
54 -
55 - if ( isset( $version ) ) {
56 - if ( $ret == 'code' ) {
57 - return substr( str_replace( '.', '', $version ), 0, 2 );
58 - } else {
59 - return $version;
60 - }
61 - }
62 -
63 - return null;
64 - }
65 -}
66 -
67 -if ( ! function_exists( 'bbpc_is_bbpress' ) ) {
68 - function bbpc_is_bbpress() {
69 - $is = bbpc_has_bbpress() ? is_bbpress() : false;
70 -
71 - return apply_filters( 'bbpc_is_bbpress', $is );
72 - }
73 -}
74 -
75 -if ( ! function_exists( 'bbpc_is_user_moderator' ) ) {
76 - function bbpc_is_user_moderator() {
77 - global $current_user;
78 -
79 - if ( is_array( $current_user->roles ) ) {
80 - return in_array( 'bbp_moderator', $current_user->roles );
81 - } else {
82 - return false;
83 - }
84 - }
85 -}
86 -
87 -if ( ! function_exists( 'bbpc_is_user_admin' ) ) {
88 - function bbpc_is_user_admin() {
89 - global $current_user;
90 -
91 - if ( is_array( $current_user->roles ) ) {
92 - return in_array( 'administrator', $current_user->roles );
93 - } else {
94 - return false;
95 - }
96 - }
97 -}
98 -
99 -if ( ! function_exists( 'bbpc_url_campaign_tracking' ) ) {
100 - function bbpc_url_campaign_tracking( $url, $campaign = '', $medium = '', $content = '', $term = '', $source = null ) {
101 - if ( ! empty( $campaign ) ) {
102 - $url = add_query_arg( 'utm_campaign', $campaign, $url );
103 - }
104 -
105 - if ( ! empty( $medium ) ) {
106 - $url = add_query_arg( 'utm_medium', $medium, $url );
107 - }
108 -
109 - if ( ! empty( $content ) ) {
110 - $url = add_query_arg( 'utm_content', $content, $url );
111 - }
112 -
113 - if ( ! empty( $term ) ) {
114 - $url = add_query_arg( 'utm_term', $term, $url );
115 - }
116 -
117 - if ( is_null( $source ) ) {
118 - $source = parse_url( get_bloginfo( 'url' ), PHP_URL_HOST );
119 - }
120 -
121 - if ( ! empty( $source ) ) {
122 - $url = add_query_arg( 'utm_source', $source, $url );
123 - }
124 -
125 - return esc_url( $url );
126 - }
127 -}
1 +<?php
2 +
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit;
5 +}
6 +
7 +if ( ! class_exists( 'gdbbp_Error' ) ) {
8 + class gdbbp_Error {
9 + var $errors = [];
10 +
11 + function __construct() {
12 + }
13 +
14 + function add( $code, $message, $data ) {
15 + $this->errors[ $code ][] = [ $message, $data ];
16 + }
17 + }
18 +}
19 +
20 +if ( ! function_exists( 'forumax_bbpress_get_user_roles' ) ) {
21 + function forumax_bbpress_get_user_roles() {
22 + $roles = [];
23 +
24 + $dynamic_roles = bbp_get_dynamic_roles();
25 +
26 + foreach ( $dynamic_roles as $role => $obj ) {
27 + $roles[ $role ] = $obj['name'];
28 + }
29 +
30 + return $roles;
31 + }
32 +}
33 +
34 +if ( ! function_exists( 'forumax_has_bbpress' ) ) {
35 + function forumax_has_bbpress() {
36 + if ( function_exists( 'bbp_version' ) ) {
37 + $version = bbp_get_version();
38 + $version = intval( substr( str_replace( '.', '', $version ), 0, 2 ) );
39 +
40 + return $version > 22;
41 + } else {
42 + return false;
43 + }
44 + }
45 +}
46 +
47 +if ( ! function_exists( 'forumax_bbpress_version' ) ) {
48 + function forumax_bbpress_version( $ret = 'code' ) {
49 + if ( ! forumax_has_bbpress() ) {
50 + return null;
51 + }
52 +
53 + $version = bbp_get_version();
54 +
55 + if ( isset( $version ) ) {
56 + if ( $ret == 'code' ) {
57 + return substr( str_replace( '.', '', $version ), 0, 2 );
58 + } else {
59 + return $version;
60 + }
61 + }
62 +
63 + return null;
64 + }
65 +}
66 +
67 +if ( ! function_exists( 'forumax_is_bbpress' ) ) {
68 + function forumax_is_bbpress() {
69 + $is = forumax_has_bbpress() ? is_bbpress() : false;
70 +
71 + return apply_filters( 'forumax_is_bbpress', $is );
72 + }
73 +}
74 +
75 +if ( ! function_exists( 'forumax_is_user_moderator' ) ) {
76 + function forumax_is_user_moderator() {
77 + global $current_user;
78 +
79 + if ( is_array( $current_user->roles ) ) {
80 + return in_array( 'bbp_moderator', $current_user->roles );
81 + } else {
82 + return false;
83 + }
84 + }
85 +}
86 +
87 +if ( ! function_exists( 'forumax_is_user_admin' ) ) {
88 + function forumax_is_user_admin() {
89 + global $current_user;
90 +
91 + if ( is_array( $current_user->roles ) ) {
92 + return in_array( 'administrator', $current_user->roles );
93 + } else {
94 + return false;
95 + }
96 + }
97 +}
98 +
99 +if ( ! function_exists( 'forumax_url_campaign_tracking' ) ) {
100 + function forumax_url_campaign_tracking( $url, $campaign = '', $medium = '', $content = '', $term = '', $source = null ) {
101 + if ( ! empty( $campaign ) ) {
102 + $url = add_query_arg( 'utm_campaign', $campaign, $url );
103 + }
104 +
105 + if ( ! empty( $medium ) ) {
106 + $url = add_query_arg( 'utm_medium', $medium, $url );
107 + }
108 +
109 + if ( ! empty( $content ) ) {
110 + $url = add_query_arg( 'utm_content', $content, $url );
111 + }
112 +
113 + if ( ! empty( $term ) ) {
114 + $url = add_query_arg( 'utm_term', $term, $url );
115 + }
116 +
117 + if ( is_null( $source ) ) {
118 + $source = parse_url( get_bloginfo( 'url' ), PHP_URL_HOST );
119 + }
120 +
121 + if ( ! empty( $source ) ) {
122 + $url = add_query_arg( 'utm_source', $source, $url );
123 + }
124 +
125 + return esc_url( $url );
126 + }
127 +}