function ccgn_create_activity_items($post_id) { $bp = buddypress(); // We want to fetch the saved post, because WP has done some filtering on save. $post_object = get_post($post_id); $author_id = (int) $post_object->post_author; $user_link = bp_core_get_userlink($author_id); $post_type_object = get_post_type_object($post_object->post_type); $post_type_label = strtolower($post_type_object->labels->singular_name); // A single narrative may be associated with more than one group $origin_group_id = ccgn_get_origin_group($post_id); $associated_groups = ccgn_get_associated_group_ids($post_id); $type = $post_object->post_type . '_created'; foreach ($associated_groups as $group_id) { // Does an activity item already exist? $exists = bp_activity_get_activity_id(array('component' => $bp->groups->id, 'type' => $type, 'item_id' => $group_id, 'secondary_item_id' => $post_id)); if (!empty($exists)) { continue; } // Create a post url that is relative to this group. $post_url = trailingslashit(ccgn_get_home_permalink($group_id)) . $post_object->post_name; $post_link = sprintf('<a href="%s">%s</a>', $post_url, $post_object->post_title); $group = groups_get_group(array('group_id' => $group_id)); $group_url = bp_get_group_permalink($group); $group_link = '<a href="' . $group_url . '">' . $group->name . '</a>'; // Only set hide_sitewide to false if this is the origin group and it is a public group. if ($group_id == $origin_group_id && 'public' == bp_get_group_status($group)) { $hide_sitewide = false; } else { $hide_sitewide = true; } $action = sprintf(__('%1$s published the %2$s %3$s in the Hub %4$s', 'cc-group-narratives'), $user_link, $post_type_label, $post_link, $group_link); $args = array('user_id' => $author_id, 'action' => $action, 'primary_link' => $post_link, 'component' => $bp->groups->id, 'type' => $type, 'item_id' => $group_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post_object->post_date, 'hide_sitewide' => $hide_sitewide, 'content' => bp_create_excerpt($post_object->post_content, 358)); do_action($post_object->post_type . '_before_activity_save', $args); $activity_id = bp_activity_add(apply_filters($post_object->post_type . '_activity_args', $args, $post_id)); } }
echo trailingslashit(ccgn_get_home_permalink()) . $post->post_name; ?> " title="<?php the_title_attribute(); ?> " > <?php the_post_thumbnail('feature-large'); ?> </a> <?php } ?> <h1 class="entry-title"> <a href="<?php echo trailingslashit(ccgn_get_home_permalink()) . $post->post_name; ?> " title="<?php echo esc_attr(sprintf(__('Link to %s', 'twentytwelve'), the_title_attribute('echo=0'))); ?> " rel="bookmark"><?php the_title(); ?> </a> <?php if ('draft' == get_post_status(get_the_ID())) { ?>  <span class="draft-narrative" style="font-size:0.8em;color:#ABABAB;font-style:italic;">Draft Narrative</span> <?php } ?>
function ccgn_moderate_post_link() { $post_id = get_the_ID(); if (ccgn_current_user_can_moderate($post_id)) { echo '<a href="' . wp_nonce_url(ccgn_get_home_permalink() . '/remove-story/' . $post_id, 'ccgn-remove-story-from-group') . '" class="button confirm">' . __('Remove from hub', 'ccgn-remove-story-from-group') . '</a>'; } }