/** * Plugin Name: Post Notification * Plugin Description: Sends an Notification email if there's a new post to an favorite topic. (Modified Version 1.4 with Post Content included in E-Mail) * Author: Thomas Klaiber * Author URI: http://thomasklaiber.com/ * Plugin URI: http://thomasklaiber.com/bbpress/post-notification/ * Version: 1.4 */ function notification_new_post($post_id = 0) { global $bbdb, $bb_table_prefix, $topic_id, $bb_current_user; $all_users = notification_select_all_users(); foreach ($all_users as $userdata) { if (notification_is_activated($userdata->ID)) { if (is_user_favorite($userdata->ID, $topic_id)) { //$topic = get_topic($topic_id); $message = __("Hello,\n\nA new post on \"%1\$s\" has been added by %2\$s at DHAnswers. \n\nMessage:\n\n%3\$s \n\n%4\$s "); mail($userdata->user_email, '[DHAnswers] New Post for Favorite Question', sprintf($message, get_topic_title($topic_id), get_user_name($bb_current_user->ID), strip_tags(get_post_text($post_id)), get_topic_link($topic_id)), 'From: ' . bb_get_option('name') . ' <' . bb_get_option('from_email') . '>'); } } } }
function make_discussion($forum, $posts, $readusers, &$userids, $ratingpercent) { set_time_limit(200); // Make discussion static $index = 0; $index++; list($discussionid, $postid) = $forum->create_discussion(null, 'Discussion ' . $index, get_post_text(), FORMAT_HTML, array(), false, 0, 0, false, false, $userids[mt_rand(0, count($userids) - 1)], false); $discussion = forum_discussion::get_from_id($discussionid, forum::CLONE_DIRECT); // Make posts $count = my_random($posts) - 1; $allposts = array($discussion->get_root_post()); for ($i = 0; $i < $count; $i++) { make_post($discussion, $allposts, $userids, $ratingpercent); } // Mark the discussion read if requested if ($readusers > 0) { $now = time(); for ($i = 0; $i < $readusers; $i++) { $discussion->mark_read($now, $userids[$i]); } } // Progress print '.'; }
function get_socialit() { global $socialit_plugopts, $bbdb, $public_tags, $socialit_is_mobile, $socialit_is_bot; $dont_get_si = false; $topic = get_topic(get_topic_id()); if (class_exists('Support_Forum') && $topic) { //compatibility with Support Forum plugin for bbPress $support_forum = new Support_Forum(); if ($support_forum->isActive() && in_array($topic->forum_id, $support_forum->enabled)) { if ($socialit_plugopts['sfpnonres'] == "no" && $support_forum->getTopicStatus() == "no" || $socialit_plugopts['sfpres'] == "no" && $support_forum->getTopicStatus() == "yes" || $socialit_plugopts['sfpnonsup'] == "no" && $support_forum->getTopicStatus() == "mu") { $dont_get_si = true; } } } if ($socialit_plugopts['mobile-hide'] == 'yes' && ($socialit_is_mobile || $socialit_is_bot)) { $dont_get_si = true; } if (bb_is_topic() && bb_get_topicmeta($topic->topic_id, 'hide_socialit') == true) { $dont_get_si = true; } if (!$dont_get_si) { if (bb_is_topic()) { $perms = urlencode(get_topic_link()); $title = get_topic_title(); $feedperms = strtolower($perms); // Grab post tags for Twittley tags. If there aren't any, use default tags set in plugin options page $get_tags = bb_get_topic_tags(get_topic_id()); if ($get_tags) { foreach ($get_tags as $tag) { $keywords = $keywords . $tag->name . ','; } } $topic_id_ft = get_topic_id(); //topic id for getting text $first_post = (int) $bbdb->get_var("SELECT post_id FROM {$bbdb->posts} WHERE topic_id = {$topic_id_ft} ORDER BY post_id ASC LIMIT 1"); $socialit_content = get_post_text($first_post); } else { $perms = socialit_get_current_url(); $title = bb_get_title(); $feedperms = strtolower($perms); $socialit_content = bb_get_option('description'); } if (strlen($title) >= 80) { $short_title = urlencode(substr($title, 0, 80) . "[..]"); } else { $short_title = urlencode($title); } $title = urlencode($title); $site_name = bb_get_option('name'); $socialit_content = urlencode(substr(strip_tags(strip_shortcodes($socialit_content)), 0, 300)); $socialit_content = socialit_change_plus_apos($socialit_content); $mail_subject = socialit_change_plus_apos($title); $post_summary = stripslashes($socialit_content); if (!empty($keywords)) { $d_tags = $keywords; } else { $d_tags = $socialit_plugopts['defaulttags']; } $site_name = bb_get_option('name'); $y_cat = $socialit_plugopts['ybuzzcat']; $y_med = $socialit_plugopts['ybuzzmed']; $t_cat = $socialit_plugopts['twittcat']; $short_url = socialit_get_fetch_url(); $current_rss_link = socialit_get_current_rss_link(); // Temporary fix for bug that breaks layout when using NextGen Gallery plugin if (strpos($post_summary, '[') || strpos($post_summary, ']')) { $post_summary = ""; } if (strpos($socialit_content, '[') || strpos($socialit_content, ']')) { $socialit_content = ""; } // select the background if (!isset($socialit_plugopts['bgimg-yes'])) { $bgchosen = ''; } elseif ($socialit_plugopts['bgimg'] == 'sexy') { $bgchosen = ' social-it-bg-sexy'; } elseif ($socialit_plugopts['bgimg'] == 'caring') { $bgchosen = ' social-it-bg-caring'; } elseif ($socialit_plugopts['bgimg'] == 'care-old') { $bgchosen = ' social-it-bg-caring-old'; } elseif ($socialit_plugopts['bgimg'] == 'love') { $bgchosen = ' social-it-bg-love'; } elseif ($socialit_plugopts['bgimg'] == 'wealth') { $bgchosen = ' social-it-bg-wealth'; } elseif ($socialit_plugopts['bgimg'] == 'enjoy') { $bgchosen = ' social-it-bg-enjoy'; } $style = $socialit_plugopts['autocenter'] ? '' : ' style="' . __($socialit_plugopts['xtrastyle']) . '"'; $isfeed = bb_is_feed(); if ($isfeed) { $style = ''; } // do not add inline styles to the feed. $expand = $socialit_plugopts['expand'] ? ' social-it-expand' : ''; if ($socialit_plugopts['autocenter'] == 1) { $autocenter = ' social-it-center'; } elseif ($socialit_plugopts['autocenter'] == 2) { $autocenter = ' social-it-spaced'; } else { $autocenter = ''; } //write the menu $socials = "\n\n" . '<!-- Start Of Code Generated By Social It Plugin By www.gaut.am -->' . "\n" . '<div class="social-it' . $expand . $autocenter . $bgchosen . '"' . $style . '><ul class="socials">'; foreach ($socialit_plugopts['bookmark'] as $name) { if ($name == 'socialit-twitter') { $socials .= bookmark_list_item($name, array('post_by' => !empty($socialit_plugopts['twittid']) ? "(via+@" . $socialit_plugopts['twittid'] . ")" : '', 'short_title' => $short_title, 'fetch_url' => $short_url)); } elseif ($name == 'socialit-mail') { $socials .= bookmark_list_item($name, array('title' => $mail_subject, 'post_summary' => $post_summary, 'permalink' => $perms)); } elseif ($name == 'socialit-diigo') { $socials .= bookmark_list_item($name, array('socialit_teaser' => $socialit_content, 'permalink' => $perms, 'title' => $title)); } elseif ($name == 'socialit-linkedin') { $socials .= bookmark_list_item($name, array('post_summary' => $post_summary, 'site_name' => $site_name, 'permalink' => $perms, 'title' => $title)); } elseif ($name == 'socialit-comfeed') { $socials .= bookmark_list_item($name, array('permalink' => $current_rss_link)); } elseif ($name == 'socialit-yahoobuzz') { $socials .= bookmark_list_item($name, array('permalink' => $perms, 'title' => $title, 'yahooteaser' => $socialit_content, 'yahoocategory' => $y_cat, 'yahoomediatype' => $y_med)); } elseif ($name == 'socialit-twittley') { $socials .= bookmark_list_item($name, array('permalink' => urlencode($perms), 'title' => $title, 'post_summary' => $post_summary, 'twitt_cat' => $t_cat, 'default_tags' => $d_tags)); } else { $socials .= bookmark_list_item($name, array('post_summary' => $post_summary, 'permalink' => $perms, 'title' => $title)); } } $socials .= '</ul><div style="clear:both;"></div></div><!-- End Of Code Generated By Social It Plugin By www.gaut.am -->' . "\n\n"; return $socials; } }
function post_text($post_id = 0) { echo apply_filters('post_text', get_post_text($post_id), get_post_id($post_id)); }
?> " /> </label> </p> <?php } do_action('edit_form_pre_post'); ?> <p> <label for="post_content"><?php _e('Post:'); ?> <br /> <textarea name="post_content" cols="50" rows="8" tabindex="32" id="post_content"><?php echo apply_filters('edit_text', get_post_text()); ?> </textarea> </label> </p> <?php if (bb_get_user(get_post_author_id()) && bb_is_subscriptions_active()) { ?> <p id="post-form-subscription-container" class="left"> <?php bb_user_subscribe_checkbox('tab=33'); ?> </p> <?php }
function nm_post_text($post_id = 0) { $content = apply_filters('post_text', get_post_text($post_id), get_post_id($post_id)); $yt_number_part = substr($content, 0, strpos($content, '</youtube>')); $yt_number_stripped = strstr($yt_number_part, '<youtube>'); $yt_number_stripped = str_replace('<youtube>', '', $yt_number_stripped); $full_code = '<youtube>' . $yt_number_stripped . '</youtube>'; $youtube = '<object width="350" height="350"><param name="movie" value="http://www.youtube.com/v/' . $yt_number_stripped . '&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $yt_number_stripped . '&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="350" height="350"></embed></object>'; $content_new = str_replace($full_code, $youtube, $content); //If the user has deleted the content, it will be blank. handle that... if (strlen($content_new) < 7) { $content_new = "The Author has deleted the content of this post."; } echo $content_new; }