PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.4.1
Forumax – AI Powered Advanced Community Forum Plugin v1.4.1
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.4.1, at includes/features/bbp_voting/metabox.php

139 lines 3.8 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', 'bbp-core' ),
24 'true' => __( 'Enable', 'bbp-core' ),
25 'false' => __( 'Disable', 'bbp-core' ),
26 ];
27 ?>
28 <p class="description">
29 <?php esc_html_e( 'Enable or disable voting on topics or replies, only for this forum.', 'bbp-core' ); ?>
30 </p>
31
32 <p>
33 <strong class="label"><?php esc_html_e( 'Voting on Topics:', 'bbp-core' ); ?></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:', 'bbp-core' ); ?></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.', 'bbp-core' ); ?>
68 </p>
69
70 <p>
71 <strong class="label"><?php esc_html_e( 'Sort Topics by Votes:', 'bbp-core' ); ?></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:', 'bbp-core' ); ?></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 }
139