Ejemplo n.º 1
0
function bp_link_description_excerpt($length = 55)
{
    echo bp_get_link_description_excerpt($length);
}
Ejemplo n.º 2
0
function bp_links_action_create_link()
{
    global $bp;
    // get component that is creating link
    $component_id = bp_links_create_component_id();
    // must have a component (string)
    if (false === $component_id) {
        return false;
    }
    // User must be logged in to create links
    if (!is_user_logged_in()) {
        return false;
    }
    // If the save, upload or embed button is clicked, lets try to save
    if (isset($_POST['save'])) {
        // Check the nonce
        check_admin_referer('bp_link_details_form_save');
        // validate the data fields, redirects on error
        $data_valid = bp_links_validate_create_form_input();
        if (!empty($data_valid)) {
            // try to create the link
            $bp->links->current_link = bp_links_manage_link(array('category_id' => $data_valid['link-category'], 'url' => $data_valid['link-url'], 'name' => $data_valid['link-name'], 'description' => $data_valid['link-desc'], 'status' => $data_valid['link-status'], 'embed_data' => $data_valid['link-url-embed-data'], 'embed_thidx' => $data_valid['link-url-embed-thidx'], 'group_id' => $data_valid['link-group-id'], 'meta' => $data_valid['link-meta']));
            if (bp_links_current_link_exists()) {
                bp_links_update_linkmeta($bp->links->current_link->id, 'last_activity', time());
                bp_links_record_activity(array('item_id' => $bp->links->current_link->id, 'action' => apply_filters('bp_links_activity_created_link', sprintf(__('%1$s created the link %2$s', 'buddypress-links'), bp_core_get_userlink($bp->loggedin_user->id), '<a href="' . bp_get_link_permalink($bp->links->current_link) . '">' . attribute_escape($bp->links->current_link->name) . '</a>')), 'content' => apply_filters('bp_links_activity_created_link_content', bp_get_link_description_excerpt($bp->links->current_link)), 'primary_link' => apply_filters('bp_links_activity_created_link_primary_link', bp_get_link_permalink($bp->links->current_link)), 'type' => BP_LINKS_ACTIVITY_ACTION_CREATE));
                do_action('bp_links_create_complete', $bp->links->current_link->id);
                if ($_POST['link-avatar-option'] == 1) {
                    bp_core_redirect(bp_get_link_permalink($bp->links->current_link) . '/admin/link-avatar');
                } else {
                    bp_core_redirect(bp_get_link_permalink($bp->links->current_link));
                }
            } else {
                bp_core_add_message(sprintf('%s %s', __('There was an error saving link details.', 'buddypress-links'), __('Please try again.', 'buddypress-links')), 'error');
            }
        }
    }
    // only load the template for native links component.
    // the group extension *should* load the correct template for us if applicable
    if (bp_links_id() == $component_id) {
        if (bp_displayed_user_id()) {
            bp_links_screen_personal_links();
        } else {
            bp_links_load_template(apply_filters('bp_links_template_create_link', 'create'));
        }
    }
}