コード例 #1
0
ファイル: 00-notify.php プロジェクト: kosir/thatcamp-org
 public function setUp()
 {
     parent::setUp();
     // Create new forum
     $this->forum_id = bbp_insert_forum(array('post_title' => 'test-forum', 'post_status' => 'publish'));
     // Create new topic
     $this->topic_id = bbp_insert_topic(array('post_parent' => $this->forum_id, 'post_title' => 'test-topic', 'post_content' => $this->topic_body, 'post_author' => 1), array('forum_id' => $this->forum_id));
     // Create new reply
     $this->reply_id = bbp_insert_reply(array('post_parent' => $this->topic_id, 'post_title' => 'test-reply', 'post_content' => $this->reply_body, 'post_author' => 1), array('forum_id' => $this->forum_id, 'topic_id' => $this->topic_id));
     add_filter('bbpnns_dry_run', '__return_true');
     // Non-spam, non-empty recipents
     $recipients = array('administrator', 'subscriber');
     update_option('bbpress_notify_newtopic_recipients', $recipients);
     $subs_id = $this->factory->user->create(array('role' => 'subscriber'));
 }
コード例 #2
0
/**
 * Create a default forum, topic, and reply
 *
 * @since bbPress (r3767)
 * @param array $args Array of arguments to override default values
 */
function bbp_create_initial_content($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('forum_parent' => 0, 'forum_status' => 'publish', 'forum_title' => __('General', 'bbpress'), 'forum_content' => __('General chit-chat', 'bbpress'), 'topic_title' => __('Hello World!', 'bbpress'), 'topic_content' => __('I am the first topic in your new forums.', 'bbpress'), 'reply_title' => __('Re: Hello World!', 'bbpress'), 'reply_content' => __('Oh, and this is what a reply looks like.', 'bbpress')), 'create_initial_content');
    // Create the initial forum
    $forum_id = bbp_insert_forum(array('post_parent' => $r['forum_parent'], 'post_status' => $r['forum_status'], 'post_title' => $r['forum_title'], 'post_content' => $r['forum_content']));
    // Create the initial topic
    $topic_id = bbp_insert_topic(array('post_parent' => $forum_id, 'post_title' => $r['topic_title'], 'post_content' => $r['topic_content']), array('forum_id' => $forum_id));
    // Create the initial reply
    $reply_id = bbp_insert_reply(array('post_parent' => $topic_id, 'post_title' => $r['reply_title'], 'post_content' => $r['reply_content']), array('forum_id' => $forum_id, 'topic_id' => $topic_id));
    return array('forum_id' => $forum_id, 'topic_id' => $topic_id, 'reply_id' => $reply_id);
}
コード例 #3
0
ファイル: block-ajax.php プロジェクト: httvncoder/151722441
 public function dln_save_topic()
 {
     if (!isset($_POST[DLN_ABE_NONCE]) || !wp_verify_nonce($_POST[DLN_ABE_NONCE], DLN_ABE_NONCE)) {
         $pic_url = isset($_POST['pic_url']) ? $_POST['pic_url'] : '';
         $message = isset($_POST['message']) ? $_POST['message'] : '';
         $forum_id = isset($_POST['forum_id']) ? (int) $_POST['forum_id'] : 0;
         $user_id = get_current_user_id();
         // Validate picture
         $pic_url = self::validate_url_image($pic_url);
         if (!empty($message) && !empty($user_id)) {
             $message = esc_html($message);
             $data = array('pic_url' => $pic_url, 'message' => $message, 'user_id' => $user_id, 'forum_id' => $forum_id);
             if (!DLN_Block_Cache::add_cache($data)) {
                 exit('0');
                 return null;
             }
             $title = wp_trim_words($message, 20, '...');
             $topic_data = array('post_title' => $title, 'post_content' => $message, 'post_author' => $user_id, 'post_status' => 'pending');
             $topic_meta = array('forum_id' => $forum_id);
             $topic_id = bbp_insert_topic($topic_data, $topic_meta);
             $args = array_merge(array('topic_id' => $topic_id), $data);
             exit(json_encode($args));
         }
     }
     exit('0');
 }
コード例 #4
0
ファイル: functions.php プロジェクト: Bnei-Baruch/kabacademy
function custom_bbp_topic_create()
{
    $topic_id = bbp_insert_topic(array('post_parent' => (int) $_POST['bbp_forum_id'], 'post_content' => $_POST['content'], 'post_title' => mb_strlen($_POST['content']) > 100 ? mb_substr($_POST['content'], 0, 100) . '...' : $_POST['content']), array('forum_id' => (int) $_POST['bbp_forum_id']));
    echo print_r($topic_id, true);
    $isAttahced = update_post_meta($topic_id, 'attaches', $_POST['attaches']);
    do_action('nbbi_insert_any', $topic_id);
    if (!is_numeric($isAttahced)) {
        echo $isAttahced;
    }
}
コード例 #5
0
 /**
  * Perform the export
  *
  * @access public
  * @since 1.0
  * @uses bbp_Export::csv_rows_out()
  * @return void
  */
 public function import()
 {
     if (!$this->can_import()) {
         wp_die(__('You do not have permission to import data.', 'bbp-export-import'), __('Error', 'bbp-export-import'));
     }
     $csv_array = $this->csv_to_array($_FILES['bbp_csv_file']['tmp_name'], ';');
     foreach ($csv_array as $key => $line) {
         $post_args = $line;
         $meta_args = array();
         // Setup author date
         if ($post_args['anonymous'] == '1') {
             $meta_args['anonymous_email'] = $line['post_author'];
         } else {
             $user = get_user_by('email', $post_args['post_author']);
             if (!$user) {
                 // The user doesn't exist, so create them
                 $user = wp_insert_user(array('user_email' => $post_args['post_author'], 'user_login' => $post_args['user_login']));
             }
             $post_args['post_author'] = $user->ID;
         }
         // Decode content
         $post_args['post_content'] = html_entity_decode($post_args['post_content']);
         $topic_type = bbp_get_topic_post_type();
         $reply_type = bbp_get_reply_post_type();
         // Remove the post args we don't want sent to wp_insert_post
         unset($post_args['anonymous']);
         unset($post_args['user_login']);
         switch ($line['post_type']) {
             case $topic_type:
                 // Set the forum parent for topics
                 $post_args['post_parent'] = $this->forum_id;
                 $meta_args['voice_count'] = $line['voices'];
                 $meta_args['reply_count'] = $post_args['reply_count'];
                 $topic_id = bbp_insert_topic($post_args, $meta_args);
                 // Subscribe the original poster to the topic
                 bbp_add_user_subscription($post_args['post_author'], $topic_id);
                 // Add the topic to the user's favorites
                 if (bbp_is_user_favorite($post_args['post_author'], $topic_id)) {
                     bbp_add_user_favorite($post_args['post_author'], $topic_id);
                 }
                 // Set topic as resolved if GetShopped Support Forum is active
                 if ($post_args['resolved'] == '1') {
                     add_post_meta($topic_id, '_bbps_topic_status', '2');
                 }
                 break;
             case $reply_type:
                 // Set the forum parent for replies. The topic ID is created above when the replie's topic is first created
                 $post_args['post_parent'] = $topic_id;
                 $reply_id = bbp_insert_reply($post_args, $meta_args);
                 // Subscribe reply author, if not already
                 if (!bbp_is_user_subscribed($post_args['post_author'], $topic_id)) {
                     bbp_add_user_subscription($post_args['post_author'], $topic_id);
                 }
                 // Mark as favorite
                 if (bbp_is_user_favorite($post_args['post_author'], $topic_id)) {
                     bbp_add_user_favorite($post_args['post_author'], $topic_id);
                 }
                 // Check if the next row is a topic, meaning we have reached the last reply and need to update the last active time
                 if ($csv_array[$key + 1]['post_type'] == bbp_get_topic_post_type()) {
                     bbp_update_forum_last_active_time($this->forum_id, $post_args['post_date']);
                 }
                 break;
         }
     }
     // Recount forum topic / reply counts
     bbp_admin_repair_forum_topic_count();
     bbp_admin_repair_forum_reply_count();
     wp_redirect(admin_url('post.php?post=' . $this->forum_id . '&action=edit'));
     exit;
 }
コード例 #6
0
ファイル: factory.php プロジェクト: joeyblake/bbpress
 public function create_object($args)
 {
     $topic_meta = isset($args['topic_meta']) ? $args['topic_meta'] : array();
     $topic_data = bbp_insert_topic($args, $topic_meta);
     return $topic_data;
 }
コード例 #7
0
 /**
  * Create the new topic when selected, including shortcode substitution
  * @param WP_Post $post post object to associate with new topic
  * @param int $topic_forum ID of forum to hold new topic
  */
 function build_new_topic($post, $topic_forum)
 {
     $strings = get_option('bbpress_discussion_text');
     $author_info = get_userdata($post->post_author);
     if (isset($strings['topic-text'])) {
         $topic_content = $strings['topic-text'];
     } else {
         $topic_content = "%excerpt<br />" . sprintf(__('[See the full post at: <a href="%s">%s</a>]', 'bbpress-post-topics'), '%url', '%url');
     }
     $shortcodes = array('%title' => $post->post_title, '%url' => get_permalink($post->ID), '%author' => $author_info->user_nicename, '%excerpt' => empty($post->post_excerpt) ? bbppt_post_discussion_get_the_content($post->post_content, 150) : apply_filters('the_excerpt', $post->post_excerpt), '%post' => $post->post_content);
     $shortcodes = apply_filters('bbppt_shortcodes_output', $shortcodes, $post, $topic_forum);
     $topic_content = str_replace(array_keys($shortcodes), array_values($shortcodes), $topic_content);
     $topic_content = apply_filters('bbppt_topic_content', addslashes($topic_content), $post->ID);
     $new_topic_data = array('post_parent' => (int) $topic_forum, 'post_author' => $post->post_author, 'post_content' => $topic_content, 'post_title' => $post->post_title, 'post_date' => $post->post_date, 'post_date_gmt' => $post->post_date_gmt);
     $new_topic_meta = array('forum_id' => (int) $topic_forum, 'last_active_time' => $post->post_date);
     $new_topic = bbp_insert_topic($new_topic_data, $new_topic_meta);
     return $new_topic;
 }