/** * Should we display the comments form ? * * @package WP Idea Stream * @subpackage comments/functions * * @since 2.0.0 * * @param bool $open true if comments are opened, false otherwise * @param int $idea_id the ID of the idea * @uses wp_idea_stream_is_ideastream() to make sure it's plugin's territory * @uses wp_idea_stream_is_comments_allowed() to check if comments about ideas is globally allowed * @uses apply_filters() call 'wp_idea_stream_comments_open' to override the value * @return bool true if comments are opened, false otherwise */ function wp_idea_stream_comments_open($open = true, $idea_id = 0) { if (!wp_idea_stream_is_ideastream()) { return $open; } if ($open != wp_idea_stream_is_comments_allowed()) { $open = false; } /** * Used internally in BuddyPress parts * * @param bool $open true if comments are opened, false otherwise * @param int $idea_id the ID of the idea */ return apply_filters('wp_idea_stream_comments_open', $open, $idea_id); }
/** * Group extension settings form * * Used in Group Administration, Edit and Create screens * * @package WP Idea Stream * @subpackage buddypress/groups * * @since 2.0.0 * * @param int $group_id the group ID * @uses is_admin() to check if we're in WP Administration * @uses checked() to add a checked attribute to checkbox if needed * @uses WP_Idea_Stream_Group::group_get_option() to get the needed group metas. * @uses wp_idea_stream_is_comments_allowed() to check if commenting ideas is globally allowed * @uses bp_is_group_admin_page() to check if the group edit screen is displayed * @uses WP_Idea_Stream_Group->group_has_ideas() to check if Ideas are attached to current group * @uses wp_nonce_field() to add a security token to check upon once submitted * @return string html output */ public function edit_screen($group_id = null) { if (empty($group_id)) { $group_id = bp_get_current_group_id(); } $is_admin = is_admin(); $br = false; if ($is_admin) { $br = '<br/>'; } if (!$is_admin) { ?> <h4><?php printf(esc_html__('%s group settings', 'wp-idea-stream'), $this->name); ?> </h4> <?php } ?> <fieldset> <?php if ($is_admin) { ?> <legend class="screen-reader-text"><?php printf(esc_html__('%s group settings', 'wp-idea-stream'), $this->name); ?> </legend> <?php } ?> <div class="field-group"> <div class="checkbox"> <label> <label for="_group_ideastream_activate"> <input type="checkbox" id="_group_ideastream_activate" name="_group_ideastream_activate" value="1" <?php checked(self::group_get_option($group_id, '_group_ideastream_activate', false)); ?> > <?php printf(__('Activate %s.', 'wp-idea-stream'), $this->name); ?> </input> </label> <?php echo $br; if (wp_idea_stream_is_comments_allowed()) { ?> <label for="_group_ideastream_comments"> <input type="checkbox" id="_group_ideastream_comments" name="_group_ideastream_comments" value="1" <?php checked(self::group_get_option($group_id, '_group_ideastream_comments', true)); ?> > <?php esc_html_e('Allow members to comment on ideas.', 'wp-idea-stream'); ?> </input> </label> <?php } echo $br; ?> <label for="_group_ideastream_categories"> <input type="checkbox" id="_group_ideastream_categories" name="_group_ideastream_categories" value="1" <?php checked(true, self::group_get_option($group_id, '_group_ideastream_categories', true)); ?> > <?php esc_html_e('Use Categories.', 'wp-idea-stream'); ?> </input> </label> </label> </div> <?php /** * If ideas are attached to the current group, it shows a new checkbox * to allow the group admin to remove all the ideas attached to its group * * If IdeaStream extension is temporarly disabled, Ideas will only be available (if public group) * on the main archive page. Once the group admin reactivates IdeaStream, Ideas will be also available * within the group. * * If the admin removes one or more ideas from the group, they still exist on the main Archive page * of the plugin. * * Ideas are dependent on their authors, not on the group they were posted in */ if ((bp_is_group_admin_page() || is_admin()) && $this->group_has_ideas($group_id)) { ?> <div class="checkbox"> <label for="_group_ideastream_remove_ideas"> <input type="checkbox" id="_group_ideastream_remove_ideas" name="_group_ideastream_remove_ideas" value="1"> <?php esc_html_e('Remove all ideas.', 'wp-idea-stream'); ?> </input> </label> </div> <?php } ?> </div> <?php if (bp_is_group_admin_page()) { ?> <input type="submit" name="save" value="<?php _e('Save', 'wp-idea-stream'); ?> " /> <?php } ?> </fieldset> <?php wp_nonce_field('groups_settings_save_' . $this->slug, 'ideastream_group_admin'); }
/** * Checks if an idea can be commented * * @package WP Idea Stream * @subpackage buddypress/functions * * @since 2.0.0 * * @param bool $open true if comments opened, false otherwise * @param int $idea_id the idea ID * @uses wp_idea_stream_is_ideastream() to check if it's the plugin's territory * @uses is_buddypress() to check if it's BuddyPress territory * @uses wp_idea_stream_is_comments_allowed() to get IdeaStream global setting * @uses get_post_field() to get the idea comments opened setting * @uses apply_filters() call 'wp_idea_stream_buddypress_comments_open' to override the comments opened setting * @return bool the comments opened status for the idea */ function wp_idea_stream_buddypress_comments_open($open = true, $idea_id = 0) { $retval = true; if (!wp_idea_stream_is_ideastream() || !is_buddypress()) { return $open; } // Comments can be disabled globally if (!wp_idea_stream_is_comments_allowed()) { $retval = false; } // We need to recheck as BuddyPress is forcing comment status to be closed // on its directory pages. if ('open' != get_post_field('comment_status', $idea_id)) { $retval = false; } /** * Used internally to check the group's comments opened setting * * @param bool $retval the comments opened setting * @param int $idea_id the ID of the idea */ return apply_filters('wp_idea_stream_buddypress_comments_open', $retval, $idea_id); }
/** * Global "opened" comments callback * * @package WP Idea Stream * @subpackage admin/settings * * @since 2.0.0 * * @uses checked() to add a checked attribute if needed * @uses wp_idea_stream_is_comments_allowed() to get the active option * @return string HTML output */ function wp_idea_stream_allow_comments_setting_callback() { ?> <input name="_ideastream_allow_comments" id="_ideastream_allow_comments" type="checkbox" value="1" <?php checked(wp_idea_stream_is_comments_allowed()); ?> /> <label for="_ideastream_allow_comments"><?php esc_html_e('Allow users to add comments on ideas', 'wp-idea-stream'); ?> </label> <?php }