Skip to content

Commit

Permalink
Allow comments to be posted and displayed group events. Allow front-e…
Browse files Browse the repository at this point in the history
…nd control of whether or not comments are open.
  • Loading branch information
rjbaniel committed Nov 1, 2017
1 parent d3bd473 commit 4055fd6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
11 changes: 11 additions & 0 deletions includes/group.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -632,6 +632,17 @@ function bpeo_render_silent_checkbox( $post_type, $location, $post ) {
} }
add_action( 'do_meta_boxes', 'bpeo_render_silent_checkbox', 10, 3 ); add_action( 'do_meta_boxes', 'bpeo_render_silent_checkbox', 10, 3 );


/**
* Override BP Core filter that sets comment_status to closed for all BP pages
*/
function bpeo_show_event_comments( $retval, $open, $post_id ) {
if ( $open && ! $retval && get_post_type( $post_id ) === 'event' ){
return true;
} else {
return $retval;
}
}
add_filter( 'bp_force_comment_status', 'bpeo_show_event_comments', 10, 3 );
/** Embed ********************************************************************/ /** Embed ********************************************************************/


/** /**
Expand Down
29 changes: 29 additions & 0 deletions includes/wp-frontend-admin-screen/abstraction-metabox.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -839,6 +839,35 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
} }
endif; endif;


/** DUPLICATES - POST COMMENT STATUS ***********************************/
if ( ! function_exists( 'post_comment_status_meta_box' ) ) :
/**
* Display post comment status form fields. (E.g. "Allow comments")
*
* WFAS Mods:
* - Removed "Allow pingbacks" checkbox
*
* @param object $post
*/
function post_comment_status_meta_box($post, $args = array() ) {
?>
<p class="meta-options">
<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow comments' ) ?></label>
<?php
/**
* Fires at the end of the Discussion meta box on the post editing screen.
*
* @since 3.1.0
*
* @param WP_Post $post WP_Post object of the current post.
*/
do_action( 'post_comment_status_meta_box-options', $post );
?>
</p>
<?php
}
endif;

/** DUPLICATES - POST SUBMIT META BOX ***********************************/ /** DUPLICATES - POST SUBMIT META BOX ***********************************/


if ( ! function_exists( 'post_submit_meta_box' ) ) : if ( ! function_exists( 'post_submit_meta_box' ) ) :
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ final protected function setup_strings() {
'last_edited_on' => __( 'Last edited on %1$s at %2$s' ), 'last_edited_on' => __( 'Last edited on %1$s at %2$s' ),
'button_publish' => __( 'Publish' ), 'button_publish' => __( 'Publish' ),
'button_update' => __( 'Update' ), 'button_update' => __( 'Update' ),
'comments_status' => __( 'Discussion' ),
'tag_delimiter' => _x( ',', 'tag delimiter' ), 'tag_delimiter' => _x( ',', 'tag delimiter' ),
'featured_image' => __( 'Featured Image' ), 'featured_image' => __( 'Featured Image' ),
'title_publish' => __( 'Publish' ), 'title_publish' => __( 'Publish' ),
Expand Down Expand Up @@ -275,7 +276,6 @@ public function display() {
?> ?>


<h2 class="admin-page-title"><?php esc_html_e( $title ); ?></h2> <h2 class="admin-page-title"><?php esc_html_e( $title ); ?></h2>

<div id="post-body"> <div id="post-body">
<form id="post" method="post" action="" name="post"> <form id="post" method="post" action="" name="post">
<?php wp_nonce_field( 'update-post_' . $post->ID ); ?> <?php wp_nonce_field( 'update-post_' . $post->ID ); ?>
Expand Down Expand Up @@ -353,6 +353,9 @@ public function display() {
// publish metabox // publish metabox
add_meta_box( 'submitdiv', $this->strings['title_publish'], 'post_submit_meta_box', self::$post_type, 'side', 'low' ); add_meta_box( 'submitdiv', $this->strings['title_publish'], 'post_submit_meta_box', self::$post_type, 'side', 'low' );


// allow comments metabox
add_meta_box( 'commentstatusdiv', $this->strings['comments_status'], 'post_comment_status_meta_box', self::$post_type, 'side', 'low' );

// taxonomy metaboxes // taxonomy metaboxes
foreach ( get_object_taxonomies( $post ) as $tax_name ) { foreach ( get_object_taxonomies( $post ) as $tax_name ) {
$taxonomy = get_taxonomy( $tax_name ); $taxonomy = get_taxonomy( $tax_name );
Expand Down
5 changes: 5 additions & 0 deletions templates/content-eo-event.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
<?php endif; ?> <?php endif; ?>


<?php bpeo_the_single_event_action_links(); ?> <?php bpeo_the_single_event_action_links(); ?>

<!-- If comments are enabled, show them -->
<div class="comments-template">
<?php comments_template(); ?>
</div>

0 comments on commit 4055fd6

Please sign in to comment.