PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.1 2.5.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 All 31 releases
← All changes | includes/features/bbp_voting/helpers.php +35 -20 1.2.9 → 2.5.0 View file →
@@ -35,46 +35,44 @@
35 35
36 36
37 37 if ( ! function_exists( 'bbp_voting_field' ) ) {
38 38 function bbp_voting_field( $key, $name, $label = '', $description = '', $type = 'bool', $pro = false ) {
39 - $name_and_id = 'name="' . $key . '" id="' . $key . '"';
39 + $name_and_id = 'name="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '"';
40 40 $teaser = defined( 'BBPVOTINGPRO' ) ? false : $pro;
41 41 $attributes = $teaser ? 'disabled' : $name_and_id;
42 42 ?>
43 43 <tr valign="top">
44 44 <th scope="row">
45 - <?php echo $name; ?>:
45 + <?php echo esc_html( $name ); ?>:
46 46 <?php if ( $pro ) { ?>
47 - <a href="https://wpforthewin.com/product/bbpress-voting-pro/" target="_blank"><span class="bbp-voting-pro-badge bbp-voting-pro-green">Pro</span></a>
47 + <a href="<?php echo esc_url( 'https://wpforthewin.com/product/bbpress-voting-pro/' ); ?>" target="_blank" rel="noopener noreferrer">
48 + <span class="bbp-voting-pro-badge bbp-voting-pro-green">Pro</span>
49 + </a>
48 50 <?php } ?>
49 51 </th>
50 52 <td>
51 - <?php if ( $type == 'bool' ) { ?>
52 - <input type="checkbox" <?php echo $attributes; ?> value="true"
53 - <?php
54 - if ( get_option( $key ) == 'true' ) {
55 - echo 'checked';}
56 - ?>
57 - />
53 + <?php if ( $type === 'bool' ) { ?>
54 + <input type="checkbox" <?php echo wp_kses_post( $attributes ); ?> value="true"
55 + <?php checked( get_option( $key ), 'true' ); ?> />
58 56 <?php } elseif ( is_array( $type ) ) { ?>
59 - <select <?php echo $attributes; ?>>
57 + <select <?php echo wp_kses_post( $attributes ); ?>>
60 58 <?php foreach ( $type as $option ) { ?>
61 - <option value="<?php echo $option; ?>"
62 - <?php
63 - if ( get_option( $key ) == $option ) {
64 - echo ' selected';}
65 - ?>
66 - ><?php echo ucwords( str_replace( '-', ' ', $option ) ); ?></option>
59 + <option value="<?php echo esc_attr( $option ); ?>" <?php selected( get_option( $key ), $option ); ?>>
60 + <?php echo esc_html( ucwords( str_replace( '-', ' ', $option ) ) ); ?>
61 + </option>
67 62 <?php } ?>
68 63 </select>
69 64 <?php } else { ?>
70 - <input type="<?php echo $type; ?>" <?php echo $attributes; ?> value="<?php echo get_option( $key ); ?>" data-lpignore="true" />
65 + <input type="<?php echo esc_attr( $type ); ?>" <?php echo wp_kses_post( $attributes ); ?>
66 + value="<?php echo esc_attr( get_option( $key ) ); ?>" data-lpignore="true" />
71 67 <?php } ?>
68 +
72 69 <?php if ( ! empty( $label ) ) { ?>
73 - <label for="<?php echo $key; ?>"><?php echo $label; ?></label>
70 + <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></label>
74 71 <?php } ?>
72 +
75 73 <?php if ( ! empty( $description ) ) { ?>
76 - <p class="description"><?php echo $description; ?></p>
74 + <p class="description"><?php echo wp_kses_post( $description ); ?></p>
77 75 <?php } ?>
78 76 </td>
79 77 </tr>
80 78 <?php
@@ -154,5 +152,22 @@
154 152
155 153 // Return the parsed results
156 154 return $r;
157 155 }
156 +}
157 +
158 +
159 +if ( ! function_exists( 'forumax_init_voting_scores' ) ) {
160 + /**
161 + * Initialize voting scores for new topics and replies.
162 + *
163 + * @param int $post_id Post ID.
164 + */
165 + function forumax_init_voting_scores( $post_id ) {
166 + update_post_meta( $post_id, 'bbp_voting_score', '0' );
167 + update_post_meta( $post_id, 'bbp_voting_ups', '0' );
168 + update_post_meta( $post_id, 'bbp_voting_downs', '0' );
169 + update_post_meta( $post_id, 'bbp_voting_log', [] );
170 + }
171 + add_action( 'bbp_new_topic', 'forumax_init_voting_scores' );
172 + add_action( 'bbp_new_reply', 'forumax_init_voting_scores' );
158 173 }