コード例 #1
0
        public function settings_screen($group_id = null)
        {
            // $group_id = bp_get_group_id( $group_id );
            $is_enabled = ccgn_is_enabled($group_id);
            $tab_label = ccgn_get_tab_label($group_id);
            $slug = ccgn_get_slug($group_id);
            $level_to_post = ccgn_get_level_to_post($group_id);
            // Needed to use wp_terms_checklist()
            require_once ABSPATH . 'wp-admin/includes/template.php';
            ?>

				<p>
					Hub Narratives allows your hub to share stories and interact via comments with visitors to your hub space.
				</p>
				<p>
					<label for="ccgn_is_enabled"> <input type="checkbox" name="ccgn_is_enabled" id="ccgn_is_enabled" value="1" <?php 
            checked($is_enabled, true);
            ?>
 /> Enable hub narratives.</label>
				</p>

				<?php 
            // Only show the other settings once the plugin has been enabled for this group
            // This is necessary because the term for associating posts to this group is only created upon submit of the "enable" checkbox
            if ($is_enabled) {
                ?>
					<div id="ccgn_settings_details">

					<p>
							<label for='ccgn_tab_label'>Change the BuddyPress hub tab label from 'Narratives' to whatever you'd like.</label>
							<input type="text" name="ccgn_tab_label" id="ccgn_tab_label" value="<?php 
                echo esc_html($tab_label);
                ?>
" />
					 </p>
					 <?php 
                /* ?>
                		 <p>
                			<label for='ccgn_url_slug'>Change the slug to something other than 'narratives'.</label>
                			<input type="text" name="ccgn_url_slug" id="ccgn_url_slug" value="<?php echo esc_html( $slug ); ?>" />
                		 </p>
                		 <?php */
                ?>
					<p>
							<label for='ccgn_level_to_post'>Who should be able to create new posts?</label>
							<select name="ccgn_level_to_post" id="ccgn_level_to_post">
								<option <?php 
                selected($level_to_post, "admin");
                ?>
 value="admin">Hub Admins Only</option>
								<option <?php 
                selected($level_to_post, "mod");
                if (empty($level_to_post)) {
                    echo 'selected="selected"';
                }
                ?>
 value="mod">Hub Admins and Moderators</option>
								<option <?php 
                selected($level_to_post, "member");
                ?>
 value="member">Any Hub Member</option>
							</select>
					 </p>

					 <p>Select other groups that narratives published in this group could be syndicated to.</p>
					 <?php 
                // @TODO: Maybe only site admins should be able to add other groups
                // Handle group associations, which are a taxonomy
                // Get the syndicated groups selected for this group, add this group's term.
                $selected_terms = ccgn_add_this_group_term(ccgn_get_categories($group_id), ccgn_get_group_term_id($group_id));
                $tax_args = array('hide_empty' => false);
                $terms = get_terms('ccgn_related_groups', $tax_args);
                // TODO: This should be filtered by groups that don't have the plugin enabled.
                // get_terms either returns an array of terms or a WP_Error_Object if there's a problem
                if (!empty($terms) && !is_wp_error($terms)) {
                    $args = array('descendants_and_self' => 0, 'selected_cats' => $selected_terms, 'popular_cats' => false, 'walker' => null, 'taxonomy' => 'ccgn_related_groups', 'checked_ontop' => false);
                    wp_terms_checklist(0, $args);
                } else {
                    ?>
					<div class="error">
							<p>Looks like no group terms are set up yet. Check back later.</p>
					</div>
					<?php 
                }
                ?>
				</div> <!-- End #bcg_settings_details -->

			<?php 
            }
            // ends the "enabled" check
            ?>

				<div class="clear"></div>
				<script type="text/javascript">
					jQuery(document).ready(function() {
						//match visibility on page load
						if ( jQuery('#ccgn_is_enabled').is(':checked') ) {
									jQuery('#ccgn_settings_details').show();
							} else {
									jQuery('#ccgn_settings_details').hide();
							}
						//update visibility on change
						jQuery('#ccgn_is_enabled').click(function() {
							if ( jQuery(this).is(':checked') ) {
									jQuery('#ccgn_settings_details').show();
							} else {
									jQuery('#ccgn_settings_details').hide();
							}
						});
					});
				</script>

		<?php 
        }
コード例 #2
0
/**
 * Where are we? Who am I? What is this beautiful house?
 * Helper functions to determine what is going on/ what action is being requested.
 * @return bool
 */
function ccgn_is_component()
{
    if (bp_is_groups_component() && bp_is_current_action(ccgn_get_slug())) {
        return true;
    }
    return false;
}