当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_activity_post_update函数代码示例

本文整理汇总了PHP中bp_activity_post_update函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_activity_post_update函数的具体用法?PHP bp_activity_post_update怎么用?PHP bp_activity_post_update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_activity_post_update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post_comment

 /**
  * Post a gallery or media Main comment on single page
  * 
  * @return type
  */
 public function post_comment()
 {
     // Bail if not a POST action
     if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
         return;
     }
     // Check the nonce
     check_admin_referer('post_update', '_wpnonce_post_update');
     if (!is_user_logged_in()) {
         exit('-1');
     }
     $mpp_type = $_POST['mpp-type'];
     $mpp_id = $_POST['mpp-id'];
     if (empty($_POST['content'])) {
         exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>');
     }
     $activity_id = 0;
     if (empty($_POST['object']) && bp_is_active('activity')) {
         //we are preventing this comment to be set as the user's lastes_update
         $user_id = bp_loggedin_user_id();
         $old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true);
         $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
         //restore
         if (!empty($old_latest_update)) {
             bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update);
         }
     } elseif ($_POST['object'] == 'groups') {
         if (!empty($_POST['item_id']) && bp_is_active('groups')) {
             $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
         }
     } else {
         $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
     }
     if (empty($activity_id)) {
         exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>');
     }
     //if we have got activity id, let us add a meta key
     if ($mpp_type == 'gallery') {
         mpp_activity_update_gallery_id($activity_id, $mpp_id);
     } elseif ($mpp_type == 'media') {
         mpp_activity_update_media_id($activity_id, $mpp_id);
     }
     $activity = new BP_Activity_Activity($activity_id);
     // $activity->component = buddypress()->mediapress->id;
     $activity->type = 'mpp_media_upload';
     $activity->save();
     if (bp_has_activities('include=' . $activity_id)) {
         while (bp_activities()) {
             bp_the_activity();
             mpp_locate_template(array('activity/entry.php'), true);
         }
     }
     exit;
 }
开发者ID:baden03,项目名称:mediapress,代码行数:59,代码来源:class-mpp-ajax-comment-helper.php

示例2: swa_post_update

function swa_post_update()
{
    global $bp;
    /* Check the nonce */
    check_admin_referer('swa_post_update', '_wpnonce_swa_post_update');
    if (!is_user_logged_in()) {
        echo '-1';
        return false;
    }
    if (empty($_POST['content'])) {
        echo '-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'swa') . '</p></div>';
        return false;
    }
    if (empty($_POST['object']) && function_exists('bp_activity_post_update')) {
        $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && function_exists('groups_post_update')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
        }
    } else {
        $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
    }
    if (!$activity_id) {
        echo '-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'swa') . '</p></div>';
        return false;
    }
    $show_avatar = $_POST["show_avatar"] ? $_POST["show_avatar"] : "no";
    $show_content = $_POST["show_content"] ? $_POST["show_content"] : "no";
    if (bp_has_activities('include=' . $activity_id)) {
        ?>
		<?php 
        while (bp_activities()) {
            bp_the_activity();
            ?>
			<?php 
            swa_activity_entry('show_avatar=' . $show_avatar . '&show_activity_content=' . $show_content);
            ?>
		<?php 
        }
        ?>
	 <?php 
    }
    exit(0);
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:44,代码来源:ajax.php

示例3: bp_dtheme_post_update

function bp_dtheme_post_update()
{
    global $bp;
    // Check the nonce
    check_admin_referer('post_update', '_wpnonce_post_update');
    if (!is_user_logged_in()) {
        echo '-1';
        return false;
    }
    if (empty($_POST['content'])) {
        echo '-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>';
        return false;
    }
    $activity_id = 0;
    if (empty($_POST['object']) && bp_is_active('activity')) {
        $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && bp_is_active('groups')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
        }
    } else {
        $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
    }
    if (empty($activity_id)) {
        echo '-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'buddypress') . '</p></div>';
        return false;
    }
    if (bp_has_activities('include=' . $activity_id)) {
        while (bp_activities()) {
            bp_the_activity();
            gconnect_locate_template(array('activity/entry.php'), true);
        }
    }
}
开发者ID:hscale,项目名称:webento,代码行数:34,代码来源:ajax.php

示例4: bp_legacy_theme_post_update

/**
 * Processes Activity updates received via a POST request.
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_legacy_theme_post_update()
{
    $bp = buddypress();
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce
    check_admin_referer('post_update', '_wpnonce_post_update');
    if (!is_user_logged_in()) {
        exit('-1');
    }
    if (empty($_POST['content'])) {
        exit('-1<div id="message" class="error bp-ajax-message"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>');
    }
    $activity_id = 0;
    if (empty($_POST['object']) && bp_is_active('activity')) {
        $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && bp_is_active('groups')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
        }
    } else {
        /** This filter is documented in bp-activity/bp-activity-actions.php */
        $activity_id = apply_filters('bp_activity_custom_update', false, $_POST['object'], $_POST['item_id'], $_POST['content']);
    }
    if (empty($activity_id)) {
        exit('-1<div id="message" class="error bp-ajax-message"><p>' . __('There was a problem posting your update. Please try again.', 'buddypress') . '</p></div>');
    }
    $last_recorded = !empty($_POST['since']) ? date('Y-m-d H:i:s', intval($_POST['since'])) : 0;
    if ($last_recorded) {
        $activity_args = array('since' => $last_recorded);
        $bp->activity->last_recorded = $last_recorded;
        add_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1);
    } else {
        $activity_args = array('include' => $activity_id);
    }
    if (bp_has_activities($activity_args)) {
        while (bp_activities()) {
            bp_the_activity();
            bp_get_template_part('activity/entry');
        }
    }
    if (!empty($last_recorded)) {
        remove_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1);
    }
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:54,代码来源:buddypress-functions.php

示例5: bp_dtheme_post_update

/**
 * Processes Activity updates received via a POST request.
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_dtheme_post_update()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce
    check_admin_referer('post_update', '_wpnonce_post_update');
    if (!is_user_logged_in()) {
        exit('-1');
    }
    if (empty($_POST['content'])) {
        exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'logicalboneshug') . '</p></div>');
    }
    $activity_id = 0;
    if (empty($_POST['object']) && bp_is_active('activity')) {
        $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && bp_is_active('groups')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
        }
    } else {
        $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
    }
    if (empty($activity_id)) {
        exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'logicalboneshug') . '</p></div>');
    }
    if (bp_has_activities('include=' . $activity_id)) {
        while (bp_activities()) {
            bp_the_activity();
            locate_template(array('activity/entry.php'), true);
        }
    }
    exit;
}
开发者ID:raminjan,项目名称:logicalbones_hug,代码行数:41,代码来源:ajax.php

示例6: bp_activity_action_post_update

/**
 * Post user/group activity update.
 *
 * @since 1.2.0
 *
 * @uses is_user_logged_in()
 * @uses bp_is_activity_component()
 * @uses bp_is_current_action()
 * @uses check_admin_referer()
 * @uses apply_filters() To call 'bp_activity_post_update_content' hook.
 * @uses apply_filters() To call 'bp_activity_post_update_object' hook.
 * @uses apply_filters() To call 'bp_activity_post_update_item_id' hook.
 * @uses bp_core_add_message()
 * @uses bp_core_redirect()
 * @uses bp_activity_post_update()
 * @uses groups_post_update()
 * @uses bp_core_redirect()
 * @uses apply_filters() To call 'bp_activity_custom_update' hook.
 *
 * @return bool False on failure.
 */
function bp_activity_action_post_update()
{
    // Do not proceed if user is not logged in, not viewing activity, or not posting.
    if (!is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action('post')) {
        return false;
    }
    // Check the nonce.
    check_admin_referer('post_update', '_wpnonce_post_update');
    /**
     * Filters the content provided in the activity input field.
     *
     * @since 1.2.0
     *
     * @param string $value Activity message being posted.
     */
    $content = apply_filters('bp_activity_post_update_content', $_POST['whats-new']);
    if (!empty($_POST['whats-new-post-object'])) {
        /**
         * Filters the item type that the activity update should be associated with.
         *
         * @since 1.2.0
         *
         * @param string $value Item type to associate with.
         */
        $object = apply_filters('bp_activity_post_update_object', $_POST['whats-new-post-object']);
    }
    if (!empty($_POST['whats-new-post-in'])) {
        /**
         * Filters what component the activity is being to.
         *
         * @since 1.2.0
         *
         * @param string $value Chosen component to post activity to.
         */
        $item_id = apply_filters('bp_activity_post_update_item_id', $_POST['whats-new-post-in']);
    }
    // No activity content so provide feedback and redirect.
    if (empty($content)) {
        bp_core_add_message(__('Please enter some content to post.', 'buddypress'), 'error');
        bp_core_redirect(wp_get_referer());
    }
    // No existing item_id.
    if (empty($item_id)) {
        $activity_id = bp_activity_post_update(array('content' => $content));
        // Post to groups object.
    } elseif ('groups' == $object && bp_is_active('groups')) {
        if ((int) $item_id) {
            $activity_id = groups_post_update(array('content' => $content, 'group_id' => $item_id));
        }
    } else {
        /**
         * Filters activity object for BuddyPress core and plugin authors before posting activity update.
         *
         * @since 1.2.0
         *
         * @param string $object  Activity item being associated to.
         * @param string $item_id Component ID being posted to.
         * @param string $content Activity content being posted.
         */
        $activity_id = apply_filters('bp_activity_custom_update', $object, $item_id, $content);
    }
    // Provide user feedback.
    if (!empty($activity_id)) {
        bp_core_add_message(__('Update Posted!', 'buddypress'));
    } else {
        bp_core_add_message(__('There was an error when posting your update. Please try again.', 'buddypress'), 'error');
    }
    // Redirect.
    bp_core_redirect(wp_get_referer());
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:91,代码来源:bp-activity-actions.php

示例7: bp_activity_action_post_update

/**
 * Post user/group activity update.
 *
 * @since BuddyPress (1.2)
 *
 * @uses is_user_logged_in()
 * @uses bp_is_activity_component()
 * @uses bp_is_current_action()
 * @uses check_admin_referer()
 * @uses apply_filters() To call 'bp_activity_post_update_content' hook.
 * @uses apply_filters() To call 'bp_activity_post_update_object' hook.
 * @uses apply_filters() To call 'bp_activity_post_update_item_id' hook.
 * @uses bp_core_add_message()
 * @uses bp_core_redirect()
 * @uses bp_activity_post_update()
 * @uses groups_post_update()
 * @uses bp_core_redirect()
 * @uses apply_filters() To call 'bp_activity_custom_update' hook.
 *
 * @return bool False on failure.
 */
function bp_activity_action_post_update()
{
    // Do not proceed if user is not logged in, not viewing activity, or not posting
    if (!is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action('post')) {
        return false;
    }
    // Check the nonce
    check_admin_referer('post_update', '_wpnonce_post_update');
    // Get activity info
    $content = apply_filters('bp_activity_post_update_content', $_POST['whats-new']);
    if (!empty($_POST['whats-new-post-object'])) {
        $object = apply_filters('bp_activity_post_update_object', $_POST['whats-new-post-object']);
    }
    if (!empty($_POST['whats-new-post-in'])) {
        $item_id = apply_filters('bp_activity_post_update_item_id', $_POST['whats-new-post-in']);
    }
    // No activity content so provide feedback and redirect
    if (empty($content)) {
        bp_core_add_message(__('Please enter some content to post.', 'buddypress'), 'error');
        bp_core_redirect(wp_get_referer());
    }
    // No existing item_id
    if (empty($item_id)) {
        $activity_id = bp_activity_post_update(array('content' => $content));
        // Post to groups object
    } else {
        if ('groups' == $object && bp_is_active('groups')) {
            if ((int) $item_id) {
                $activity_id = groups_post_update(array('content' => $content, 'group_id' => $item_id));
            }
            // Special circumstance so let filters handle it
        } else {
            $activity_id = apply_filters('bp_activity_custom_update', $object, $item_id, $content);
        }
    }
    // Provide user feedback
    if (!empty($activity_id)) {
        bp_core_add_message(__('Update Posted!', 'buddypress'));
    } else {
        bp_core_add_message(__('There was an error when posting your update, please try again.', 'buddypress'), 'error');
    }
    // Redirect
    bp_core_redirect(wp_get_referer());
}
开发者ID:eresyyl,项目名称:mk,代码行数:65,代码来源:bp-activity-actions.php

示例8: bpdd_import_users_activity

function bpdd_import_users_activity()
{
    $users = bpdd_get_random_users_ids(0);
    require dirname(__FILE__) . '/data/activity.php';
    for ($i = 0, $count = 0; $i < 75; $i++) {
        $user = $users[array_rand($users)];
        $content = $activity[array_rand($activity)];
        if (bp_activity_post_update(array('user_id' => $user, 'content' => $content))) {
            $count++;
        }
    }
    return $count;
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:13,代码来源:bp-default-data.php

示例9: bp_mytheme_post_update

function bp_mytheme_post_update()
{
    global $bp;
    // Check the nonce
    check_admin_referer('post_update', '_wpnonce_post_update');
    if (!is_user_logged_in()) {
        echo '-1';
        return false;
    }
    if (empty($_POST['content'])) {
        echo '-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>';
        return false;
    }
    if (empty($_POST['object']) && function_exists('bp_activity_post_update')) {
        if (!bp_is_home() && bp_is_member()) {
            $content = "@" . bp_get_displayed_user_username() . " " . $_POST['content'];
        } else {
            $content = $_POST['content'];
        }
        $activity_id = bp_activity_post_update(array('content' => $content));
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && function_exists('groups_post_update')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
        }
    } else {
        $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
    }
    if (!$activity_id) {
        echo '-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'buddypress') . '</p></div>';
        return false;
    }
    if (bp_has_activities('include=' . $activity_id)) {
        ?>
		<?php 
        while (bp_activities()) {
            bp_the_activity();
            ?>
		<?php 
            locate_template(array('activity/entry-wall.php'), true);
            ?>
		<?php 
        }
        ?>
		<?php 
    }
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:46,代码来源:buddy_boss_wall.php

示例10: devb_aawire_post_update

function devb_aawire_post_update()
{
    global $bp;
    $is_wire_post = false;
    /* Check the nonce */
    check_admin_referer('post_update', '_wpnonce_post_update');
    if (!is_user_logged_in()) {
        echo '-1';
        exit(0);
    }
    if (empty($_POST['content'])) {
        echo '-1<div id="message"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>';
        exit(0);
    }
    if (empty($_POST['object']) && function_exists('bp_activity_post_update')) {
        //this is what I have changed
        if (!bp_is_my_profile() && bp_is_user()) {
            $content = '@' . bp_get_displayed_user_username() . ' ' . $_POST['content'];
            $is_wire_post = true;
        } else {
            $content = $_POST['content'];
        }
        //let us get the last activity id, we will use it to reset user's last activity
        $last_update = bp_get_user_meta(bp_loggedin_user_id(), 'bp_latest_update', true);
        if ($is_wire_post) {
            add_filter('bp_activity_new_update_action', 'devb_aawire_filter_action');
        }
        $activity_id = bp_activity_post_update(array('content' => $content));
        if ($is_wire_post) {
            remove_filter('bp_activity_new_update_action', 'devb_aawire_filter_action');
            //add activity meta to remember that it was a wire post and we may use it in future
            if ($activity_id) {
                bp_activity_update_meta($activity_id, 'is_wire_post', 1);
            }
            //let us remember it for future
            //for 2.0 Let us add the mentioned user in the meta, so in future if we plan eo extend the wall beyond mention, we can do that easily
            bp_activity_update_meta($activity_id, 'wire_user_id', bp_displayed_user_id());
            //let us remember it for future
        }
        //reset the last update
        bp_update_user_meta(get_current_user_id(), 'bp_latest_update', $last_update);
        //end of my changes
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && function_exists('groups_post_update')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
        }
    } else {
        $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
    }
    if (!$activity_id) {
        echo '-1<div id="message"><p>' . __('There was a problem posting your update, please try again.', 'buddypress') . '</p></div>';
        exit(0);
    }
    if (bp_has_activities('include=' . $activity_id)) {
        ?>
     <?php 
        while (bp_activities()) {
            bp_the_activity();
            ?>
        <?php 
            bp_locate_template(array('activity/entry.php'), true);
            ?>
     <?php 
        }
        ?>
     <?php 
    }
    exit(0);
}
开发者ID:poweronio,项目名称:mbsite,代码行数:69,代码来源:bp-activity-as-wire.php

示例11: bp_legacy_theme_post_update

/**
 * Processes Activity updates received via a POST request.
 *
 * @return string HTML
 * @since 1.2.0
 */
function bp_legacy_theme_post_update()
{
    $bp = buddypress();
    // Bail if not a POST action.
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce.
    check_admin_referer('post_update', '_wpnonce_post_update');
    if (!is_user_logged_in()) {
        exit('-1');
    }
    if (empty($_POST['content'])) {
        exit('-1<div id="message" class="error bp-ajax-message"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>');
    }
    $activity_id = 0;
    $item_id = 0;
    $object = '';
    // Try to get the item id from posted variables.
    if (!empty($_POST['item_id'])) {
        $item_id = (int) $_POST['item_id'];
    }
    // Try to get the object from posted variables.
    if (!empty($_POST['object'])) {
        $object = sanitize_key($_POST['object']);
        // If the object is not set and we're in a group, set the item id and the object
    } elseif (bp_is_group()) {
        $item_id = bp_get_current_group_id();
        $object = 'groups';
    }
    if (!$object && bp_is_active('activity')) {
        $activity_id = bp_activity_post_update(array('content' => $_POST['content'], 'error_type' => 'wp_error'));
    } elseif ('groups' === $object) {
        if ($item_id && bp_is_active('groups')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $item_id, 'error_type' => 'wp_error'));
        }
    } else {
        /** This filter is documented in bp-activity/bp-activity-actions.php */
        $activity_id = apply_filters('bp_activity_custom_update', false, $object, $item_id, $_POST['content']);
    }
    if (false === $activity_id) {
        exit('-1<div id="message" class="error bp-ajax-message"><p>' . __('There was a problem posting your update. Please try again.', 'buddypress') . '</p></div>');
    } elseif (is_wp_error($activity_id) && $activity_id->get_error_code()) {
        exit('-1<div id="message" class="error bp-ajax-message"><p>' . $activity_id->get_error_message() . '</p></div>');
    }
    $last_recorded = !empty($_POST['since']) ? date('Y-m-d H:i:s', intval($_POST['since'])) : 0;
    if ($last_recorded) {
        $activity_args = array('since' => $last_recorded);
        $bp->activity->last_recorded = $last_recorded;
        add_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1);
    } else {
        $activity_args = array('include' => $activity_id);
    }
    if (bp_has_activities($activity_args)) {
        while (bp_activities()) {
            bp_the_activity();
            bp_get_template_part('activity/entry');
        }
    }
    if (!empty($last_recorded)) {
        remove_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10);
    }
    exit;
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:70,代码来源:buddypress-functions.php

示例12: test_bp_activity_post_update_success

 /**
  * @group bp_activity_post_update
  */
 public function test_bp_activity_post_update_success()
 {
     $u = $this->factory->user->create();
     $a = bp_activity_post_update(array('user_id' => $u, 'content' => 'foo'));
     $this->assertNotEmpty($a);
 }
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:9,代码来源:functions.php

示例13: ajax_update_activity_contents

 /**
  * This is where we actually save the activity update.
  */
 function ajax_update_activity_contents()
 {
     $bpfb_code = $activity = '';
     $aid = 0;
     $codec = new BpfbCodec();
     if (!empty($_POST['data']['bpfb_video_url'])) {
         $bpfb_code = $codec->create_video_tag($_POST['data']['bpfb_video_url']);
     }
     if (!empty($_POST['data']['bpfb_link_url'])) {
         $bpfb_code = $codec->create_link_tag($_POST['data']['bpfb_link_url'], $_POST['data']['bpfb_link_title'], $_POST['data']['bpfb_link_body'], $_POST['data']['bpfb_link_image']);
     }
     if (!empty($_POST['data']['bpfb_photos'])) {
         $images = $this->move_images($_POST['data']['bpfb_photos']);
         $bpfb_code = $codec->create_images_tag($images);
     }
     $bpfb_code = apply_filters('bpfb_code_before_save', $bpfb_code);
     // All done creating tags. Now, save the code
     $gid = (int) @$_POST['group_id'];
     if ($bpfb_code) {
         $content = @$_POST['content'] . "\n" . $bpfb_code;
         $content = apply_filters('bp_activity_post_update_content', $content);
         $aid = $gid ? groups_post_update(array('content' => $content, 'group_id' => $gid)) : bp_activity_post_update(array('content' => $content));
         global $blog_id;
         bp_activity_update_meta($aid, 'bpfb_blog_id', $blog_id);
     }
     if ($aid) {
         ob_start();
         if (bp_has_activities('include=' . $aid)) {
             while (bp_activities()) {
                 bp_the_activity();
                 if (function_exists('bp_locate_template')) {
                     bp_locate_template(array('activity/entry.php'), true);
                 } else {
                     locate_template(array('activity/entry.php'), true);
                 }
             }
         }
         $activity = ob_get_clean();
     }
     header('Content-type: application/json');
     echo json_encode(array('code' => $bpfb_code, 'id' => $aid, 'activity' => $activity));
     exit;
 }
开发者ID:pausaura,项目名称:agora_nodes,代码行数:46,代码来源:class_bpfb_binder.php

示例14: bp_activity_action_post_update

function bp_activity_action_post_update() {
	global $bp;

	if ( !is_user_logged_in() || $bp->current_component != $bp->activity->slug || $bp->current_action != 'post' )
		return false;

	/* Check the nonce */
	check_admin_referer( 'post_update', '_wpnonce_post_update' );

	$content = apply_filters( 'bp_activity_post_update_content', $_POST['whats-new'] );
	$object = apply_filters( 'bp_activity_post_update_object', $_POST['whats-new-post-object'] );
	$item_id = apply_filters( 'bp_activity_post_update_item_id', $_POST['whats-new-post-in'] );

	if ( empty( $content ) ) {
		bp_core_add_message( __( 'Please enter some content to post.', 'buddypress' ), 'error' );
		bp_core_redirect( wp_get_referer() );
	}

	if ( !(int)$item_id ) {
		$activity_id = bp_activity_post_update( array( 'content' => $content ) );

	} else if ( 'groups' == $object && function_exists( 'groups_post_update' ) ) {
		if ( (int)$item_id ) {
			$activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
		}
	} else
		$activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );

	if ( !empty( $activity_id ) )
		bp_core_add_message( __( 'Update Posted!', 'buddypress' ) );
	else
		bp_core_add_message( __( 'There was an error when posting your update, please try again.', 'buddypress' ), 'error' );

	bp_core_redirect( wp_get_referer() );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:35,代码来源:bp-activity.php

示例15: bp_template_pack_post_update

/**
 * Processes Activity updates received via a POST request.
 *
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_template_pack_post_update()
{
    $bp = buddypress();
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Check the nonce
    check_admin_referer('post_update', '_wpnonce_post_update');
    if (!is_user_logged_in()) {
        exit('-1');
    }
    if (empty($_POST['content'])) {
        exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>');
    }
    $activity_id = 0;
    if (empty($_POST['object']) && bp_is_active('activity')) {
        $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
    } elseif ($_POST['object'] == 'groups') {
        if (!empty($_POST['item_id']) && bp_is_active('groups')) {
            $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
        }
    } else {
        $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
    }
    if (empty($activity_id)) {
        exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'buddypress') . '</p></div>');
    }
    $last_id = isset($_POST['offset']) ? absint($_POST['offset']) + 1 : 0;
    if ($last_id) {
        $activity_args = array('offset' => $last_id);
        $bp->activity->new_update_id = $activity_id;
        add_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1);
    } else {
        $activity_args = array('include' => $activity_id);
    }
    if (bp_has_activities($activity_args)) {
        while (bp_activities()) {
            bp_the_activity();
            bp_get_template_part('activity/entry');
        }
    }
    if (!empty($last_id)) {
        remove_filter('bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1);
    }
    exit;
}
开发者ID:wesavetheworld,项目名称:buddypress-templates,代码行数:53,代码来源:buddypress-ajax.php


注:本文中的bp_activity_post_update函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。