PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
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 2.0.0 All 30 releases
← All changes | includes/features/bbp_voting/metabox.php +138 -129 1.3.1 → 2.5.0 View file →
@@ -1,129 +1,138 @@
1 -<?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - exit; // Exit if accessed directly.
4 -}
5 -
6 -// Add meta box.
7 -add_action( 'add_meta_boxes', 'bbp_voting_metaboxes' );
8 -function bbp_voting_metaboxes() {
9 - add_meta_box(
10 - 'bbp_voting',
11 - 'bbPress Voting',
12 - 'bbp_voting_forum_metabox',
13 - 'forum',
14 - 'side',
15 - 'low'
16 - );
17 -}
18 -
19 -// Meta box form.
20 -function bbp_voting_forum_metabox() {
21 - $post_id = get_the_ID();
22 - $options = [
23 - '' => 'Default',
24 - 'true' => 'Enable',
25 - 'false' => 'Disable',
26 - ];
27 - ?>
28 - <p class="description">
29 - Enable or disable voting on topics or replies, only for this forum.
30 - </p>
31 - <p>
32 - <strong class="label">Voting on Topics:</strong>
33 - <select type="checkbox" name="bbp_voting_forum_enable_topics" value="true" id="bbp_voting_forum_enable_topics" class="bbp_dropdown">
34 - <?php
35 - $selected = get_post_meta( $post_id, 'bbp_voting_forum_enable_topics', true );
36 - foreach ( $options as $value => $label ) {
37 - echo '<option value="' . $value . '" ';
38 - if ( $selected == $value ) {
39 - echo 'selected';
40 - }
41 - echo '>' . $label . '</option>';
42 - }
43 - ?>
44 - </select>
45 - </p>
46 - <p>
47 - <strong class="label">Voting on Replies:</strong>
48 - <select type="checkbox" name="bbp_voting_forum_enable_replies" value="true" id="bbp_voting_forum_enable_replies" class="bbp_dropdown">
49 - <?php
50 - $selected = get_post_meta( $post_id, 'bbp_voting_forum_enable_replies', true );
51 - foreach ( $options as $value => $label ) {
52 - echo '<option value="' . $value . '" ';
53 - if ( $selected == $value ) {
54 - echo 'selected';
55 - }
56 - echo '>' . $label . '</option>';
57 - }
58 - ?>
59 - </select>
60 - </p>
61 - <p class="description">
62 - Enable or disable sorting based on votes on topics or replies, only for this forum.
63 - </p>
64 - <p>
65 - <strong class="label">Sort Topics by Votes:</strong>
66 - <select type="checkbox" name="sort_bbpress_topics_by_votes_on_forum" value="true" id="sort_bbpress_topics_by_votes_on_forum" class="bbp_dropdown">
67 - <?php
68 - $selected = get_post_meta( $post_id, 'sort_bbpress_topics_by_votes_on_forum', true );
69 - foreach ( $options as $value => $label ) {
70 - echo '<option value="' . $value . '" ';
71 - if ( $selected == $value ) {
72 - echo 'selected';
73 - }
74 - echo '>' . $label . '</option>';
75 - }
76 - ?>
77 - </select>
78 - </p>
79 - <p>
80 - <strong class="label">Sort Replies by Votes:</strong>
81 - <select type="checkbox" name="sort_bbpress_replies_by_votes_on_forum" value="true" id="sort_bbpress_replies_by_votes_on_forum" class="bbp_dropdown">
82 - <?php
83 - $selected = get_post_meta( $post_id, 'sort_bbpress_replies_by_votes_on_forum', true );
84 - foreach ( $options as $value => $label ) {
85 - echo '<option value="' . $value . '" ';
86 - if ( $selected == $value ) {
87 - echo 'selected';
88 - }
89 - echo '>' . $label . '</option>';
90 - }
91 - ?>
92 - </select>
93 - </p>
94 - <?php
95 -}
96 -
97 -// Save meta box data
98 -
99 -add_action( 'save_post', 'bbp_voting_save_forum_metabox' );
100 -function bbp_voting_save_forum_metabox( $post_id ) {
101 - if ( array_key_exists( 'bbp_voting_forum_enable_topics', $_POST ) ) {
102 - update_post_meta(
103 - $post_id,
104 - 'bbp_voting_forum_enable_topics',
105 - $_POST['bbp_voting_forum_enable_topics']
106 - );
107 - }
108 - if ( array_key_exists( 'bbp_voting_forum_enable_replies', $_POST ) ) {
109 - update_post_meta(
110 - $post_id,
111 - 'bbp_voting_forum_enable_replies',
112 - $_POST['bbp_voting_forum_enable_replies']
113 - );
114 - }
115 - if ( array_key_exists( 'sort_bbpress_topics_by_votes_on_forum', $_POST ) ) {
116 - update_post_meta(
117 - $post_id,
118 - 'sort_bbpress_topics_by_votes_on_forum',
119 - $_POST['sort_bbpress_topics_by_votes_on_forum']
120 - );
121 - }
122 - if ( array_key_exists( 'sort_bbpress_replies_by_votes_on_forum', $_POST ) ) {
123 - update_post_meta(
124 - $post_id,
125 - 'sort_bbpress_replies_by_votes_on_forum',
126 - $_POST['sort_bbpress_replies_by_votes_on_forum']
127 - );
128 - }
129 -}
1 +<?php
2 +if ( ! defined( 'ABSPATH' ) ) {
3 + exit; // Exit if accessed directly.
4 +}
5 +
6 +// Add meta box.
7 +add_action( 'add_meta_boxes', 'bbp_voting_metaboxes' );
8 +function bbp_voting_metaboxes() {
9 + add_meta_box(
10 + 'bbp_voting',
11 + 'bbPress Voting',
12 + 'bbp_voting_forum_metabox',
13 + 'forum',
14 + 'side',
15 + 'low'
16 + );
17 +}
18 +
19 +// Meta box form.
20 +function bbp_voting_forum_metabox() {
21 + $post_id = get_the_ID();
22 + $options = [
23 + '' => __( 'Default', 'forumax' ),
24 + 'true' => __( 'Enable', 'forumax' ),
25 + 'false' => __( 'Disable', 'forumax' ),
26 + ];
27 + ?>
28 + <p class="description">
29 + <?php esc_html_e( 'Enable or disable voting on topics or replies, only for this forum.', 'forumax' ); ?>
30 + </p>
31 +
32 + <p>
33 + <strong class="label"><?php esc_html_e( 'Voting on Topics:', 'forumax' ); ?></strong>
34 + <select name="bbp_voting_forum_enable_topics" id="bbp_voting_forum_enable_topics" class="bbp_dropdown">
35 + <?php
36 + $selected = get_post_meta( $post_id, 'bbp_voting_forum_enable_topics', true );
37 + foreach ( $options as $value => $label ) {
38 + printf(
39 + '<option value="%s" %s>%s</option>',
40 + esc_attr( $value ),
41 + selected( $selected, $value, false ),
42 + esc_html( $label )
43 + );
44 + }
45 + ?>
46 + </select>
47 + </p>
48 +
49 + <p>
50 + <strong class="label"><?php esc_html_e( 'Voting on Replies:', 'forumax' ); ?></strong>
51 + <select name="bbp_voting_forum_enable_replies" id="bbp_voting_forum_enable_replies" class="bbp_dropdown">
52 + <?php
53 + $selected = get_post_meta( $post_id, 'bbp_voting_forum_enable_replies', true );
54 + foreach ( $options as $value => $label ) {
55 + printf(
56 + '<option value="%s" %s>%s</option>',
57 + esc_attr( $value ),
58 + selected( $selected, $value, false ),
59 + esc_html( $label )
60 + );
61 + }
62 + ?>
63 + </select>
64 + </p>
65 +
66 + <p class="description">
67 + <?php esc_html_e( 'Enable or disable sorting based on votes on topics or replies, only for this forum.', 'forumax' ); ?>
68 + </p>
69 +
70 + <p>
71 + <strong class="label"><?php esc_html_e( 'Sort Topics by Votes:', 'forumax' ); ?></strong>
72 + <select name="sort_bbpress_topics_by_votes_on_forum" id="sort_bbpress_topics_by_votes_on_forum" class="bbp_dropdown">
73 + <?php
74 + $selected = get_post_meta( $post_id, 'sort_bbpress_topics_by_votes_on_forum', true );
75 + foreach ( $options as $value => $label ) {
76 + printf(
77 + '<option value="%s" %s>%s</option>',
78 + esc_attr( $value ),
79 + selected( $selected, $value, false ),
80 + esc_html( $label )
81 + );
82 + }
83 + ?>
84 + </select>
85 + </p>
86 +
87 + <p>
88 + <strong class="label"><?php esc_html_e( 'Sort Replies by Votes:', 'forumax' ); ?></strong>
89 + <select name="sort_bbpress_replies_by_votes_on_forum" id="sort_bbpress_replies_by_votes_on_forum" class="bbp_dropdown">
90 + <?php
91 + $selected = get_post_meta( $post_id, 'sort_bbpress_replies_by_votes_on_forum', true );
92 + foreach ( $options as $value => $label ) {
93 + printf(
94 + '<option value="%s" %s>%s</option>',
95 + esc_attr( $value ),
96 + selected( $selected, $value, false ),
97 + esc_html( $label )
98 + );
99 + }
100 + ?>
101 + </select>
102 + </p>
103 + <?php
104 +}
105 +
106 +// Save meta box data
107 +
108 +add_action( 'save_post', 'bbp_voting_save_forum_metabox' );
109 +function bbp_voting_save_forum_metabox( $post_id ) {
110 + if ( array_key_exists( 'bbp_voting_forum_enable_topics', $_POST ) ) {
111 + update_post_meta(
112 + $post_id,
113 + 'bbp_voting_forum_enable_topics',
114 + $_POST['bbp_voting_forum_enable_topics']
115 + );
116 + }
117 + if ( array_key_exists( 'bbp_voting_forum_enable_replies', $_POST ) ) {
118 + update_post_meta(
119 + $post_id,
120 + 'bbp_voting_forum_enable_replies',
121 + $_POST['bbp_voting_forum_enable_replies']
122 + );
123 + }
124 + if ( array_key_exists( 'sort_bbpress_topics_by_votes_on_forum', $_POST ) ) {
125 + update_post_meta(
126 + $post_id,
127 + 'sort_bbpress_topics_by_votes_on_forum',
128 + $_POST['sort_bbpress_topics_by_votes_on_forum']
129 + );
130 + }
131 + if ( array_key_exists( 'sort_bbpress_replies_by_votes_on_forum', $_POST ) ) {
132 + update_post_meta(
133 + $post_id,
134 + 'sort_bbpress_replies_by_votes_on_forum',
135 + $_POST['sort_bbpress_replies_by_votes_on_forum']
136 + );
137 + }
138 +}