Esempio n. 1
0
 /**
  * Sets up the title for pages and <title>
  *
  * @global BuddyPress $bp The one true BuddyPress instance
  */
 public function setup_title()
 {
     $bp = buddypress();
     if (bp_is_buddyblog_component()) {
         if (bp_is_my_profile() && !bp_is_single_item()) {
             $bp->bp_options_title = __('Posts', 'buddyblog');
         } elseif (!bp_is_my_profile() && !bp_is_single_item()) {
             $bp->bp_options_avatar = bp_core_fetch_avatar(array('item_id' => bp_displayed_user_id(), 'type' => 'thumb', 'alt' => sprintf(__('Profile picture of %s', 'buddyblog'), bp_get_displayed_user_fullname())));
             $bp->bp_options_title = bp_get_displayed_user_fullname();
             // We are viewing a single group, so set up the
             // group navigation menu using the $this->current_group global.
         }
     }
     parent::setup_title();
 }
Esempio n. 2
0
/**
 * Is it new Post page
 * @return type 
 */
function buddyblog_is_new_post()
{
    $action = bp_current_action();
    $post_id = bp_action_variable(0);
    if (bp_is_buddyblog_component() && $action == 'edit' && empty($post_id)) {
        return true;
    }
    return false;
}
Esempio n. 3
0
function buddyblog_modify_page_title($full_title, $title, $sep, $seplocation)
{
    if (!bp_is_buddyblog_component()) {
        return $full_title;
    }
    $post_type_obj = get_post_type_object(buddyblog_get_posttype());
    $full_title = bp_get_displayed_user_fullname() . ' ' . $sep . ' ' . $post_type_obj->labels->name . ' ' . $sep . ' ';
    if (buddyblog_is_single_post()) {
        $post_id = buddyblog_get_post_id(bp_action_variable(0));
        $post = get_post($post_id);
        $full_title .= $post->post_title . ' ' . $sep . ' ';
    } elseif (buddyblog_is_edit_post()) {
        $full_title .= $post_type_obj->labels->edit_item . ' ' . $sep . ' ';
    } elseif (buddyblog_is_new_post()) {
        $full_title .= $post_type_obj->labels->new_item . ' ' . $sep . ' ';
    }
    return $full_title;
    //  bp_get_displayed_user_fullname(), ucwords( $component_name ), $sep
    //if we are here, we are on
}
Esempio n. 4
0
/**
 * Generate pagination links
 * 
 * @global type $wp_query
 */
function buddyblog_paginate()
{
    /// get total number of pages
    global $wp_query;
    $total = $wp_query->max_num_pages;
    // only bother with the rest if we have more than 1 page!
    if ($total > 1) {
        // get the current page
        if (!($current_page = get_query_var('paged'))) {
            $current_page = 1;
        }
        // structure of “format” depends on whether we’re using pretty permalinks
        $perma_struct = get_option('permalink_structure');
        $format = empty($perma_struct) ? '&page=%#%' : 'page/%#%/';
        $base = trailingslashit(buddyblog_get_home_url() . BUDDYBLOG_ARCHIVE_SLUG);
        // echo $base;
        if (bp_is_buddyblog_component()) {
            //$base = $base.'/';
        }
        echo paginate_links(array('base' => $base . '%_%', 'format' => $format, 'current' => $current_page, 'total' => $total, 'mid_size' => 4, 'type' => 'list'));
    }
}
Esempio n. 5
0
 /**
  * Unpublish a post
  */
 public function unpublish()
 {
     if (!(bp_is_buddyblog_component() && bp_is_current_action('unpublish'))) {
         return;
     }
     $id = bp_action_variable(0);
     if (!$id) {
         return;
     }
     if (buddyblog_user_can_unpublish(get_current_user_id(), $id)) {
         $post = get_post($id, ARRAY_A);
         $post['post_status'] = 'draft';
         wp_update_post($post);
         //unpublish
         bp_core_add_message(__('Post unpublished', 'buddyblog'));
     }
     bp_core_redirect(buddyblog_get_home_url());
 }