PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.3
Forumax – AI Powered Advanced Community Forum Plugin v1.2.3
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 / features / bbp_voting / metabox.php

metabox.php in Forumax – AI Powered Advanced Community Forum Plugin 1.2.3, at includes/features/bbp_voting/metabox.php

130 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
130