function DumpLog($pElement = false) { if (RWLogger::IsOn()) { echo "\n<!-- RATING-WIDGET LOG START\n\n"; RWLogger::Output(" "); echo "\n RATING-WIDGET LOG END-->\n"; } }
function rw_attach_rating_js($pElement = false) { if (RWLogger::IsOn()) { $params = func_get_args(); RWLogger::LogEnterence("rw_attach_rating_js", $params); } $rw_settings = array("blog-post" => array("options" => WP_RW__BLOG_POSTS_OPTIONS), "front-post" => array("options" => WP_RW__FRONT_POSTS_OPTIONS), "comment" => array("options" => WP_RW__COMMENTS_OPTIONS), "page" => array("options" => WP_RW__PAGES_OPTIONS), "activity-update" => array("options" => WP_RW__ACTIVITY_UPDATES_OPTIONS), "activity-comment" => array("options" => WP_RW__ACTIVITY_COMMENTS_OPTIONS), "new-forum-post" => array("options" => WP_RW__ACTIVITY_FORUM_POSTS_OPTIONS), "new-blog-post" => array("options" => WP_RW__ACTIVITY_BLOG_POSTS_OPTIONS), "new-blog-comment" => array("options" => WP_RW__ACTIVITY_BLOG_COMMENTS_OPTIONS), "forum-post" => array("options" => WP_RW__ACTIVITY_FORUM_POSTS_OPTIONS), "user" => array("options" => WP_RW__USERS_OPTIONS), "user-post" => array("options" => WP_RW__USERS_POSTS_OPTIONS), "user-page" => array("options" => WP_RW__USERS_PAGES_OPTIONS), "user-comment" => array("options" => WP_RW__USERS_COMMENTS_OPTIONS), "user-activity-update" => array("options" => WP_RW__USERS_ACTIVITY_UPDATES_OPTIONS), "user-activity-comment" => array("options" => WP_RW__USERS_ACTIVITY_COMMENTS_OPTIONS), "user-forum-post" => array("options" => WP_RW__USERS_FORUM_POSTS_OPTIONS)); $attach_js = false; $is_logged = is_user_logged_in(); if (is_array(self::$ratings) && count(self::$ratings) > 0) { foreach (self::$ratings as $urid => $data) { $rclass = $data["rclass"]; if (isset($rw_settings[$rclass]) && !isset($rw_settings[$rclass]["enabled"])) { $rw_settings[$rclass]["enabled"] = true; // Get rating front posts settings. $rw_settings[$rclass]["options"] = $this->_getOption($rw_settings[$rclass]["options"]); if (WP_RW__AVAILABILITY_DISABLED === $this->rw_validate_availability($rclass)) { // Disable ratings (set them to be readOnly). $options_obj = json_decode($rw_settings[$rclass]["options"]); $options_obj->readOnly = true; $rw_settings[$rclass]["options"] = json_encode($options_obj); } $attach_js = true; } } } if ($attach_js || self::$TOP_RATED_WIDGET_LOADED) { ?> <div class="rw-js-container"> <script type="text/javascript"> // Initialize ratings. function RW_Async_Init(){ RW.init({<?php // User key (uid). echo 'uid: "' . WP_RW__USER_KEY . '"'; $user = wp_get_current_user(); if ($user->id !== 0) { // User logged-in. $vid = $user->id; // Set voter id to logged user id. echo ", vid: {$vid}"; } if (false !== WP_RW__USER_SECRET) { // Secure connection. $timestamp = time(); $token = self::GenerateToken($timestamp); echo ', token: {timestamp: ' . $timestamp . ', token: "' . $token . '"}'; } ?> }); <?php foreach ($rw_settings as $rclass => $options) { if (isset($rw_settings[$rclass]["enabled"]) && true === $rw_settings[$rclass]["enabled"]) { if (!empty($rw_settings[$rclass]["options"])) { echo 'RW.initClass("' . $rclass . '", ' . $rw_settings[$rclass]["options"] . ');'; } } } foreach (self::$ratings as $urid => $data) { echo 'RW.initRating("' . $urid . '", {title: "' . esc_js($data["title"]) . '", url: "' . esc_js($data["permalink"]) . '"});'; } ?> RW.render(null, <?php echo !self::$TOP_RATED_WIDGET_LOADED ? "true" : "false"; ?> ); } RW_Advanced_Options = { blockFlash: !(<?php echo $this->_getOption(WP_RW__FLASH_DEPENDENCY); ?> ) }; // Append RW JS lib. if (typeof(RW) == "undefined"){ (function(){ var rw = document.createElement("script"); rw.type = "text/javascript"; rw.async = true; rw.src = "<?php echo WP_RW__ADDRESS_JS; ?> external<?php if (!defined("WP_RW__DEBUG")) { echo ".min"; } ?> .js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(rw, s); })(); } </script> </div> <?php } if (RWLogger::IsOn()) { echo "\n<!-- RATING-WIDGET LOG START\n\n"; RWLogger::Output(" "); echo "\n RATING-WIDGET LOG END-->\n"; } }