function cjtheme_activity_posted_update($content, $user_id, $activity_id) { global $wpdb, $current_user; $table_activity = $wpdb->prefix . 'bp_activity'; // Create post object $my_post = array('post_title' => cjtheme_trim_text($content, 30), 'post_content' => $content, 'post_status' => 'publish', 'post_type' => $_POST['category'], 'post_author' => $current_user->ID); // Insert the post into the database $post_id = wp_insert_post($my_post); $new_activity_id = $wpdb->get_row("SELECT * FROM {$table_activity} WHERE secondary_item_id = '{$post_id}'"); bp_activity_delete_by_activity_id($activity_id); return $new_activity_id->id; }
function cjtheme_insert_answer() { global $wpdb; $errors = null; parse_str($_POST['postdata'], $postdata); $user_info = cjtheme_user_info($postdata['user_id']); $time = current_time('mysql'); $comment_data = array('comment_post_ID' => $postdata['post_id'], 'comment_author' => $user_info['user_login'], 'comment_author_email' => $user_info['user_email'], 'comment_author_url' => '', 'comment_content' => esc_textarea($postdata['comment']), 'user_id' => $user_info['ID'], 'comment_date' => $time, 'comment_approved' => 1); $comment_id = wp_insert_comment($comment_data); if (strlen($postdata['comment']) >= 140) { gamf_add_points($user_info['ID'], 1, 'comment-140', 'You answered a question with more than 140 characters.'); } $post_info = cjtheme_post_info($postdata['post_id']); $nmessage = '<a href="' . site_url($user_info['user_login']) . '">' . $user_info['display_name'] . '</a> answered your <a href="' . get_permalink($post_info['ID']) . '">question</a>.'; $nmessage .= '<br>' . cjtheme_trim_text($post_info['post_content'], 160, '...'); cjtheme_notification_add($post_info['post_author'], $nmessage); $return['success'] = get_permalink($post_info['ID']) . '#answer-' . $comment_id; echo json_encode($return); die; }
function cjtheme_replace_title_separator($title) { $title_prefix = cjtheme_get_option('wp_head_wp_title_prefix'); $title_suffix = cjtheme_get_option('wp_head_wp_title_suffix'); $title_maxlength = cjtheme_get_option('wp_head_wp_title_maxlength'); $title_replace = cjtheme_get_option('wp_head_wp_title_replace'); $return[] = $title_prefix ? $title_prefix . ' ' : ''; if ($title_maxlength) { $title = cjtheme_trim_text($title, $title_maxlength, '..'); } else { $title = $title; } $return[] = $title; $return[] = $title_suffix ? ' ' . $title_suffix : ''; $title = implode('', $return); if ($title_replace) { $replace = $title_replace['text_to_replace']; $with = $title_replace['new_text_value']; $title = str_replace($replace, $with, $title); } return $title; }