| @@ -9,38 +9,101 @@ | ||
| 9 | 9 | |
| 10 | 10 | /** Dashboard *****************************************************************/ |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | + * Filter the Dashboard "at a glance" items and append bbPress elements to it. | |
| 14 | + * | |
| 15 | + * @since 2.6.0 bbPress (r5268) | |
| 16 | + * | |
| 17 | + * @param array $elements | |
| 18 | + * @return array | |
| 19 | + */ | |
| 20 | +function bbp_filter_dashboard_glance_items( $elements = array() ) { | |
| 21 | + | |
| 22 | + // Bail if user cannot spectate | |
| 23 | + if ( ! current_user_can( 'spectate' ) ) { | |
| 24 | + return $elements; | |
| 25 | + } | |
| 26 | + | |
| 27 | + // Get the statistics | |
| 28 | + $r = bbp_get_statistics( array( | |
| 29 | + 'count_pending_topics' => false, | |
| 30 | + 'count_private_topics' => false, | |
| 31 | + 'count_spammed_topics' => false, | |
| 32 | + 'count_trashed_topics' => false, | |
| 33 | + 'count_pending_replies' => false, | |
| 34 | + 'count_private_replies' => false, | |
| 35 | + 'count_spammed_replies' => false, | |
| 36 | + 'count_trashed_replies' => false, | |
| 37 | + 'count_empty_tags' => false | |
| 38 | + ) ); | |
| 39 | + | |
| 40 | + // Users | |
| 41 | + if ( isset( $r['user_count'] ) ) { | |
| 42 | + $link = admin_url( 'users.php' ); | |
| 43 | + $text = sprintf( _n( '%s User', '%s Users', $r['user_count_int'], 'bbpress' ), $r['user_count'] ); | |
| 44 | + $elements[] = current_user_can( 'edit_users' ) | |
| 45 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-users">' . esc_html( $text ) . '</a>' | |
| 46 | + : esc_html( $text ); | |
| 47 | + } | |
| 48 | + | |
| 49 | + // Forums | |
| 50 | + if ( isset( $r['forum_count'] ) ) { | |
| 51 | + $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) ); | |
| 52 | + $text = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count_int'], 'bbpress' ), $r['forum_count'] ); | |
| 53 | + $elements[] = current_user_can( 'publish_forums' ) | |
| 54 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-forums">' . esc_html( $text ) . '</a>' | |
| 55 | + : esc_html( $text ); | |
| 56 | + } | |
| 57 | + | |
| 58 | + // Topics | |
| 59 | + if ( isset( $r['topic_count'] ) ) { | |
| 60 | + $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); | |
| 61 | + $text = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count_int'], 'bbpress' ), $r['topic_count'] ); | |
| 62 | + $elements[] = current_user_can( 'publish_topics' ) | |
| 63 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topics">' . esc_html( $text ) . '</a>' | |
| 64 | + : esc_html( $text ); | |
| 65 | + } | |
| 66 | + | |
| 67 | + // Replies | |
| 68 | + if ( isset( $r['reply_count'] ) ) { | |
| 69 | + $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); | |
| 70 | + $text = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count_int'], 'bbpress' ), $r['reply_count'] ); | |
| 71 | + $elements[] = current_user_can( 'publish_replies' ) | |
| 72 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-replies">' . esc_html( $text ) . '</a>' | |
| 73 | + : esc_html( $text ); | |
| 74 | + } | |
| 75 | + | |
| 76 | + // Topic Tags | |
| 77 | + if ( bbp_allow_topic_tags() && isset( $r['topic_tag_count'] ) ) { | |
| 78 | + $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) ); | |
| 79 | + $text = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count_int'], 'bbpress' ), $r['topic_tag_count'] ); | |
| 80 | + $elements[] = current_user_can( 'manage_topic_tags' ) | |
| 81 | + ? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topic-tags">' . esc_html( $text ) . '</a>' | |
| 82 | + : esc_html( $text ); | |
| 83 | + } | |
| 84 | + | |
| 85 | + // Filter & return | |
| 86 | + return apply_filters( 'bbp_dashboard_at_a_glance', $elements, $r ); | |
| 87 | +} | |
| 88 | + | |
| 89 | +/** | |
| 13 | 90 | * bbPress Dashboard Right Now Widget |
| 14 | 91 | * |
| 15 | 92 | * Adds a dashboard widget with forum statistics |
| 16 | 93 | * |
| 17 | - * @since bbPress (r2770) | |
| 94 | + * @since 2.0.0 bbPress (r2770) | |
| 18 | 95 | * |
| 19 | - * @uses bbp_get_version() To get the current bbPress version | |
| 20 | - * @uses bbp_get_statistics() To get the forum statistics | |
| 21 | - * @uses current_user_can() To check if the user is capable of doing things | |
| 22 | - * @uses bbp_get_forum_post_type() To get the forum post type | |
| 23 | - * @uses bbp_get_topic_post_type() To get the topic post type | |
| 24 | - * @uses bbp_get_reply_post_type() To get the reply post type | |
| 25 | - * @uses get_admin_url() To get the administration url | |
| 26 | - * @uses add_query_arg() To add custom args to the url | |
| 27 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_content_table_end' | |
| 28 | - * below the content table | |
| 29 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_table_end' | |
| 30 | - * below the discussion table | |
| 31 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_discussion_table_end' | |
| 32 | - * below the discussion table | |
| 33 | - * @uses do_action() Calls 'bbp_dashboard_widget_right_now_end' below the widget | |
| 96 | + * @deprecated 2.6.0 bbPress (r5268) | |
| 34 | 97 | */ |
| 35 | 98 | function bbp_dashboard_widget_right_now() { |
| 36 | 99 | |
| 37 | - // Get the statistics and extract them | |
| 38 | - extract( bbp_get_statistics(), EXTR_SKIP ); ?> | |
| 100 | + // Get the statistics | |
| 101 | + $r = bbp_get_statistics(); ?> | |
| 39 | 102 | |
| 40 | 103 | <div class="table table_content"> |
| 41 | 104 | |
| 42 | - <p class="sub"><?php _e( 'Discussion', 'bbpress' ); ?></p> | |
| 105 | + <p class="sub"><?php esc_html_e( 'Discussion', 'bbpress' ); ?></p> | |
| 43 | 106 | |
| 44 | 107 | <table> |
| 45 | 108 | |
| 46 | 109 | <tr class="first"> |
| @@ -45,14 +108,14 @@ | ||
| 45 | 108 | |
| 46 | 109 | <tr class="first"> |
| 47 | 110 | |
| 48 | 111 | <?php |
| 49 | - $num = $forum_count; | |
| 50 | - $text = _n( 'Forum', 'Forums', $forum_count, 'bbpress' ); | |
| 112 | + $num = $r['forum_count']; | |
| 113 | + $text = _n( 'Forum', 'Forums', $r['forum_count_int'], 'bbpress' ); | |
| 51 | 114 | if ( current_user_can( 'publish_forums' ) ) { |
| 52 | - $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 53 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 54 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 115 | + $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) ); | |
| 116 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 117 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 55 | 118 | } |
| 56 | 119 | ?> |
| 57 | 120 | |
| 58 | 121 | <td class="first b b-forums"><?php echo $num; ?></td> |
| @@ -62,14 +125,14 @@ | ||
| 62 | 125 | |
| 63 | 126 | <tr> |
| 64 | 127 | |
| 65 | 128 | <?php |
| 66 | - $num = $topic_count; | |
| 67 | - $text = _n( 'Topic', 'Topics', $topic_count, 'bbpress' ); | |
| 129 | + $num = $r['topic_count']; | |
| 130 | + $text = _n( 'Topic', 'Topics', $r['topic_count_int'], 'bbpress' ); | |
| 68 | 131 | if ( current_user_can( 'publish_topics' ) ) { |
| 69 | - $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 70 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 71 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 132 | + $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); | |
| 133 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 134 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 72 | 135 | } |
| 73 | 136 | ?> |
| 74 | 137 | |
| 75 | 138 | <td class="first b b-topics"><?php echo $num; ?></td> |
| @@ -79,14 +142,14 @@ | ||
| 79 | 142 | |
| 80 | 143 | <tr> |
| 81 | 144 | |
| 82 | 145 | <?php |
| 83 | - $num = $reply_count; | |
| 84 | - $text = _n( 'Reply', 'Replies', $reply_count, 'bbpress' ); | |
| 146 | + $num = $r['reply_count']; | |
| 147 | + $text = _n( 'Reply', 'Replies', $r['reply_count_int'], 'bbpress' ); | |
| 85 | 148 | if ( current_user_can( 'publish_replies' ) ) { |
| 86 | - $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 87 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 88 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 149 | + $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); | |
| 150 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 151 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 89 | 152 | } |
| 90 | 153 | ?> |
| 91 | 154 | |
| 92 | 155 | <td class="first b b-replies"><?php echo $num; ?></td> |
| @@ -98,14 +161,14 @@ | ||
| 98 | 161 | |
| 99 | 162 | <tr> |
| 100 | 163 | |
| 101 | 164 | <?php |
| 102 | - $num = $topic_tag_count; | |
| 103 | - $text = _n( 'Topic Tag', 'Topic Tags', $topic_tag_count, 'bbpress' ); | |
| 165 | + $num = $r['topic_tag_count']; | |
| 166 | + $text = _n( 'Topic Tag', 'Topic Tags', $r['topic_tag_count_int'], 'bbpress' ); | |
| 104 | 167 | if ( current_user_can( 'manage_topic_tags' ) ) { |
| 105 | - $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) ); | |
| 106 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 107 | - $text = '<a href="' . $link . '">' . $text . '</a>'; | |
| 168 | + $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) ); | |
| 169 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 170 | + $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 108 | 171 | } |
| 109 | 172 | ?> |
| 110 | 173 | |
| 111 | 174 | <td class="first b b-topic_tags"><span class="total-count"><?php echo $num; ?></span></td> |
| @@ -123,9 +186,9 @@ | ||
| 123 | 186 | |
| 124 | 187 | |
| 125 | 188 | <div class="table table_discussion"> |
| 126 | 189 | |
| 127 | - <p class="sub"><?php _e( 'Users & Moderation', 'bbpress' ); ?></p> | |
| 190 | + <p class="sub"><?php esc_html_e( 'Users & Moderation', 'bbpress' ); ?></p> | |
| 128 | 191 | |
| 129 | 192 | <table> |
| 130 | 193 | |
| 131 | 194 | <tr class="first"> |
| @@ -130,12 +193,12 @@ | ||
| 130 | 193 | |
| 131 | 194 | <tr class="first"> |
| 132 | 195 | |
| 133 | 196 | <?php |
| 134 | - $num = $user_count; | |
| 135 | - $text = _n( 'User', 'Users', $user_count, 'bbpress' ); | |
| 197 | + $num = $r['user_count']; | |
| 198 | + $text = _n( 'User', 'Users', $r['user_count_int'], 'bbpress' ); | |
| 136 | 199 | if ( current_user_can( 'edit_users' ) ) { |
| 137 | - $link = get_admin_url( null, 'users.php' ); | |
| 200 | + $link = admin_url( 'users.php' ); | |
| 138 | 201 | $num = '<a href="' . $link . '">' . $num . '</a>'; |
| 139 | 202 | $text = '<a href="' . $link . '">' . $text . '</a>'; |
| 140 | 203 | } |
| 141 | 204 | ?> |
| @@ -144,21 +207,21 @@ | ||
| 144 | 207 | <td class="last t users"><?php echo $text; ?></td> |
| 145 | 208 | |
| 146 | 209 | </tr> |
| 147 | 210 | |
| 148 | - <?php if ( isset( $topic_count_hidden ) ) : ?> | |
| 211 | + <?php if ( isset( $r['topic_count_hidden'] ) ) : ?> | |
| 149 | 212 | |
| 150 | 213 | <tr> |
| 151 | 214 | |
| 152 | 215 | <?php |
| 153 | - $num = $topic_count_hidden; | |
| 154 | - $text = _n( 'Hidden Topic', 'Hidden Topics', $topic_count_hidden, 'bbpress' ); | |
| 155 | - $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 156 | - if ( '0' != $num ) { | |
| 216 | + $num = $r['topic_count_hidden']; | |
| 217 | + $text = _n( 'Hidden Topic', 'Hidden Topics', $r['topic_count_hidden_int'], 'bbpress' ); | |
| 218 | + $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) ); | |
| 219 | + if ( '0' !== $num ) { | |
| 157 | 220 | $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); |
| 158 | 221 | } |
| 159 | - $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $num . '</a>'; | |
| 160 | - $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_topic_title ) . '">' . $text . '</a>'; | |
| 222 | + $num = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $num . '</a>'; | |
| 223 | + $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $text . '</a>'; | |
| 161 | 224 | ?> |
| 162 | 225 | |
| 163 | 226 | <td class="b b-hidden-topics"><?php echo $num; ?></td> |
| 164 | 227 | <td class="last t hidden-replies"><?php echo $text; ?></td> |
| @@ -166,21 +229,21 @@ | ||
| 166 | 229 | </tr> |
| 167 | 230 | |
| 168 | 231 | <?php endif; ?> |
| 169 | 232 | |
| 170 | - <?php if ( isset( $reply_count_hidden ) ) : ?> | |
| 233 | + <?php if ( isset( $r['reply_count_hidden'] ) ) : ?> | |
| 171 | 234 | |
| 172 | 235 | <tr> |
| 173 | 236 | |
| 174 | 237 | <?php |
| 175 | - $num = $reply_count_hidden; | |
| 176 | - $text = _n( 'Hidden Reply', 'Hidden Replies', $reply_count_hidden, 'bbpress' ); | |
| 177 | - $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) ); | |
| 178 | - if ( '0' != $num ) { | |
| 238 | + $num = $r['reply_count_hidden']; | |
| 239 | + $text = _n( 'Hidden Reply', 'Hidden Replies', $r['reply_count_hidden_int'], 'bbpress' ); | |
| 240 | + $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ); | |
| 241 | + if ( '0' !== $num ) { | |
| 179 | 242 | $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link ); |
| 180 | 243 | } |
| 181 | - $num = '<a href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $num . '</a>'; | |
| 182 | - $text = '<a class="waiting" href="' . $link . '" title="' . esc_attr( $hidden_reply_title ) . '">' . $text . '</a>'; | |
| 244 | + $num = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $num . '</a>'; | |
| 245 | + $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $text . '</a>'; | |
| 183 | 246 | ?> |
| 184 | 247 | |
| 185 | 248 | <td class="b b-hidden-replies"><?php echo $num; ?></td> |
| 186 | 249 | <td class="last t hidden-replies"><?php echo $text; ?></td> |
| @@ -188,18 +251,18 @@ | ||
| 188 | 251 | </tr> |
| 189 | 252 | |
| 190 | 253 | <?php endif; ?> |
| 191 | 254 | |
| 192 | - <?php if ( bbp_allow_topic_tags() && isset( $empty_topic_tag_count ) ) : ?> | |
| 255 | + <?php if ( bbp_allow_topic_tags() && isset( $r['empty_topic_tag_count'] ) ) : ?> | |
| 193 | 256 | |
| 194 | 257 | <tr> |
| 195 | 258 | |
| 196 | 259 | <?php |
| 197 | - $num = $empty_topic_tag_count; | |
| 198 | - $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $empty_topic_tag_count, 'bbpress' ); | |
| 199 | - $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) ); | |
| 200 | - $num = '<a href="' . $link . '">' . $num . '</a>'; | |
| 201 | - $text = '<a class="waiting" href="' . $link . '">' . $text . '</a>'; | |
| 260 | + $num = $r['empty_topic_tag_count']; | |
| 261 | + $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $r['empty_topic_tag_count_int'], 'bbpress' ); | |
| 262 | + $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) ); | |
| 263 | + $num = '<a href="' . esc_url( $link ) . '">' . $num . '</a>'; | |
| 264 | + $text = '<a class="waiting" href="' . esc_url( $link ) . '">' . $text . '</a>'; | |
| 202 | 265 | ?> |
| 203 | 266 | |
| 204 | 267 | <td class="b b-hidden-topic-tags"><?php echo $num; ?></td> |
| 205 | 268 | <td class="last t hidden-topic-tags"><?php echo $text; ?></td> |
| @@ -233,24 +296,17 @@ | ||
| 233 | 296 | |
| 234 | 297 | /** Forums ********************************************************************/ |
| 235 | 298 | |
| 236 | 299 | /** |
| 237 | - * Forum metabox | |
| 300 | + * Forum meta-box | |
| 238 | 301 | * |
| 239 | - * The metabox that holds all of the additional forum information | |
| 302 | + * The meta-box that holds all of the additional forum information | |
| 240 | 303 | * |
| 241 | - * @since bbPress (r2744) | |
| 242 | - * | |
| 243 | - * @uses bbp_is_forum_closed() To check if a forum is closed or not | |
| 244 | - * @uses bbp_is_forum_category() To check if a forum is a category or not | |
| 245 | - * @uses bbp_is_forum_private() To check if a forum is private or not | |
| 246 | - * @uses bbp_dropdown() To show a dropdown of the forums for forum parent | |
| 247 | - * @uses do_action() Calls 'bbp_forum_metabox' | |
| 304 | + * @since 2.0.0 bbPress (r2744) | |
| 248 | 305 | */ |
| 249 | -function bbp_forum_metabox() { | |
| 306 | +function bbp_forum_metabox( $post ) { | |
| 250 | 307 | |
| 251 | 308 | // Post ID |
| 252 | - $post_id = get_the_ID(); | |
| 253 | 309 | $post_parent = bbp_get_global_post_field( 'post_parent', 'raw' ); |
| 254 | 310 | $menu_order = bbp_get_global_post_field( 'menu_order', 'edit' ); |
| 255 | 311 | |
| 256 | 312 | /** Type ******************************************************************/ |
| @@ -257,11 +313,11 @@ | ||
| 257 | 313 | |
| 258 | 314 | ?> |
| 259 | 315 | |
| 260 | 316 | <p> |
| 261 | - <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong> | |
| 262 | - <label class="screen-reader-text" for="bbp_forum_type_select"><?php _e( 'Type:', 'bbpress' ) ?></label> | |
| 263 | - <?php bbp_form_forum_type_dropdown( $post_id ); ?> | |
| 317 | + <strong class="label"><?php esc_html_e( 'Type:', 'bbpress' ); ?></strong> | |
| 318 | + <label class="screen-reader-text" for="bbp_forum_type_select"><?php esc_html_e( 'Type:', 'bbpress' ) ?></label> | |
| 319 | + <?php bbp_form_forum_type_dropdown( array( 'forum_id' => $post->ID ) ); ?> | |
| 264 | 320 | </p> |
| 265 | 321 | |
| 266 | 322 | <?php |
| 267 | 323 | |
| @@ -269,11 +325,11 @@ | ||
| 269 | 325 | |
| 270 | 326 | ?> |
| 271 | 327 | |
| 272 | 328 | <p> |
| 273 | - <strong class="label"><?php _e( 'Status:', 'bbpress' ); ?></strong> | |
| 274 | - <label class="screen-reader-text" for="bbp_forum_status_select"><?php _e( 'Status:', 'bbpress' ) ?></label> | |
| 275 | - <?php bbp_form_forum_status_dropdown( $post_id ); ?> | |
| 329 | + <strong class="label"><?php esc_html_e( 'Status:', 'bbpress' ); ?></strong> | |
| 330 | + <label class="screen-reader-text" for="bbp_forum_status_select"><?php esc_html_e( 'Status:', 'bbpress' ) ?></label> | |
| 331 | + <?php bbp_form_forum_status_dropdown( array( 'forum_id' => $post->ID ) ); ?> | |
| 276 | 332 | </p> |
| 277 | 333 | |
| 278 | 334 | <?php |
| 279 | 335 | |
| @@ -281,11 +337,11 @@ | ||
| 281 | 337 | |
| 282 | 338 | ?> |
| 283 | 339 | |
| 284 | 340 | <p> |
| 285 | - <strong class="label"><?php _e( 'Visibility:', 'bbpress' ); ?></strong> | |
| 286 | - <label class="screen-reader-text" for="bbp_forum_visibility_select"><?php _e( 'Visibility:', 'bbpress' ) ?></label> | |
| 287 | - <?php bbp_form_forum_visibility_dropdown( $post_id ); ?> | |
| 341 | + <strong class="label"><?php esc_html_e( 'Visibility:', 'bbpress' ); ?></strong> | |
| 342 | + <label class="screen-reader-text" for="bbp_forum_visibility_select"><?php esc_html_e( 'Visibility:', 'bbpress' ) ?></label> | |
| 343 | + <?php bbp_form_forum_visibility_dropdown( array( 'forum_id' => $post->ID ) ); ?> | |
| 288 | 344 | </p> |
| 289 | 345 | |
| 290 | 346 | <hr /> |
| 291 | 347 | |
| @@ -295,26 +351,23 @@ | ||
| 295 | 351 | |
| 296 | 352 | ?> |
| 297 | 353 | |
| 298 | 354 | <p> |
| 299 | - <strong class="label"><?php _e( 'Parent:', 'bbpress' ); ?></strong> | |
| 300 | - <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum Parent', 'bbpress' ); ?></label> | |
| 355 | + <strong class="label"><?php esc_html_e( 'Parent:', 'bbpress' ); ?></strong> | |
| 356 | + <label class="screen-reader-text" for="parent_id"><?php esc_html_e( 'Forum Parent', 'bbpress' ); ?></label> | |
| 301 | 357 | <?php bbp_dropdown( array( |
| 302 | 358 | 'post_type' => bbp_get_forum_post_type(), |
| 303 | 359 | 'selected' => $post_parent, |
| 304 | - 'child_of' => '0', | |
| 305 | 360 | 'numberposts' => -1, |
| 306 | 361 | 'orderby' => 'title', |
| 307 | 362 | 'order' => 'ASC', |
| 308 | 363 | 'walker' => '', |
| 309 | - 'exclude' => $post_id, | |
| 364 | + 'exclude' => $post->ID, | |
| 310 | 365 | |
| 311 | 366 | // Output-related |
| 312 | 367 | 'select_id' => 'parent_id', |
| 313 | - 'tab' => bbp_get_tab_index(), | |
| 314 | 368 | 'options_only' => false, |
| 315 | - 'show_none' => __( '— No parent —', 'bbpress' ), | |
| 316 | - 'none_found' => false, | |
| 369 | + 'show_none' => esc_html__( '— No parent —', 'bbpress' ), | |
| 317 | 370 | 'disable_categories' => false, |
| 318 | 371 | 'disabled' => '' |
| 319 | 372 | ) ); ?> |
| 320 | 373 | </p> |
| @@ -319,48 +372,68 @@ | ||
| 319 | 372 | ) ); ?> |
| 320 | 373 | </p> |
| 321 | 374 | |
| 322 | 375 | <p> |
| 323 | - <strong class="label"><?php _e( 'Order:', 'bbpress' ); ?></strong> | |
| 324 | - <label class="screen-reader-text" for="menu_order"><?php _e( 'Forum Order', 'bbpress' ); ?></label> | |
| 376 | + <strong class="label"><?php esc_html_e( 'Order:', 'bbpress' ); ?></strong> | |
| 377 | + <label class="screen-reader-text" for="menu_order"><?php esc_html_e( 'Forum Order', 'bbpress' ); ?></label> | |
| 325 | 378 | <input name="menu_order" type="number" step="1" size="4" id="menu_order" value="<?php echo esc_attr( $menu_order ); ?>" /> |
| 326 | 379 | </p> |
| 327 | 380 | |
| 381 | + <input name="ping_status" type="hidden" id="ping_status" value="open" /> | |
| 382 | + | |
| 328 | 383 | <?php |
| 329 | 384 | wp_nonce_field( 'bbp_forum_metabox_save', 'bbp_forum_metabox' ); |
| 330 | - do_action( 'bbp_forum_metabox', $post_id ); | |
| 385 | + do_action( 'bbp_forum_metabox', $post ); | |
| 331 | 386 | } |
| 332 | 387 | |
| 333 | 388 | /** Topics ********************************************************************/ |
| 334 | 389 | |
| 335 | 390 | /** |
| 336 | - * Topic metabox | |
| 391 | + * Topic meta-box | |
| 337 | 392 | * |
| 338 | - * The metabox that holds all of the additional topic information | |
| 393 | + * The meta-box that holds all of the additional topic information | |
| 339 | 394 | * |
| 340 | - * @since bbPress (r2464) | |
| 341 | - * | |
| 342 | - * @uses bbp_get_topic_forum_id() To get the topic forum id | |
| 343 | - * @uses do_action() Calls 'bbp_topic_metabox' | |
| 395 | + * @since 2.0.0 bbPress (r2464) | |
| 344 | 396 | */ |
| 345 | -function bbp_topic_metabox() { | |
| 397 | +function bbp_topic_metabox( $post ) { | |
| 346 | 398 | |
| 347 | - // Post ID | |
| 348 | - $post_id = get_the_ID(); ?> | |
| 399 | + /** Type ******************************************************************/ | |
| 349 | 400 | |
| 401 | + ?> | |
| 402 | + | |
| 350 | 403 | <p> |
| 351 | - <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong> | |
| 352 | - <label class="screen-reader-text" for="bbp_stick_topic"><?php _e( 'Topic Type', 'bbpress' ); ?></label> | |
| 353 | - <?php bbp_topic_type_select( array( 'topic_id' => $post_id ) ); ?> | |
| 404 | + <strong class="label"><?php esc_html_e( 'Type:', 'bbpress' ); ?></strong> | |
| 405 | + <label class="screen-reader-text" for="bbp_stick_topic"><?php esc_html_e( 'Topic Type', 'bbpress' ); ?></label> | |
| 406 | + <?php bbp_form_topic_type_dropdown( array( 'topic_id' => $post->ID ) ); ?> | |
| 354 | 407 | </p> |
| 355 | 408 | |
| 409 | + <?php | |
| 410 | + | |
| 411 | + /** Status ****************************************************************/ | |
| 412 | + | |
| 413 | + ?> | |
| 414 | + | |
| 356 | 415 | <p> |
| 357 | - <strong class="label"><?php _e( 'Forum:', 'bbpress' ); ?></strong> | |
| 358 | - <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum', 'bbpress' ); ?></label> | |
| 416 | + <strong class="label"><?php esc_html_e( 'Status:', 'bbpress' ); ?></strong> | |
| 417 | + <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' === $post->post_status ) ? 'draft' : $post->post_status ); ?>" /> | |
| 418 | + <label class="screen-reader-text" for="bbp_open_close_topic"><?php esc_html_e( 'Select whether to open or close the topic.', 'bbpress' ); ?></label> | |
| 419 | + <?php bbp_form_topic_status_dropdown( array( 'select_id' => 'post_status', 'topic_id' => $post->ID ) ); ?> | |
| 420 | + </p> | |
| 421 | + | |
| 422 | + <?php | |
| 423 | + | |
| 424 | + /** Parent *****************************************************************/ | |
| 425 | + | |
| 426 | + ?> | |
| 427 | + | |
| 428 | + <hr /> | |
| 429 | + | |
| 430 | + <p> | |
| 431 | + <strong class="label"><?php esc_html_e( 'Forum:', 'bbpress' ); ?></strong> | |
| 432 | + <label class="screen-reader-text" for="parent_id"><?php esc_html_e( 'Forum', 'bbpress' ); ?></label> | |
| 359 | 433 | <?php bbp_dropdown( array( |
| 360 | 434 | 'post_type' => bbp_get_forum_post_type(), |
| 361 | - 'selected' => bbp_get_topic_forum_id( $post_id ), | |
| 362 | - 'child_of' => '0', | |
| 435 | + 'selected' => bbp_get_topic_forum_id( $post->ID ), | |
| 363 | 436 | 'numberposts' => -1, |
| 364 | 437 | 'orderby' => 'title', |
| 365 | 438 | 'order' => 'ASC', |
| 366 | 439 | 'walker' => '', |
| @@ -367,53 +440,64 @@ | ||
| 367 | 440 | 'exclude' => '', |
| 368 | 441 | |
| 369 | 442 | // Output-related |
| 370 | 443 | 'select_id' => 'parent_id', |
| 371 | - 'tab' => bbp_get_tab_index(), | |
| 372 | 444 | 'options_only' => false, |
| 373 | - 'show_none' => __( '— No parent —', 'bbpress' ), | |
| 374 | - 'none_found' => false, | |
| 445 | + 'show_none' => esc_html__( '— No forum —', 'bbpress' ), | |
| 375 | 446 | 'disable_categories' => current_user_can( 'edit_forums' ), |
| 376 | 447 | 'disabled' => '' |
| 377 | 448 | ) ); ?> |
| 378 | 449 | </p> |
| 379 | 450 | |
| 451 | + <input name="ping_status" type="hidden" id="ping_status" value="open" /> | |
| 452 | + | |
| 380 | 453 | <?php |
| 381 | 454 | wp_nonce_field( 'bbp_topic_metabox_save', 'bbp_topic_metabox' ); |
| 382 | - do_action( 'bbp_topic_metabox', $post_id ); | |
| 455 | + do_action( 'bbp_topic_metabox', $post ); | |
| 383 | 456 | } |
| 384 | 457 | |
| 385 | 458 | /** Replies *******************************************************************/ |
| 386 | 459 | |
| 387 | 460 | /** |
| 388 | - * Reply metabox | |
| 461 | + * Reply meta-box | |
| 389 | 462 | * |
| 390 | - * The metabox that holds all of the additional reply information | |
| 463 | + * The meta-box that holds all of the additional reply information | |
| 391 | 464 | * |
| 392 | - * @since bbPress (r2464) | |
| 393 | - * | |
| 394 | - * @uses bbp_get_topic_post_type() To get the topic post type | |
| 395 | - * @uses do_action() Calls 'bbp_reply_metabox' | |
| 465 | + * @since 2.0.0 bbPress (r2464) | |
| 396 | 466 | */ |
| 397 | -function bbp_reply_metabox() { | |
| 467 | +function bbp_reply_metabox( $post ) { | |
| 398 | 468 | |
| 399 | - // Post ID | |
| 400 | - $post_id = get_the_ID(); | |
| 469 | + // Get some meta | |
| 470 | + $reply_topic_id = bbp_get_reply_topic_id( $post->ID ); | |
| 471 | + $reply_forum_id = bbp_get_reply_forum_id( $post->ID ); | |
| 472 | + $topic_forum_id = bbp_get_topic_forum_id( $reply_topic_id ); | |
| 401 | 473 | |
| 402 | - // Get some meta | |
| 403 | - $reply_topic_id = bbp_get_reply_topic_id( $post_id ); | |
| 404 | - $reply_forum_id = bbp_get_reply_forum_id( $post_id ); | |
| 474 | + /** Status ****************************************************************/ | |
| 405 | 475 | |
| 406 | - // Allow individual manipulation of reply forum | |
| 407 | - if ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate' ) ) : ?> | |
| 476 | + ?> | |
| 408 | 477 | |
| 478 | + <p> | |
| 479 | + <strong class="label"><?php esc_html_e( 'Status:', 'bbpress' ); ?></strong> | |
| 480 | + <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' === $post->post_status ) ? 'draft' : $post->post_status ); ?>" /> | |
| 481 | + <label class="screen-reader-text" for="post_status"><?php esc_html_e( 'Select what status to give the reply.', 'bbpress' ); ?></label> | |
| 482 | + <?php bbp_form_reply_status_dropdown( array( 'select_id' => 'post_status', 'reply_id' => $post->ID ) ); ?> | |
| 483 | + </p> | |
| 484 | + | |
| 485 | + <hr /> | |
| 486 | + | |
| 487 | + <?php | |
| 488 | + | |
| 489 | + /** Forum *****************************************************************/ | |
| 490 | + | |
| 491 | + // Only allow individual manipulation of reply forum if there is a mismatch | |
| 492 | + if ( ( $reply_forum_id !== $topic_forum_id ) && ( current_user_can( 'edit_others_replies' ) || current_user_can( 'moderate', $post->ID ) ) ) : ?> | |
| 493 | + | |
| 409 | 494 | <p> |
| 410 | - <strong class="label"><?php _e( 'Forum:', 'bbpress' ); ?></strong> | |
| 411 | - <label class="screen-reader-text" for="bbp_forum_id"><?php _e( 'Forum', 'bbpress' ); ?></label> | |
| 495 | + <strong class="label"><?php esc_html_e( 'Forum:', 'bbpress' ); ?></strong> | |
| 496 | + <label class="screen-reader-text" for="bbp_forum_id"><?php esc_html_e( 'Forum', 'bbpress' ); ?></label> | |
| 412 | 497 | <?php bbp_dropdown( array( |
| 413 | 498 | 'post_type' => bbp_get_forum_post_type(), |
| 414 | 499 | 'selected' => $reply_forum_id, |
| 415 | - 'child_of' => '0', | |
| 416 | 500 | 'numberposts' => -1, |
| 417 | 501 | 'orderby' => 'title', |
| 418 | 502 | 'order' => 'ASC', |
| 419 | 503 | 'walker' => '', |
| @@ -420,76 +504,329 @@ | ||
| 420 | 504 | 'exclude' => '', |
| 421 | 505 | |
| 422 | 506 | // Output-related |
| 423 | 507 | 'select_id' => 'bbp_forum_id', |
| 424 | - 'tab' => bbp_get_tab_index(), | |
| 425 | 508 | 'options_only' => false, |
| 426 | - 'show_none' => __( '— No parent —', 'bbpress' ), | |
| 427 | - 'none_found' => false, | |
| 509 | + 'show_none' => esc_html__( '— No reply —', 'bbpress' ), | |
| 428 | 510 | 'disable_categories' => current_user_can( 'edit_forums' ), |
| 429 | 511 | 'disabled' => '' |
| 430 | 512 | ) ); ?> |
| 431 | 513 | </p> |
| 432 | 514 | |
| 433 | - <?php endif; ?> | |
| 515 | + <?php endif; | |
| 434 | 516 | |
| 517 | + /** Topic *****************************************************************/ | |
| 518 | + | |
| 519 | + ?> | |
| 520 | + | |
| 435 | 521 | <p> |
| 436 | - <strong class="label"><?php _e( 'Topic:', 'bbpress' ); ?></strong> | |
| 437 | - <label class="screen-reader-text" for="parent_id"><?php _e( 'Topic', 'bbpress' ); ?></label> | |
| 438 | - <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr( $reply_topic_id ); ?>" /> | |
| 522 | + <strong class="label"><?php esc_html_e( 'Topic:', 'bbpress' ); ?></strong> | |
| 523 | + <label class="screen-reader-text" for="parent_id"><?php esc_html_e( 'Topic', 'bbpress' ); ?></label> | |
| 524 | + <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr( $reply_topic_id ); ?>" data-ajax-url="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_suggest_topic' ), admin_url( 'admin-ajax.php', 'relative' ) ), 'bbp_suggest_topic_nonce' ) ); ?>" /> | |
| 439 | 525 | </p> |
| 440 | 526 | |
| 441 | 527 | <?php |
| 528 | + | |
| 529 | + /** Reply To **************************************************************/ | |
| 530 | + | |
| 531 | + // Only show reply-to drop-down when editing an existing reply | |
| 532 | + if ( ! empty( $reply_topic_id ) ) : ?> | |
| 533 | + | |
| 534 | + <p> | |
| 535 | + <strong class="label"><?php esc_html_e( 'Reply To:', 'bbpress' ); ?></strong> | |
| 536 | + <label class="screen-reader-text" for="bbp_reply_to"><?php esc_html_e( 'Reply To', 'bbpress' ); ?></label> | |
| 537 | + <?php bbp_reply_to_dropdown( $post->ID ); ?> | |
| 538 | + </p> | |
| 539 | + | |
| 540 | + <?php | |
| 541 | + | |
| 542 | + endif; | |
| 543 | + | |
| 544 | + ?> | |
| 545 | + | |
| 546 | + <input name="ping_status" type="hidden" id="ping_status" value="open" /> | |
| 547 | + | |
| 548 | + <?php | |
| 442 | 549 | wp_nonce_field( 'bbp_reply_metabox_save', 'bbp_reply_metabox' ); |
| 443 | - do_action( 'bbp_reply_metabox', $post_id ); | |
| 550 | + do_action( 'bbp_reply_metabox', $post ); | |
| 444 | 551 | } |
| 445 | 552 | |
| 553 | +/** | |
| 554 | + * Output the topic replies meta-box | |
| 555 | + * | |
| 556 | + * @since 2.6.0 bbPress (r5886) | |
| 557 | + * | |
| 558 | + * @param object $topic | |
| 559 | + * | |
| 560 | + * @return void | |
| 561 | + */ | |
| 562 | +function bbp_topic_replies_metabox( $topic = false ) { | |
| 563 | + | |
| 564 | + // Bail if no topic to load replies for | |
| 565 | + if ( empty( $topic ) ) { | |
| 566 | + return; | |
| 567 | + } | |
| 568 | + | |
| 569 | + // Pull in the list table class | |
| 570 | + if ( ! class_exists( 'BBP_Topic_Replies_List_Table' ) ) { | |
| 571 | + require_once bbp_admin()->admin_dir . '/classes/class-bbp-topic-replies-list-table.php'; | |
| 572 | + } | |
| 573 | + | |
| 574 | + // Look for pagination value | |
| 575 | + $page = isset( $_REQUEST['page'] ) | |
| 576 | + ? (int) $_REQUEST['page'] | |
| 577 | + : 0; | |
| 578 | + | |
| 579 | + // Load up the list table | |
| 580 | + $replies_list_table = new BBP_Topic_Replies_List_Table(); | |
| 581 | + $replies_list_table->prepare_items( $topic->ID ); ?> | |
| 582 | + | |
| 583 | + <form id="bbp-topic-replies" method="get"> | |
| 584 | + <input type="hidden" name="page" value="<?php echo esc_attr( $page ); ?>" /> | |
| 585 | + | |
| 586 | + <?php $replies_list_table->display(); ?> | |
| 587 | + </form> | |
| 588 | + | |
| 589 | + <?php | |
| 590 | +} | |
| 591 | + | |
| 446 | 592 | /** Users *********************************************************************/ |
| 447 | 593 | |
| 448 | 594 | /** |
| 449 | - * Anonymous user information metabox | |
| 595 | + * Anonymous user information meta-box | |
| 450 | 596 | * |
| 451 | - * @since bbPress (r2828) | |
| 597 | + * @since 2.0.0 bbPress (r2828) | |
| 452 | 598 | * |
| 453 | - * @uses bbp_is_reply_anonymous() To check if reply is anonymous | |
| 454 | - * @uses bbp_is_topic_anonymous() To check if topic is anonymous | |
| 455 | - * @uses get_the_ID() To get the global post ID | |
| 456 | - * @uses get_post_meta() To get the author user information | |
| 599 | + * @param WP_Post $post The current post object | |
| 457 | 600 | */ |
| 458 | -function bbp_author_metabox() { | |
| 601 | +function bbp_author_metabox( $post ) { | |
| 459 | 602 | |
| 460 | - // Post ID | |
| 461 | - $post_id = get_the_ID(); | |
| 603 | + // Show extra bits if topic/reply is anonymous | |
| 604 | + if ( bbp_is_reply_anonymous( $post->ID ) || bbp_is_topic_anonymous( $post->ID ) ) : ?> | |
| 462 | 605 | |
| 463 | - // Show extra bits if topic/reply is anonymous | |
| 464 | - if ( bbp_is_reply_anonymous( $post_id ) || bbp_is_topic_anonymous( $post_id ) ) : ?> | |
| 606 | + <p> | |
| 607 | + <strong class="label"><?php esc_html_e( 'Name:', 'bbpress' ); ?></strong> | |
| 608 | + <label class="screen-reader-text" for="bbp_anonymous_name"><?php esc_html_e( 'Name', 'bbpress' ); ?></label> | |
| 609 | + <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_anonymous_name', true ) ); ?>" /> | |
| 610 | + </p> | |
| 465 | 611 | |
| 466 | 612 | <p> |
| 467 | - <strong class="label"><?php _e( 'Name:', 'bbpress' ); ?></strong> | |
| 468 | - <label class="screen-reader-text" for="bbp_anonymous_name"><?php _e( 'Name', 'bbpress' ); ?></label> | |
| 469 | - <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_name', true ) ); ?>" /> | |
| 613 | + <strong class="label"><?php esc_html_e( 'Email:', 'bbpress' ); ?></strong> | |
| 614 | + <label class="screen-reader-text" for="bbp_anonymous_email"><?php esc_html_e( 'Email', 'bbpress' ); ?></label> | |
| 615 | + <input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_anonymous_email', true ) ); ?>" /> | |
| 470 | 616 | </p> |
| 471 | 617 | |
| 472 | 618 | <p> |
| 473 | - <strong class="label"><?php _e( 'Email:', 'bbpress' ); ?></strong> | |
| 474 | - <label class="screen-reader-text" for="bbp_anonymous_email"><?php _e( 'Email', 'bbpress' ); ?></label> | |
| 475 | - <input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_email', true ) ); ?>" /> | |
| 619 | + <strong class="label"><?php esc_html_e( 'Website:', 'bbpress' ); ?></strong> | |
| 620 | + <label class="screen-reader-text" for="bbp_anonymous_website"><?php esc_html_e( 'Website', 'bbpress' ); ?></label> | |
| 621 | + <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_anonymous_website', true ) ); ?>" /> | |
| 476 | 622 | </p> |
| 477 | 623 | |
| 624 | + <?php else : ?> | |
| 625 | + | |
| 478 | 626 | <p> |
| 479 | - <strong class="label"><?php _e( 'Website:', 'bbpress' ); ?></strong> | |
| 480 | - <label class="screen-reader-text" for="bbp_anonymous_website"><?php _e( 'Website', 'bbpress' ); ?></label> | |
| 481 | - <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_anonymous_website', true ) ); ?>" /> | |
| 627 | + <strong class="label"><?php esc_html_e( 'ID:', 'bbpress' ); ?></strong> | |
| 628 | + <label class="screen-reader-text" for="bbp_author_id"><?php esc_html_e( 'ID', 'bbpress' ); ?></label> | |
| 629 | + <input type="text" id="bbp_author_id" name="post_author_override" value="<?php echo esc_attr( bbp_get_global_post_field( 'post_author' ) ); ?>" data-ajax-url="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_suggest_user' ), admin_url( 'admin-ajax.php', 'relative' ) ), 'bbp_suggest_user_nonce' ) ); ?>" /> | |
| 482 | 630 | </p> |
| 483 | 631 | |
| 484 | 632 | <?php endif; ?> |
| 485 | 633 | |
| 486 | 634 | <p> |
| 487 | - <strong class="label"><?php _e( 'IP:', 'bbpress' ); ?></strong> | |
| 488 | - <label class="screen-reader-text" for="bbp_author_ip_address"><?php _e( 'IP Address', 'bbpress' ); ?></label> | |
| 489 | - <input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php echo esc_attr( get_post_meta( $post_id, '_bbp_author_ip', true ) ); ?>" disabled="disabled" /> | |
| 635 | + <strong class="label"><?php esc_html_e( 'IP:', 'bbpress' ); ?></strong> | |
| 636 | + <label class="screen-reader-text" for="bbp_author_ip_address"><?php esc_html_e( 'IP Address', 'bbpress' ); ?></label> | |
| 637 | + <input type="text" id="bbp_author_ip_address" name="bbp_author_ip_address" value="<?php echo esc_attr( get_post_meta( $post->ID, '_bbp_author_ip', true ) ); ?>" disabled="disabled" /> | |
| 490 | 638 | </p> |
| 491 | 639 | |
| 492 | 640 | <?php |
| 493 | 641 | |
| 494 | - do_action( 'bbp_author_metabox', $post_id ); | |
| 642 | + do_action( 'bbp_author_metabox', $post ); | |
| 643 | +} | |
| 644 | + | |
| 645 | +/** | |
| 646 | + * Moderator assignment meta-box | |
| 647 | + * | |
| 648 | + * @since 2.6.0 bbPress (r2828) | |
| 649 | + */ | |
| 650 | +function bbp_moderator_assignment_metabox( $post ) { | |
| 651 | + | |
| 652 | + // Get nicenames | |
| 653 | + $user_ids = bbp_get_moderator_ids( $post->ID ); | |
| 654 | + $user_nicenames = bbp_get_user_nicenames_from_ids( $user_ids ); | |
| 655 | + $moderators = ! empty( $user_nicenames ) | |
| 656 | + ? implode( ', ', array_map( 'esc_attr', $user_nicenames ) ) | |
| 657 | + : ''; ?> | |
| 658 | + | |
| 659 | + <label class="screen-reader-text" for="bbp_moderators"><?php esc_html_e( 'Moderators', 'bbpress' ); ?></label> | |
| 660 | + <input type="text" id="bbp_moderators" name="bbp_moderators" value="<?php echo esc_attr( $moderators ); ?>" /> | |
| 661 | + <p class="howto"><?php esc_html_e( 'Separate user-names with commas', 'bbpress' ); ?></p> | |
| 662 | + | |
| 663 | + <?php | |
| 664 | + | |
| 665 | + do_action( 'bbp_moderator_assignment_metabox', $post ); | |
| 666 | +} | |
| 667 | + | |
| 668 | +/** | |
| 669 | + * See who engaged with a topic | |
| 670 | + * | |
| 671 | + * @since 2.6.0 bbPress (r6333) | |
| 672 | + */ | |
| 673 | +function bbp_topic_engagements_metabox( $post ) { | |
| 674 | + | |
| 675 | + // Get user IDs | |
| 676 | + $user_ids = bbp_get_topic_engagements( $post->ID ); | |
| 677 | + | |
| 678 | + // Output | |
| 679 | + ?><p><?php | |
| 680 | + | |
| 681 | + // Relationships | |
| 682 | + $args = array( | |
| 683 | + 'include' => $user_ids | |
| 684 | + ); | |
| 685 | + | |
| 686 | + // Users were found | |
| 687 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 688 | + bbp_metabox_user_links(); | |
| 689 | + | |
| 690 | + // No users | |
| 691 | + else : | |
| 692 | + esc_html_e( 'No users have engaged to this topic.', 'bbpress' ); | |
| 693 | + endif; | |
| 694 | + | |
| 695 | + ?></p><?php | |
| 696 | + | |
| 697 | + do_action( 'bbp_topic_engagements_metabox', $post ); | |
| 698 | +} | |
| 699 | + | |
| 700 | +/** | |
| 701 | + * See who marked a topic as a favorite | |
| 702 | + * | |
| 703 | + * @since 2.6.0 bbPress (r6197) | |
| 704 | + * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query | |
| 705 | + */ | |
| 706 | +function bbp_topic_favorites_metabox( $post ) { | |
| 707 | + | |
| 708 | + // Get user IDs | |
| 709 | + $user_ids = bbp_get_topic_favoriters( $post->ID ); | |
| 710 | + | |
| 711 | + // Output | |
| 712 | + ?><p><?php | |
| 713 | + | |
| 714 | + // Relationships | |
| 715 | + $args = array( | |
| 716 | + 'include' => $user_ids | |
| 717 | + ); | |
| 718 | + | |
| 719 | + // Users were found | |
| 720 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 721 | + bbp_metabox_user_links(); | |
| 722 | + | |
| 723 | + // No users | |
| 724 | + else : | |
| 725 | + esc_html_e( 'No users have favorited this topic.', 'bbpress' ); | |
| 726 | + endif; | |
| 727 | + | |
| 728 | + ?></p><?php | |
| 729 | + | |
| 730 | + do_action( 'bbp_favorites_metabox', $post ); | |
| 731 | +} | |
| 732 | + | |
| 733 | +/** | |
| 734 | + * See who is subscribed to a topic | |
| 735 | + * | |
| 736 | + * @since 2.6.0 bbPress (r6197) | |
| 737 | + * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query | |
| 738 | + */ | |
| 739 | +function bbp_topic_subscriptions_metabox( $post ) { | |
| 740 | + | |
| 741 | + // Current user subscription | |
| 742 | + $input_value = bbp_is_user_subscribed( bbp_get_current_user_id(), $post->ID ) | |
| 743 | + ? 'bbp_subscribe' // maintain existing subscription | |
| 744 | + : ''; // do not add or remove subscription | |
| 745 | + | |
| 746 | + // Get user IDs | |
| 747 | + $user_ids = bbp_get_subscribers( $post->ID ); | |
| 748 | + | |
| 749 | + // Output | |
| 750 | + ?> | |
| 751 | + <input name="bbp_topic_subscription" id="bbp_topic_subscription" type="hidden" value="<?php echo esc_attr( $input_value ); ?>" /> | |
| 752 | + <p><?php | |
| 753 | + | |
| 754 | + // Relationships | |
| 755 | + $args = array( | |
| 756 | + 'include' => $user_ids | |
| 757 | + ); | |
| 758 | + | |
| 759 | + // Users were found | |
| 760 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 761 | + bbp_metabox_user_links(); | |
| 762 | + | |
| 763 | + // No users | |
| 764 | + else : | |
| 765 | + esc_html_e( 'No users have subscribed to this topic.', 'bbpress' ); | |
| 766 | + endif; | |
| 767 | + | |
| 768 | + ?></p><?php | |
| 769 | + | |
| 770 | + do_action( 'bbp_subscriptions_metabox', $post ); | |
| 771 | +} | |
| 772 | + | |
| 773 | +/** | |
| 774 | + * See who is subscribed to a forum | |
| 775 | + * | |
| 776 | + * @since 2.6.0 bbPress (r6197) | |
| 777 | + * @since 2.6.0 bbPress (r6333) Updated to use BBP_User_Query | |
| 778 | + */ | |
| 779 | +function bbp_forum_subscriptions_metabox( $post ) { | |
| 780 | + | |
| 781 | + // Get user IDs | |
| 782 | + $user_ids = bbp_get_subscribers( $post->ID ); | |
| 783 | + | |
| 784 | + // Output | |
| 785 | + ?><p><?php | |
| 786 | + | |
| 787 | + // Relationships | |
| 788 | + $args = array( | |
| 789 | + 'include' => $user_ids | |
| 790 | + ); | |
| 791 | + | |
| 792 | + // Users were found | |
| 793 | + if ( ! empty( $user_ids ) && bbp_has_users( $args ) ) : | |
| 794 | + bbp_metabox_user_links(); | |
| 795 | + | |
| 796 | + // No users | |
| 797 | + else : | |
| 798 | + esc_html_e( 'No users have subscribed to this forum.', 'bbpress' ); | |
| 799 | + endif; | |
| 800 | + | |
| 801 | + ?></p><?php | |
| 802 | + | |
| 803 | + do_action( 'bbp_forum_subscriptions_metabox', $post ); | |
| 804 | +} | |
| 805 | + | |
| 806 | +/** | |
| 807 | + * Loop through queried metabox users, and output links to their avatars | |
| 808 | + * | |
| 809 | + * Developers Note: This function may change in a future release to include | |
| 810 | + * additional actions, so do not use this function in any third party plugin. | |
| 811 | + * | |
| 812 | + * @since 2.6.0 bbPress (r6913) | |
| 813 | + */ | |
| 814 | +function bbp_metabox_user_links() { | |
| 815 | + | |
| 816 | + // Loop through users | |
| 817 | + while ( bbp_users() ) { | |
| 818 | + | |
| 819 | + // Set the iterator | |
| 820 | + bbp_the_user(); | |
| 821 | + | |
| 822 | + // Get the user ID, URL, and Avatar | |
| 823 | + $user_id = bbp_get_user_id(); | |
| 824 | + $user_url = bbp_get_user_profile_url( $user_id ); | |
| 825 | + $user_avatar = get_avatar( $user_id, 32, '', '', array( | |
| 826 | + 'force_display' => true | |
| 827 | + ) ); | |
| 828 | + | |
| 829 | + // Output a link to the user avatar | |
| 830 | + echo '<a href="' . esc_url( $user_url ) . '">' . $user_avatar . '</a>'; | |
| 831 | + } | |
| 495 | 832 | } |