function bcg_fix_category_permalink($catlink, $category_id) { if (!bcg_is_component() || !in_bcg_loop()) { return $catlink; } $permalink = trailingslashit(bcg_get_home_url()); //$cat = get_category( $category_id ); //think about the cat permalink, do we need it or not? return $permalink . bcg_get_taxonomy() . '/' . $category_id; //no need for category_name }
function bcg_get_query() { $bp = buddypress(); $cats = bcg_get_categories($bp->groups->current_group->id); $qs = array('post_type' => bcg_get_post_type(), 'post_status' => 'publish'); if (empty($cats)) { $qs['name'] = -1; //we know it will not find anything } if (bcg_is_single_post()) { $slug = $bp->action_variables[0]; $qs['name'] = $slug; //tax query $qs['tax_query'] = array(array('taxonomy' => bcg_get_taxonomy(), 'terms' => $cats, 'field' => 'id', 'operator' => 'IN')); } $paged = get_query_var('paged') ? get_query_var('paged') : 1; if (bcg_is_category()) { $qs['tax_query'] = array(array('taxonomy' => bcg_get_taxonomy(), 'terms' => (int) bp_action_variable(1), 'field' => 'id', 'operator' => 'IN')); } else { $qs['tax_query'] = array(array('taxonomy' => bcg_get_taxonomy(), 'terms' => $cats, 'field' => 'id', 'operator' => 'IN')); } $qs['paged'] = $paged; return apply_filters("bcg_get_query", $qs); }
function bcg_admin_form() { $group_id = bp_get_group_id(); $selected_cats = bcg_get_categories($group_id); $taxonomy = get_taxonomy(bcg_get_taxonomy()); echo "<p>" . sprintf(__("Check a %s to assopciate the posts in this %s with this group.", "bcg"), $taxonomy->labels->singular_name, $taxonomy->labels->singular_name) . "</p>"; $cats = bcg_get_all_terms(); if (is_array($cats)) { ////it is sure but do not take risk foreach ($cats as $cat) { //show the form $checked = 0; if (!empty($selected_cats) && in_array($cat->term_id, $selected_cats)) { $checked = true; } ?> <label style="padding:5px;display:block;float:left;"> <input type="checkbox" name="blog_cats[]" id="<?php $opt_id; ?> " value="<?php echo $cat->term_id; ?> " <?php if ($checked) { echo "checked='checked'"; } ?> /> <?php echo $cat->name; ?> </label> <?php } } else { ?> <div class="error"> <p><?php _e("Please create the categories first to attach them to a group.", "bcg"); ?> </p> </div> <?php } ?> <div class="clear"></div> <?php }
function bcg_get_all_terms() { $cats = get_terms(bcg_get_taxonomy(), array('fields' => 'all', 'get' => 'all')); return $cats; }
/** * register post form for Posting/editing * @return type */ public function register_form() { //make sure the Front end simple post plugin is active if (!function_exists('bp_new_simple_blog_post_form')) { return; } $post_status = 'draft'; $user_id = get_current_user_id(); $group_id = bp_get_current_group_id(); $settings = array('post_type' => bcg_get_post_type(), 'post_author' => $user_id, 'post_status' => $post_status, 'comment_status' => 'open', 'show_comment_option' => false, 'custom_field_title' => '', 'custom_fields' => array('_is_bcg_post' => array('type' => 'hidden', 'label' => '', 'default' => 1)), 'tax' => array(bcg_get_taxonomy() => array('include' => bcg_get_categories($group_id))), 'upload_count' => 3, 'has_post_thumbnail' => 1, 'current_user_can_post' => bcg_current_user_can_post(), 'update_callback' => array($this, 'on_save')); //use it to add extra fields or filter the post type etc $settings = apply_filters('bcg_form_args', $settings); $form = bp_new_simple_blog_post_form('bcg_form', $settings); }