/** * Output the ID of the current post in the loop. */ function bp_the_topic_post_id() { echo bp_get_the_topic_post_id(); }
function rw_display_forum_post_rating($content) { if (RWLogger::IsOn()) { $params = func_get_args(); RWLogger::LogEnterence("rw_display_forum_post_rating", $params); } // global $bp, $topic_template, $forum_template; // if the topic is closed, return just the rating number // if ( 0 == (int)$forum_template->topic->topic_open && !is_site_admin() ) // return $post_text . '<div class="rfp-rate"><b>'.get_option( 'rfp_help_text_closed' ).'</b><span class="counter">' . rfp_get_post_rating_signed( $topic_template->post->post_id ) . '</span></div>'; $rclass = "forum-post"; // Check if item rating is top positioned. if (!isset($this->forum_align[$rclass])) { return $content; } $post_id = bp_get_the_topic_post_id(); // Validate that item isn't explicitly excluded. if (false === $this->rw_validate_visibility($post_id, $rclass)) { return $content; } // Get forum-post user-rating-id. $post_urid = $this->_getForumPostRatingGuid($post_id); // Queue activity-comment rating. self::QueueRatingData($post_urid, strip_tags($topic_template->post->post_text), bp_get_the_topic_permalink() . "#post-" . $post_id, $rclass); /* // Get corresponding user's accamulator rating id. $uarid = $this->_getUserRatingGuid(WP_RW__FORUM_POST_SECONDERY_ID, bp_get_the_topic_poster_id()); $rw = '<div class="rw-' . $this->forum_align[$rclass]->hor . '"><div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $post_urid . ' rw-uarid-' . $uarid . '"></div></div>'; */ $rw = '<div class="rw-' . $this->forum_align[$rclass]->hor . '"><div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $post_urid . '"></div></div>'; // Attach rating html container. return $this->forum_align[$rclass]->ver == "top" ? $rw . $content : $content . $rw; }
/** * Add bbPress forum post ratings. This method is for old versions of bbPress & BuddyPress bundle. * * @param mixed $content * * @return string */ public function rw_display_forum_post_rating($content) { if (RWLogger::IsOn()) { $params = func_get_args(); RWLogger::LogEnterence('rw_display_forum_post_rating', $params); } $rclass = 'forum-post'; // Check if item rating is top positioned. if (!isset($this->forum_align[$rclass])) { return $content; } $post_id = bp_get_the_topic_post_id(); /* // Validate that item isn't explicitly excluded. if (false === $this->rw_validate_visibility($post_id, $rclass)) return $content; // Get forum-post user-rating-id. $post_urid = $this->_getForumPostRatingGuid($post_id); // Queue activity-comment rating. $this->QueueRatingData($post_urid, strip_tags($topic_template->post->post_text), bp_get_the_topic_permalink() . "#post-" . $post_id, $rclass); $rw = '<div class="rw-' . $this->forum_align[$rclass]->hor . '"><div class="rw-ui-container rw-class-' . $rclass . ' rw-urid-' . $post_urid . '"></div></div>'; */ global $topic_template; // Add accumulator id if user accumulated rating. if ($this->IsUserAccumulatedRating()) { $options['uarid'] = $this->_getUserRatingGuid($topic_template->post->poster_id); } $rw = $this->EmbedRatingIfVisible($post_id, $topic_template->post->poster_id, strip_tags(bp_get_the_topic_post_content()), bp_get_the_topic_permalink() . '#post-' . $post_id, $rclass, false, $this->forum_align[$rclass]->hor, false, $options, false); // Attach rating html container. return $this->forum_align[$rclass]->ver == 'top' ? $rw . $content : $content . $rw; }
function ray_bp_oembed($content) { global $bp_oembed; // WP(MU) 2.9 oEmbed check if (!function_exists(wp_oembed_get)) { return $content; } // match URLs - could use some work // preg_match_all( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $content, $matches ); preg_match_all('`.*?((http|https)://[\\w#$&+,\\/:;=?@.-]+)[^\\w#$&+,\\/:;=?@.-]*?`i', $content, $matches); // debug regex // print_r($matches[0]); // if there are no links to parse, return $content now! if (empty($matches[0])) { return $content; } $whitelist = $bp_oembed['whitelist']; for ($i = 0; $i < count($matches[0]); $i++) { $url = $matches[0][$i]; // check url with whitelist, if url matches any whitelist item, skip from parsing foreach ($whitelist as $whitelist_item) { if (strpos($url, $whitelist_item) !== false) { continue 2; } } $cachekey = '_oembed_' . md5($url); // grab oEmbed cache depending on BP component // not pretty! only looking for activity updates or forum posts ATM if (!bp_get_activity_id() && bp_forums_is_installed_correctly()) { $cache = bb_get_postmeta(bp_get_the_topic_post_id(), $cachekey); } else { $cache = bp_activity_get_meta(bp_get_activity_id(), $cachekey); } // cache check - no oEmbed, but cached result, skip rest of loop if ($url === $cache) { continue; } // cache check - yes oEmbed if (!empty($cache)) { $replace = apply_filters('embed_oembed_html', $cache, $url, $attr); } else { // process url to oEmbed $oembed = wp_oembed_get($url); // returns true if link is oEmbed //$oembed = file_get_contents("http://autoembed.com/api/?url=".urlencode($url)); if ($oembed) { $replace = apply_filters('embed_oembed_html', $oembed, $url, $attr); $replace = str_replace(' ', '', $replace); // fix Viddler line break in <object> tag } else { $replace = $url; // unlike WP's oEmbed, I cache the URL if not oEmbed-dable! // the URL is more useful in the DB than a string called {{unknown}} ;) } // save oEmbed cache depending on BP component // the same "not prettiness!" if (!bp_get_activity_id() && bp_forums_is_installed_correctly()) { bb_update_postmeta(bp_get_the_topic_post_id(), $cachekey, $replace); } else { bp_activity_update_meta(bp_get_activity_id(), $cachekey, $replace); } } $content = str_replace($url, $replace, $content); } return $content; }