_getOption("WP_RW__LOGGER")) { // Start logger. RWLogger::PowerOn(); } // Load user key. $this->load_user_key(); if (RWLogger::IsOn()){ RWLogger::Log("version", WP_RW__VERSION); } if (false !== WP_RW__USER_KEY) { // Posts/Pages/Comments add_action("loop_start", array(&$this, "rw_before_loop_start")); // BodyPress extension. if (WP_RW__BP_INSTALLED) { // Activity page. add_action("bp_has_activities", array(&$this, "rw_before_activity_loop")); } // Rating-Widget main javascript load. add_action('wp_footer', array(&$this, "rw_attach_rating_js")); } add_action('admin_head', array(&$this, "rw_admin_menu_icon_css")); add_action( 'admin_menu', array(&$this, 'admin_menu')); require_once(WP_RW__PLUGIN_DIR . "/languages/dir.php"); $this->languages = $rw_languages; $this->languages_short = array_keys($this->languages); // Register CSS stylesheets. wp_register_style('rw', WP_RW__ADDRESS_CSS . "settings.css", array(), WP_RW__VERSION); wp_register_style('rw_wp_settings', WP_RW__ADDRESS_CSS . "wordpress/settings.css", array(), WP_RW__VERSION); wp_register_style('rw_wp_reports', WP_RW__ADDRESS_CSS . "wordpress/reports.css", array(), WP_RW__VERSION); wp_register_style('rw_cp', WP_RW__ADDRESS_CSS . "colorpicker.css", array(), WP_RW__VERSION); // Register JS. wp_register_script('rw', WP_RW__ADDRESS_JS . "index.php", array(), WP_RW__VERSION); wp_register_script('rw_wp', WP_RW__ADDRESS_JS . "wordpress/settings.js", array(), WP_RW__VERSION); wp_register_script('rw_cp', WP_RW__ADDRESS_JS . "vendors/colorpicker.js", array(), WP_RW__VERSION); wp_register_script('rw_cp_eye', WP_RW__ADDRESS_JS . "vendors/eye.js", array(), WP_RW__VERSION); wp_register_script('rw_cp_utils', WP_RW__ADDRESS_JS . "vendors/utils.js", array(), WP_RW__VERSION); // Register and Enqueue jQuery. wp_enqueue_script('jquery'); } /* Private -------------------------------------------------*/ private static function Urid2Id($pUrid, $pSubLength = 1, $pSubValue = 1) { return round((double)substr($pUrid, 0, strlen($pUrid) - $pSubLength) - $pSubValue); } private function _getPostRatingGuid($id = false) { if (false === $id){ $id = get_the_ID(); } $urid = ($id + 1) . "0"; if (RWLogger::IsOn()){ RWLogger::Log("post-id", $id); RWLogger::Log("post-urid", $urid); } return $urid; } public static function Urid2PostId($pUrid) { return self::Urid2Id($pUrid); } private function _getCommentRatingGuid($id = false) { if (false === $id){ $id = get_comment_ID(); } $urid = ($id + 1) . "1"; if (RWLogger::IsOn()){ RWLogger::Log("comment-id", $id); RWLogger::Log("comment-urid", $urid); } return $urid; } public static function Urid2CommentId($pUrid) { return self::Urid2Id($pUrid); } private function _getActivityRatingGuid($id = false) { if (false === $id){ $id = bp_get_activity_id(); } $urid = ($id + 1) . "2"; if (RWLogger::IsOn()){ RWLogger::Log("activity-id", $id); RWLogger::Log("activity-urid", $urid); } return $urid; } private function _getForumPostRatingGuid($id = false) { if (false === $id){ $id = bp_get_the_topic_post_id(); } $urid = ($id + 1) . "3"; if (RWLogger::IsOn()){ RWLogger::Log("forum-post-id", $id); RWLogger::Log("forum-post-urid", $urid); } return $urid; } private function _getUserRatingGuid($secondery_id = WP_RW__USER_SECONDERY_ID, $id = false) { if (false === $id){ $id = bp_displayed_user_id(); } $len = strlen($secondery_id); $secondery_id = ($len == 0) ? WP_RW__USER_SECONDERY_ID : (($len == 1) ? "0" . $secondery_id : substr($secondery_id, 0, 2)); $urid = ($id + 1) . $secondery_id . "4"; if (RWLogger::IsOn()){ RWLogger::Log("user-id", $id); RWLogger::Log("user-secondery-id", $secondery_id); RWLogger::Log("user-urid", $urid); } return $urid; } private static $OPTIONS_DEFAULTS = array( WP_RW__FRONT_POSTS_ALIGN => '{"ver": "top", "hor": "left"}', WP_RW__FRONT_POSTS_OPTIONS => '{"type": "star", "theme": "star_yellow1"}', WP_RW__BLOG_POSTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__BLOG_POSTS_OPTIONS => '{"type": "star", "theme": "star_yellow1"}', WP_RW__COMMENTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__COMMENTS_OPTIONS => '{"type": "nero", "theme": "thumbs_1"}', WP_RW__PAGES_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__PAGES_OPTIONS => '{"type": "star", "theme": "star_yellow1"}', // BuddyPress WP_RW__ACTIVITY_BLOG_POSTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__ACTIVITY_BLOG_POSTS_OPTIONS => '{"type": "star", "theme": "star_gray1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 1px 2px 0px 2px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', WP_RW__ACTIVITY_BLOG_COMMENTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__ACTIVITY_BLOG_COMMENTS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', WP_RW__ACTIVITY_UPDATES_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__ACTIVITY_UPDATES_OPTIONS => '{"type": "star", "theme": "star_gray1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 1px 2px 0px 2px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', WP_RW__ACTIVITY_COMMENTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__ACTIVITY_COMMENTS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // bbPress /*WP_RW__FORUM_TOPICS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__FORUM_TOPICS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}',*/ WP_RW__FORUM_POSTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__FORUM_POSTS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', /*WP_RW__ACTIVITY_FORUM_TOPICS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__ACTIVITY_FORUM_TOPICS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}',*/ WP_RW__ACTIVITY_FORUM_POSTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__ACTIVITY_FORUM_POSTS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // User WP_RW__USERS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__USERS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // Posts WP_RW__USERS_POSTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__USERS_POSTS_OPTIONS => '{"type": "star", "theme": "star_gray1", "readOnly": true, "advanced": {"css": {"container": "background: #F4F4F4; padding: 1px 2px 0px 2px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // Pages WP_RW__USERS_PAGES_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__USERS_PAGES_OPTIONS => '{"type": "star", "theme": "star_gray1", "readOnly": true, "advanced": {"css": {"container": "background: #F4F4F4; padding: 1px 2px 0px 2px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // Comments WP_RW__USERS_COMMENTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__USERS_COMMENTS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "readOnly": true, "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // Activity-Updates WP_RW__USERS_ACTIVITY_UPDATES_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__USERS_ACTIVITY_UPDATES_OPTIONS => '{"type": "star", "theme": "star_gray1", "readOnly": true, "advanced": {"css": {"container": "background: #F4F4F4; padding: 1px 2px 0px 2px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // Avtivity-Comments WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__USERS_ACTIVITY_COMMENTS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "readOnly": true, "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', // Forum-Posts WP_RW__USERS_FORUM_POSTS_ALIGN => '{"ver": "bottom", "hor": "left"}', WP_RW__USERS_FORUM_POSTS_OPTIONS => '{"type": "nero", "theme": "thumbs_bp1", "readOnly": true, "advanced": {"css": {"container": "background: #F4F4F4; padding: 4px 8px 1px 8px; margin-bottom: 2px; border-right: 1px solid #DDD; border-bottom: 1px solid #DDD; border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px;"}}}', WP_RW__VISIBILITY_SETTINGS => "{}", WP_RW__AVAILABILITY_SETTINGS => '{"activity-update": 1, "activity-comment": 1, "forum-post": 1, "new-forum-post": 1, "user": 1, "user-post": 1, "user-comment": 1, "user-page": 1, "user-activity-update": 1, "user-activity-comment": 1, "user-forum-post": 1}', // By default, disable all activity ratings for un-logged users. WP_RW__SHOW_ON_EXCERPT => '{"front-post": false, "blog-post": false, "page": false}', WP_RW__FLASH_DEPENDENCY => "true", WP_RW__LOGGER => false, ); private static $OPTIONS_CACHE = array(); public static function _getOption($pOption, $pFlush = false) { if ($pFlush || !isset(self::$OPTIONS_CACHE[$pOption])) { $default = isset(self::$OPTIONS_DEFAULTS[$pOption]) ? self::$OPTIONS_DEFAULTS[$pOption] : false; self::$OPTIONS_CACHE[$pOption] = get_option($pOption, $default); } return self::$OPTIONS_CACHE[$pOption]; } private function _setOption($pOption, $pValue) { if (!isset(self::$OPTIONS_CACHE[$pOption]) || $pValue != self::$OPTIONS_CACHE[$pOption]) { // Update option. update_option($pOption, $pValue); // Update cache. self::$OPTIONS_CACHE[$pOption] = $pValue; } } private function _deleteOption($pOption) { delete_option($pOption); if (isset(self::$OPTIONS_DEFAULTS[$pOption])){ self::$OPTIONS_CACHE[$pOption] = self::$OPTIONS_DEFAULTS[$pOption]; }else{ unset(self::$OPTIONS_CACHE[$pOption]); } } public static function RemoteCall($pPage, $pData) { if (function_exists('wp_remote_post')) // WP 2.7+ { $rw_ret_obj = wp_remote_post(WP_RW__ADDRESS . "/{$pPage}", array('body' => $pData)); if (is_wp_error($rw_ret_obj)) { self::$errors = $rw_ret_obj; return false; } $rw_ret_obj = wp_remote_retrieve_body($rw_ret_obj); } else { $fp = fsockopen( WP_RW__DOMAIN, 80, $err_num, $err_str, 3 ); if (!$fp){ self::$errors->add('connect', __("Can't connect to Rating-Widget.com", WP_RW__ID)); return false; } if (function_exists('stream_set_timeout')){ stream_set_timeout($fp, 3); } global $wp_version; $request_body = http_build_query($pData, null, '&'); $request = "POST {$pPage} HTTP/1.0\r\n"; $request .= "Host: " . WP_RW__DOMAIN . "\r\n"; $request .= "User-agent: WordPress/$wp_version\r\n"; $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n"; $request .= 'Content-Length: ' . strlen($request_body) . "\r\n"; fwrite($fp, "$request\r\n$request_body"); $response = ''; while (!feof($fp)){ $response .= fread($fp, 4096); } fclose($fp); list($headers, $rw_ret_obj) = explode("\r\n\r\n", $response, 2); } return $rw_ret_obj; } public static function QueueRatingData($urid, $title, $permalink, $rclass) { $title_short = (mb_strlen($title) > 256) ? trim(mb_substr($title, 0, 256)) . '...' : $title; $permalink = (mb_strlen($permalink) > 512) ? trim(mb_substr($permalink, 0, 512)) . '...' : $permalink; self::$ratings[$urid] = array("title" => $title, "permalink" => $permalink, "rclass" => $rclass); } private function load_user_key() { if (!defined('WP_RW__USER_KEY')) { $user_key = $this->_getOption("rw_user_key"); if (strlen($user_key) !== 32){ $user_key = false; } define('WP_RW__USER_KEY', $user_key); } if (!defined('WP_RW__USER_SECRET')) { $user_secret = $this->_getOption("rw_user_secret"); if (strlen($user_secret) !== 32){ $user_secret = false; } define('WP_RW__USER_SECRET', $user_secret); } } private function _printErrors() { if (!$error_codes = self::$errors->get_error_codes()){ return; } ?>
get_error_messages($error_code) as $error_message) : ?>

get_error_data($error_code) ? $error_message : esc_html($error_message); ?>


is_admin = (bool)current_user_can('manage_options'); if (!$this->is_admin){ return; } // Enqueue styles. wp_enqueue_style('rw'); wp_enqueue_style('rw_wp_settings'); wp_enqueue_style('rw_cp'); // Enqueue scripts. wp_enqueue_script('json2'); wp_enqueue_script('rw_cp'); wp_enqueue_script('rw_cp_eye'); wp_enqueue_script('rw_cp_utils'); wp_enqueue_script('rw_wp'); wp_enqueue_script('rw'); if (false === WP_RW__USER_KEY){ add_options_page(__('Rating-Widget Settings', WP_RW__ID), __('Ratings', WP_RW__ID), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_user_key_page')); if ( function_exists('add_object_page') ){ // WP 2.7+ $hook = add_object_page(__('Rating-Widget Settings', WP_RW__ID), __('Ratings', WP_RW__ID), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_user_key_page'), WP_RW__PLUGIN_URL . "icon.png" ); }else{ $hook = add_management_page(__('Rating-Widget Settings', WP_RW__ID), __('Ratings', WP_RW__ID), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_user_key_page') ); } add_action("load-$hook", array( &$this, 'rw_user_key_page_load')); if ((empty($_GET['page']) || WP_RW__ADMIN_MENU_SLUG != $_GET['page'])){ add_action( 'admin_notices', create_function( '', 'echo "

" . sprintf( "You need to input your Rating-Widget.com account details.", "edit.php?page=' . WP_RW__ADMIN_MENU_SLUG . '" ) . "

";' ) ); } return; } add_options_page(__('Rating-Widget Settings', WP_RW__ID), __('Ratings', WP_RW__ID), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_settings_page')); // add_menu_page(__('Rating-Widget Settings', WP_RW__ID), __('Ratings', WP_RW__ID), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_settings_page'), WP_RW__PLUGIN_URL . "icon.png"); if ( function_exists('add_object_page') ){ // WP 2.7+ $hook = add_object_page(__('Rating-Widget Settings', WP_RW__ID), __('Ratings', WP_RW__ID), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_settings_page'), WP_RW__PLUGIN_URL . "icon.png" ); }else{ $hook = add_management_page(__( 'Rating-Widget Settings', WP_RW__ID ), __( 'Ratings', WP_RW__ID ), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_settings_page') ); } add_action("load-$hook", array( &$this, 'rw_settings_page_load')); if ($this->is_admin) { add_submenu_page(WP_RW__ADMIN_MENU_SLUG, __( 'Ratings – Basic', WP_RW__ID ), __('Basic', WP_RW__ID ), 'edit_posts', WP_RW__ADMIN_MENU_SLUG, array(&$this, 'rw_settings_page')); if (WP_RW__BP_INSTALLED){ add_submenu_page(WP_RW__ADMIN_MENU_SLUG, __( 'Ratings – BuddyPress', WP_RW__ID ), __('BuddyPress', WP_RW__ID ), 'edit_posts', WP_RW__ADMIN_MENU_SLUG . '&action=buddypress', array(&$this, 'rw_settings_page')); } $user_label = (WP_RW__BP_INSTALLED) ? "User" : "Author"; add_submenu_page(WP_RW__ADMIN_MENU_SLUG, __( 'Ratings – Advanced', WP_RW__ID ), __('Advanced', WP_RW__ID ), 'edit_posts', WP_RW__ADMIN_MENU_SLUG . '&action=advanced', array(&$this, 'rw_settings_page')); } } function rw_user_key_page_load() { if ('post' != strtolower($_SERVER['REQUEST_METHOD']) || empty($_POST['action']) || 'account' != $_POST['action']) { return false; } // Get reCAPTCHA inputs. $recaptcha_challenge = $_POST['recaptcha_challenge_field']; $recaptcha_response = $_POST['recaptcha_response_field']; $details = array( 'title' => urlencode(get_option('blogname', "")), 'email' => urlencode(get_option('admin_email', "")), 'domain' => urlencode(get_option('siteurl', "")), 'challenge' => $recaptcha_challenge, 'response' => $recaptcha_response, ); $rw_ret_obj = self::RemoteCall("action/user.php", $details); if (false === $rw_ret_obj){ return false; } // Decode RW ret object. $rw_ret_obj = json_decode($rw_ret_obj); if (false == $rw_ret_obj->success) { self::$errors->add('rating_widget_captcha', __($rw_ret_obj->msg, WP_RW__ID)); return false; } $rw_user_key = $rw_ret_obj->data[0]->uid; $this->_setOption("rw_user_key", $rw_user_key); define("WP_RW__USER_KEY", $rw_user_key); return true; } function rw_user_key_page($flush = false) { if (false === $flush && false !== WP_RW__USER_KEY) { $this->rw_settings_page(); return; } $this->_printErrors(); ?>

Rating-Widget.com unique user-key.', WP_RW__ID), WP_RW__ADDRESS); echo "

"; _e('In order to get your user-key, please fill the CAPTCHA below and click on the "Verify CAPTCHA" button.', WP_RW__ID) ?>

0 && $pQuery[$pos - 1] === "&"){ $pos--; } return substr($pQuery, 0, $pos) . substr($pQuery, $cur); } public static function _isValidPCId($pPCId) { // Length check. if (strlen($pPCId) !== 36){ return false; } if ($pPCId[8] != "-" || $pPCId[13] != "-" || $pPCId[18] != "-" || $pPCId[23] != "-") { return false; } for ($i = 0; $i < 36; $i++) { if ($i == 8 || $i == 13 || $i == 18 || $i == 23){ $i++; } $code = ord($pPCId[$i]); if ($code < 48 || $code > 70 || ($code > 57 && $code < 65)) { return false; } } return true; } /* Advanced Settings ---------------------------------------------------------------------------------------------------------------*/ function rw_advanced_settings_page() { // Variables for the field and option names $rw_form_hidden_field_name = "rw_form_hidden_field_name"; // Get flash dependency. $rw_flash_dependency = $this->_getOption(WP_RW__FLASH_DEPENDENCY); if (isset($_POST[$rw_form_hidden_field_name]) && $_POST[$rw_form_hidden_field_name] == 'Y') { $rw_restore_defaults = (isset($_POST["rw_restore_defaults"]) && in_array($_POST["rw_restore_defaults"], array("true", "false"))) ? $_POST["rw_restore_defaults"] : "false"; $rw_delete_history = (isset($_POST["rw_delete_history"]) && in_array($_POST["rw_delete_history"], array("true", "false"))) ? $_POST["rw_delete_history"] : "false"; if ("true" === $rw_restore_defaults) { // Restore to defaults - delete all settings. $this->_deleteOption(WP_RW__ACTIVITY_COMMENTS_ALIGN); $this->_deleteOption(WP_RW__ACTIVITY_COMMENTS_OPTIONS); $this->_deleteOption(WP_RW__ACTIVITY_UPDATES_ALIGN); $this->_deleteOption(WP_RW__ACTIVITY_UPDATES_OPTIONS); $this->_deleteOption(WP_RW__AVAILABILITY_SETTINGS); $this->_deleteOption(WP_RW__USERS_ALIGN); $this->_deleteOption(WP_RW__USERS_OPTIONS); $this->_deleteOption(WP_RW__USERS_POSTS_ALIGN); $this->_deleteOption(WP_RW__USERS_POSTS_OPTIONS); $this->_deleteOption(WP_RW__USERS_PAGES_ALIGN); $this->_deleteOption(WP_RW__USERS_PAGES_OPTIONS); $this->_deleteOption(WP_RW__USERS_COMMENTS_ALIGN); $this->_deleteOption(WP_RW__USERS_COMMENTS_OPTIONS); $this->_deleteOption(WP_RW__USERS_ACTIVITY_UPDATES_ALIGN); $this->_deleteOption(WP_RW__USERS_ACTIVITY_UPDATES_OPTIONS); $this->_deleteOption(WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN); $this->_deleteOption(WP_RW__USERS_ACTIVITY_COMMENTS_OPTIONS); $this->_deleteOption(WP_RW__USERS_FORUM_POSTS_ALIGN); $this->_deleteOption(WP_RW__USERS_FORUM_POSTS_OPTIONS); $this->_deleteOption(WP_RW__ACTIVITY_BLOG_POSTS_ALIGN); $this->_deleteOption(WP_RW__ACTIVITY_BLOG_POSTS_OPTIONS); $this->_deleteOption(WP_RW__ACTIVITY_BLOG_COMMENTS_ALIGN); $this->_deleteOption(WP_RW__ACTIVITY_BLOG_COMMENTS_OPTIONS); $this->_deleteOption(WP_RW__ACTIVITY_FORUM_POSTS_ALIGN); $this->_deleteOption(WP_RW__ACTIVITY_FORUM_POSTS_OPTIONS); /*$this->_deleteOption(WP_RW__ACTIVITY_FORUM_TOPICS_ALIGN); $this->_deleteOption(WP_RW__ACTIVITY_FORUM_TOPICS_OPTIONS);*/ $this->_deleteOption(WP_RW__FORUM_POSTS_ALIGN); $this->_deleteOption(WP_RW__FORUM_POSTS_OPTIONS); /*$this->_deleteOption(WP_RW__FORUM_TOPICS_ALIGN); $this->_deleteOption(WP_RW__FORUM_TOPICS_OPTIONS);*/ $this->_deleteOption(WP_RW__BLOG_POSTS_ALIGN); $this->_deleteOption(WP_RW__BLOG_POSTS_OPTIONS); $this->_deleteOption(WP_RW__COMMENTS_ALIGN); $this->_deleteOption(WP_RW__COMMENTS_OPTIONS); $this->_deleteOption(WP_RW__FLASH_DEPENDENCY); $this->_deleteOption(WP_RW__FRONT_POSTS_ALIGN); $this->_deleteOption(WP_RW__FRONT_POSTS_OPTIONS); $this->_deleteOption(WP_RW__PAGES_ALIGN); $this->_deleteOption(WP_RW__PAGES_OPTIONS); $this->_deleteOption(WP_RW__SHOW_ON_EXCERPT); $this->_deleteOption(WP_RW__VISIBILITY_SETTINGS); // Re-Load all advanced settings. // Flash dependency. $rw_flash_dependency = $this->_getOption(WP_RW__FLASH_DEPENDENCY); } else if ("true" === $rw_delete_history) { // Delete user-key & secret. global $wpdb; $ret = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name = 'rw_user_key' OR option_name = 'rw_user_secret'"); // Goto user-key creation page. $this->rw_user_key_page(true); return; } else { // Save advanced settings. // Get posted flash dependency. if (isset($_POST["rw_flash_dependency"]) && in_array($_POST["rw_flash_dependency"], array("true", "false")) && $_POST["rw_flash_dependency"] != $rw_flash_dependency) { $rw_flash_dependency = $_POST["rw_flash_dependency"]; // Save flash dependency. $this->_setOption(WP_RW__FLASH_DEPENDENCY, $rw_flash_dependency); } } ?>


Flash Dependency

"> > Enable Flash dependency (track computers using LSO).
"> > Disable Flash dependency (computers with identical IPs won't be distinguished).
Flash dependency don't means that if a user don't have a flash player installed on his browser then it will stuck. The reason to disable flash is for users which have flash blocking add-ons (e.g. FF Flashblock add-on), which is quite rare.

Critical Actions

Restore all Rating-Widget settings to factory.
Delete your unique-user-key and generate new one.
Notice: All your ratings data will be deleted.
rw_advanced_settings_page(); return; } // Variables for the field and option names $rw_form_hidden_field_name = "rw_form_hidden_field_name"; if (($action === "buddypress" && WP_RW__BP_INSTALLED) && is_plugin_active(WP_RW__BP_CORE_FILE)) { $settings_data = array( "activity-blog-posts" => array( "tab" => "Activity Blog Posts", "class" => "new-blog-post", "options" => WP_RW__ACTIVITY_BLOG_POSTS_OPTIONS, "align" => WP_RW__ACTIVITY_BLOG_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__ACTIVITY_BLOG_POSTS_ALIGN], "excerpt" => false, "show_align" => true, ), "activity-blog-comments" => array( "tab" => "Activity Blog Comments", "class" => "new-blog-comment", "options" => WP_RW__ACTIVITY_BLOG_COMMENTS_OPTIONS, "align" => WP_RW__ACTIVITY_BLOG_COMMENTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__ACTIVITY_BLOG_COMMENTS_ALIGN], "excerpt" => false, "show_align" => true, ), "activity-updates" => array( "tab" => "Activity Updates", "class" => "activity-update", "options" => WP_RW__ACTIVITY_UPDATES_OPTIONS, "align" => WP_RW__ACTIVITY_UPDATES_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__ACTIVITY_UPDATES_ALIGN], "excerpt" => false, "show_align" => true, ), "activity-comments" => array( "tab" => "Activity Comments", "class" => "activity-comment", "options" => WP_RW__ACTIVITY_COMMENTS_OPTIONS, "align" => WP_RW__ACTIVITY_COMMENTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__ACTIVITY_COMMENTS_ALIGN], "excerpt" => false, "show_align" => true, ), ); $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "activity-blog-posts"; if (!isset($settings_data[$selected_key])){ $selected_key = "activity-blog-posts"; } } else { $settings_data = array( "blog-posts" => array( "tab" => "Blog Posts", "class" => "blog-post", "options" => WP_RW__BLOG_POSTS_OPTIONS, "align" => WP_RW__BLOG_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__BLOG_POSTS_ALIGN], "excerpt" => true, "show_align" => true, ), "front-posts" => array( "tab" => "Front Page Posts", "class" => "front-post", "options" => WP_RW__FRONT_POSTS_OPTIONS, "align" => WP_RW__FRONT_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__FRONT_POSTS_ALIGN], "excerpt" => true, "show_align" => true, ), "comments" => array( "tab" => "Comments", "class" => "comment", "options" => WP_RW__COMMENTS_OPTIONS, "align" => WP_RW__COMMENTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__COMMENTS_ALIGN], "excerpt" => false, "show_align" => true, ), "pages" => array( "tab" => "Pages", "class" => "page", "options" => WP_RW__PAGES_OPTIONS, "align" => WP_RW__PAGES_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__PAGES_ALIGN], "excerpt" => true, "show_align" => true, ), ); $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "blog-posts"; if (!isset($settings_data[$selected_key])){ $selected_key = "blog-posts"; } } $rw_current_settings = $settings_data[$selected_key]; // Show on excerpts list must be loaded anyway. $this->show_on_excerpts_list = json_decode($this->_getOption(WP_RW__SHOW_ON_EXCERPT)); // Visibility list must be loaded anyway. $this->visibility_list = json_decode($this->_getOption(WP_RW__VISIBILITY_SETTINGS)); // Availability list must be loaded anyway. $this->availability_list = json_decode($this->_getOption(WP_RW__AVAILABILITY_SETTINGS)); // Some alias. $rw_class = $rw_current_settings["class"]; // See if the user has posted us some information // If they did, this hidden field will be set to 'Y' if (isset($_POST[$rw_form_hidden_field_name]) && $_POST[$rw_form_hidden_field_name] == 'Y') { /* Widget align options. ---------------------------------------------------------------------------------------------------------------*/ $rw_show_rating = isset($_POST["rw_show"]) ? true : false; $rw_align_str = (!$rw_show_rating) ? "{}" : $rw_current_settings["default_align"]; if ($rw_show_rating && isset($_POST["rw_align"])) { $align = explode(" ", $_POST["rw_align"]); if (is_array($align) && count($align) == 2) { if (in_array($align[0], array("top", "bottom")) && in_array($align[1], array("left", "center", "right"))) { $rw_align_str = '{"ver": "' . $align[0] . '", "hor": "' . $align[1] . '"}'; } } } $this->_setOption($rw_current_settings["align"], $rw_align_str); /* Show on excerpts. ---------------------------------------------------------------------------------------------------------------*/ $rw_show_on_excerpts = false; if ($rw_current_settings["excerpt"] === true) { $rw_show_on_excerpts = isset($_POST["rw_show_excerpt"]) ? true : false; $this->show_on_excerpts_list->{$rw_class} = $rw_show_on_excerpts; $this->_setOption(WP_RW__SHOW_ON_EXCERPT, json_encode($this->show_on_excerpts_list)); } /* Rating-Widget options. ---------------------------------------------------------------------------------------------------------------*/ $rw_options_str = preg_replace('/\%u([0-9A-F]{4})/i', '\\u$1', urldecode($_POST["rw_options"])); if (null !== json_decode($rw_options_str)){ $this->_setOption($rw_current_settings["options"], $rw_options_str); } /* Availability settings. ---------------------------------------------------------------------------------------------------------------*/ $rw_availability = isset($_POST["rw_availability"]) ? max(0, min(2, (int)$_POST["rw_availability"])) : 0; $this->availability_list->{$rw_class} = $rw_availability; $this->_setOption(WP_RW__AVAILABILITY_SETTINGS, json_encode($this->availability_list)); /* Visibility settings ---------------------------------------------------------------------------------------------------------------*/ $rw_visibility = isset($_POST["rw_visibility"]) ? max(0, min(2, (int)$_POST["rw_visibility"])) : 0; $rw_visibility_exclude = isset($_POST["rw_visibility_exclude"]) ? $_POST["rw_visibility_exclude"] : ""; $rw_visibility_include = isset($_POST["rw_visibility_include"]) ? $_POST["rw_visibility_include"] : ""; $this->visibility_list->{$rw_class}->selected = $rw_visibility; $this->visibility_list->{$rw_class}->exclude = $rw_visibility_exclude; $this->visibility_list->{$rw_class}->include = $rw_visibility_include; $this->_setOption(WP_RW__VISIBILITY_SETTINGS, json_encode($this->visibility_list)); ?>

_getOption($rw_current_settings["align"]); /* Get show on excerpts option. ---------------------------------------------------------------------------------------------------------------*/ // Already loaded. /* Get rating options. ---------------------------------------------------------------------------------------------------------------*/ $rw_options_str = $this->_getOption($rw_current_settings["options"]); /* Get availability settings. ---------------------------------------------------------------------------------------------------------------*/ // Already loaded. /* Get visibility settings ---------------------------------------------------------------------------------------------------------------*/ // Already loaded. } $rw_align = json_decode($rw_align_str); $rw_options = json_decode($rw_options_str); $rw_language_str = isset($rw_options->lng) ? $rw_options->lng : WP_RW__DEFAULT_LNG; if (!isset($this->visibility_list->{$rw_class})) { $this->visibility_list->{$rw_class} = new stdClass(); $this->visibility_list->{$rw_class}->selected = 0; $this->visibility_list->{$rw_class}->exclude = ""; $this->visibility_list->{$rw_class}->include = ""; } $rw_visibility_settings = $this->visibility_list->{$rw_class}; if (!isset($this->availability_list->{$rw_class})){ $this->availability_list->{$rw_class} = 0; } $rw_availability_settings = $this->availability_list->{$rw_class}; if (!isset($this->show_on_excerpts_list->{$rw_class})){ $this->show_on_excerpts_list->{$rw_class} = true; } $rw_show_on_excerpts = $this->show_on_excerpts_list->{$rw_class}; require_once(WP_RW__PLUGIN_DIR . "/languages/{$rw_language_str}.php"); require_once(WP_RW__PLUGIN_DIR . "/lib/defaults.php"); require_once(WP_RW__PLUGIN_DIR . "/lib/def_settings.php"); /*$rw_options_type = isset($rw_options->type) ? $rw_options->type : "star"; if ($rw_options_type == "nero"){ unset($rw_options->type); $rw_options_str = json_encode($rw_options); $rw_options->type = "nero"; }*/ global $DEFAULT_OPTIONS; rw_set_language_options($DEFAULT_OPTIONS, $dictionary, $dir, $hor); $rating_font_size_set = false; $rating_line_height_set = false; $theme_font_size_set = false; $theme_line_height_set = false; $rating_font_size_set = (isset($rw_options->advanced) && isset($rw_options->advanced->font) && isset($rw_options->advanced->font->size)); $rating_line_height_set = (isset($rw_options->advanced) && isset($rw_options->advanced->layout) && isset($rw_options->advanced->layout->lineHeight)); $def_options = $DEFAULT_OPTIONS; if (isset($rw_options->theme) && $rw_options->theme !== "") { require(WP_RW__PLUGIN_DIR . "/themes/dir.php"); if (!isset($rw_options->type)){ $rw_options->type = isset($rw_themes["star"][$rw_options->theme]) ? "star" : "nero"; } if (isset($rw_themes[$rw_options->type][$rw_options->theme])) { require(WP_RW__PLUGIN_DIR . "/themes/" . $rw_themes[$rw_options->type][$rw_options->theme]["file"]); $theme_font_size_set = (isset($theme["options"]->advanced) && isset($theme["options"]->advanced->font) && isset($theme["options"]->advanced->font->size)); $theme_line_height_set = (isset($theme["options"]->advanced) && isset($theme["options"]->advanced->layout) && isset($theme["options"]->advanced->layout->lineHeight)); // Enrich theme options with defaults. $def_options = rw_enrich_options1($theme["options"], $DEFAULT_OPTIONS); } } // Enrich rating options with calculated default options (with theme reference). $rw_options = rw_enrich_options1($rw_options, $def_options); // If font size and line height isn't explicitly specified on rating // options or rating's theme, updated theme correspondingly // to rating size. if (isset($rw_options->size)) { $SIZE = strtoupper($rw_options->size); if (!$rating_font_size_set && !$theme_font_size_set) { global $DEF_FONT_SIZE; if (!isset($rw_options->advanced)){ $rw_options->advanced = new stdClass(); } if (!isset($rw_options->advanced->font)){ $rw_options->advanced->font = new stdClass(); } $rw_options->advanced->font->size = $DEF_FONT_SIZE->$SIZE; } if (!$rating_line_height_set && !$theme_line_height_set) { global $DEF_LINE_HEIGHT; if (!isset($rw_options->advanced)){ $rw_options->advanced = new stdClass(); } if (!isset($rw_options->advanced->layout)){ $rw_options->advanced->layout = new stdClass(); } $rw_options->advanced->layout->lineHeight = $DEF_LINE_HEIGHT->$SIZE; } } $rw_enrich_options_str = json_encode($rw_options); $browser_info = array("browser" => "msie", "version" => "7.0"); $rw_languages = $this->languages; ?>

    $settings) { if ($settings_data[$key] == $rw_current_settings) { ?>
ver); ?>

ver && $hor == $rw_align->hor); } ?>
" />

_getOption(WP_RW__COMMENTS_ALIGN); $comment_align = json_decode($comment_align_str); $comment_enabled = (isset($comment_align) && isset($comment_align->hor)); if ($comment_enabled && WP_RW__AVAILABILITY_HIDDEN !== $this->rw_validate_availability("comment")) { $this->comment_align = $comment_align; // Hook comment rating showup. add_action('comment_text', array(&$this, "rw_display_comment_rating")); } if (is_page()) { // Get rating pages alignment. $post_align_str = $this->_getOption(WP_RW__PAGES_ALIGN); $post_class = "page"; } else if (is_home()) { // Get rating front posts alignment. $post_align_str = $this->_getOption(WP_RW__FRONT_POSTS_ALIGN); $post_class = "front-post"; } else { // Get rating blog posts alignment. $post_align_str = $this->_getOption(WP_RW__BLOG_POSTS_ALIGN); $post_class = "blog-post"; } $post_align = json_decode($post_align_str); $post_enabled = (isset($post_align) && isset($post_align->hor)); if ($post_enabled && WP_RW__AVAILABILITY_HIDDEN !== $this->rw_validate_availability($post_class)) { $this->post_align = $post_align; $this->post_class = $post_class; // Hook post rating showup. add_action('the_content', array(&$this, "rw_display_post_rating")); if (!isset($this->show_on_excerpts_list)){ $this->show_on_excerpts_list = json_decode($this->_getOption(WP_RW__SHOW_ON_EXCERPT)); } if ($this->show_on_excerpts_list->{$post_class} === true) { // Hook post excerpt rating showup. add_action('the_excerpt', array(&$this, "rw_display_post_rating")); } } } static function rw_ids_string_to_array(&$pIds) { $ids = explode(",", $pIds); $pIds = array(); foreach ($ids as $id) { $id = trim($id); if (is_numeric($id)){ $pIds[] = $id; } } $pIds = array_unique($pIds); } function rw_validate_visibility($pId, $pClass) { if (!isset($this->visibility_list)){ $this->visibility_list = json_decode($this->_getOption(WP_RW__VISIBILITY_SETTINGS)); } if (!isset($this->visibility_list->{$pClass})){ return true; } // Alias. $visibility = $this->visibility_list->{$pClass}; // All visible. if ($visibility->selected === 0){ return true; } if ($visibility->selected === 1 && !is_array($visibility->exclude)) { self::rw_ids_string_to_array($visibility->exclude); } else if ($visibility->selected === 2 && !is_array($visibility->include)) { self::rw_ids_string_to_array($visibility->include); } if (($visibility->selected === 1 && in_array($pId, $visibility->exclude)) || ($visibility->selected === 2 && !in_array($pId, $visibility->include))) { return false; } return true; } var $is_user_logged_in; function rw_validate_availability($pClass) { if (!isset($this->is_user_logged_in)) { // Check if user logged in for availability check. $this->is_user_logged_in = is_user_logged_in(); $this->availability_list = json_decode($this->_getOption(WP_RW__AVAILABILITY_SETTINGS)); } if (true === $this->is_user_logged_in || !isset($this->availability_list->{$pClass})) { return WP_RW__AVAILABILITY_ACTIVE; } return $this->availability_list->{$pClass}; } /** * If Rating-Widget enabled for Posts, attach it * html container to the post content at the right position. * * @param {string} $content */ function rw_display_post_rating($content) { if (RWLogger::IsOn()){ $params = func_get_args(); RWLogger::LogEnterence("rw_display_post_rating", $params); } global $post; // Checks if post isn't specificaly excluded. if (false === $this->rw_validate_visibility($post->ID, $this->post_class)){ return $content; } $urid = $this->_getPostRatingGuid(); self::QueueRatingData($urid, $post->post_title, get_permalink($post->ID), $this->post_class); $rw = '
'; return ($this->post_align->ver == "top") ? $rw . $content : $content . $rw; } /** * If Rating-Widget enabled for Comments, attach it * html container to the comment content at the right position. * * @param {string} $content */ function rw_display_comment_rating($content) { if (RWLogger::IsOn()){ $params = func_get_args(); RWLogger::LogEnterence("rw_display_comment_rating", $params); } global $post, $comment; if (false === $this->rw_validate_visibility($comment->comment_ID, "comment")){ return $content; } $urid = $this->_getCommentRatingGuid(); self::QueueRatingData($urid, strip_tags($comment->comment_content), get_permalink($post->ID) . '#comment-' . $comment->comment_ID, "comment"); $rw = '
'; return ($this->comment_align->ver == "top") ? $rw . $content : $content . $rw; } /* BuddyPress Support Actions ---------------------------------------------------------------------------------------------------------------*/ var $activity_align = array(); function rw_before_activity_loop($has_activities) { if (RWLogger::IsOn()){ $params = func_get_args(); RWLogger::LogEnterence("rw_before_activity_loop", $params); } if (!$has_activities){ return false; } $items = array( "activity-update" => array( "align_key" => WP_RW__ACTIVITY_UPDATES_ALIGN, "enabled" => false, ), "activity-comment" => array( "align_key" => WP_RW__ACTIVITY_COMMENTS_ALIGN, "enabled" => false, ), "new-blog-post" => array( "align_key" => WP_RW__ACTIVITY_BLOG_POSTS_ALIGN, "enabled" => false, ), "new-blog-comment" => array( "align_key" => WP_RW__ACTIVITY_BLOG_COMMENTS_ALIGN, "enabled" => false, ), ); $ver_top = false; $ver_bottom = false; foreach ($items as $key => &$item) { $align_str = self::_getOption($item["align_key"]); $align = json_decode($align_str); $item["enabled"] = (isset($align) && isset($align->hor)); if ($item["enabled"] && WP_RW__AVAILABILITY_HIDDEN !== $this->rw_validate_availability($key)) { $this->activity_align[$key] = $align; if ($align->ver === "top"){ $ver_top = true; }else{ $ver_bottom = true; } } } if ($ver_top){ // Hook activity TOP rating. add_filter("bp_get_activity_action", array(&$this, "rw_display_activity_rating_top")); } if ($ver_bottom){ // Hook activity BOTTOM rating. add_action("bp_activity_entry_meta", array(&$this, "rw_display_activity_rating_bottom")); } if (true === $items["activity-comment"]["enabled"]){ // Hook activity-comment rating showup. add_filter("bp_get_activity_content", array(&$this, "rw_display_activity_comment_rating")); } return true; } function rw_get_activity_rating($ver) { if (RWLogger::IsOn()){ $params = func_get_args(); RWLogger::LogEnterence("rw_get_activity_rating", $params); } global $activities_template; // Set current activity-comment to current activity update (recursive comments). $this->current_comment = $activities_template->activity; $rclass = str_replace("_", "-", $activities_template->activity->type); $is_forum_topic = false; if ($rclass === "new-forum-topic"){ $rclass = "new-forum-post"; $is_forum_topic = true; } if ($rclass == "new-forum-post"){ return false; } // Check if item rating is top positioned. if (!isset($this->activity_align[$rclass]) || $ver !== $this->activity_align[$rclass]->ver){ return false; } // Get item id. $item_id = ("activity-update" === $rclass || "activity-comment" === $rclass) ? $activities_template->activity->id : $activities_template->activity->secondary_item_id; // Validate that item isn't explicitly excluded. if (false === $this->rw_validate_visibility($item_id, $rclass)){ return false; } switch ($rclass) { case "activity-update": case "activity-comment": // Get activity rating user-rating-id. $urid = $this->_getActivityRatingGuid($item_id); break; case "new-blog-post": // Get activity rating user-rating-id. $urid = $this->_getPostRatingGuid($item_id); break; case "new-blog-comment": // Get activity rating user-rating-id. $urid = $this->_getCommentRatingGuid($item_id); break; } // If the item is post, queue rating with post title. $title = ("new-blog-post" === $rclass) ? get_the_title($item_id) : $activities_template->activity->content; // Queue activity rating. self::QueueRatingData($urid, strip_tags($title), bp_activity_get_permalink($activities_template->activity->id), $rclass); // Return rating html container. return '
'; } // Activity item top rating. function rw_display_activity_rating_top($action) { if (RWLogger::IsOn()){ $params = func_get_args(); RWLogger::LogEnterence("rw_display_activity_rating_top", $params); } $rating_html = $this->rw_get_activity_rating("top"); return ((false === $rating_html) ? $action : // Attach rating html container after activity actions line. $action . '
' . $rating_html .'
'); } // Activity item bottom rating. function rw_display_activity_rating_bottom($id = "", $type = "") { if (RWLogger::IsOn()){ $params = func_get_args(); RWLogger::LogEnterence("rw_display_activity_rating_bottom", $params); } $rating_html = $this->rw_get_activity_rating("bottom"); if (false !== $rating_html){ // Echo rating html container on bottom actions line. echo $rating_html; } } /*var $current_comment; function rw_get_current_activity_comment($action) { global $activities_template; // Set current activity-comment to current activity update (recursive comments). $this->current_comment = $activities_template->activity; return $action; }*/ // Activity-comment. function rw_display_activity_comment_rating($comment_content) { if (RWLogger::IsOn()){ $params = func_get_args(); RWLogger::LogEnterence("rw_display_activity_comment_rating", $params); } // Find current comment. while (!$this->current_comment->children || false === current($this->current_comment->children)) { $this->current_comment = $this->current_comment->parent; next($this->current_comment->children); } $parent = $this->current_comment; $this->current_comment = current($this->current_comment->children); $this->current_comment->parent = $parent; // Check if comment rating isn't specifically excluded. if (false === $this->rw_validate_visibility($this->current_comment->id, "activity-comment")){ return $comment_content; } // Get activity comment user-rating-id. $comment_urid = $this->_getActivityRatingGuid($this->current_comment->id); // Queue activity-comment rating. self::QueueRatingData($comment_urid, strip_tags($this->current_comment->content), bp_activity_get_permalink($this->current_comment->id), "activity-comment"); $rw = '
hor . '">

'; // Attach rating html container. return ($this->activity_align["activity-comment"]->ver == "top") ? $rw . $comment_content : $comment_content . $rw; } /* Final Rating-Widget JS attach (before ) ---------------------------------------------------------------------------------------------------------------*/ function rw_attach_rating_js($pElement) { 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-blog-post" => array("options" => WP_RW__ACTIVITY_BLOG_POSTS_OPTIONS), "new-blog-comment" => array("options" => WP_RW__ACTIVITY_BLOG_COMMENTS_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) { ?>
\n"; } } } if (class_exists("WP_Widget")) { /* Top Rated Widget ---------------------------------------------------------------------------------------------------------------*/ class RWTopRated extends WP_Widget { var $rw_address; var $version; function RWTopRated() { $this->rw_address = WP_RW__ADDRESS; $widget_ops = array('classname' => 'rw_top_rated', 'description' => __('A list of your top rated posts.')); $this->WP_Widget("RWTopRated", "Rating-Widget: Top Rated", $widget_ops); // wp_enqueue_style('rw_toprated', "{$this->rw_address}/css/wordpress/toprated.css", array(), WP_RW__VERSION); } function widget($args, $instance) { if (!defined("WP_RW__USER_KEY") || false === WP_RW__USER_KEY){ return; } extract($args, EXTR_SKIP); if (false === $instance['show_posts'] && false === $instance['show_comments'] && false === $instance['show_pages']) { // Nothing to show. return; } $details = array( "uid" => WP_RW__USER_KEY, ); if (false !== WP_RW__USER_SECRET) { // Secure connection. $timestamp = time(); $token = RatingWidgetPlugin::GenerateToken($timestamp, true); $details["timestamp"] = $timestamp; $details["token"] = $token; } $queries = array(); $types = array( "posts" => array( "rclass" => "blog-post", "classes" => "front-post,blog-post,new-blog-post" ), "pages" => array( "rclass" => "page", "classes" => "page" ), "comments" => array( "rclass" => "comment", "classes" => "comment,new-blog-comment" ), ); foreach ($types as $type => $type_data) { if ($instance["show_{$type}"] && $instance["{$type}_count"] > 0) { $queries[$type] = array( "rclasses" => $type_data["classes"], "votes" => 1, "orderby" => "avgrate", "order" => "DESC", "limit" => (int)$instance["{$type}_count"], ); } } $details["queries"] = urlencode(json_encode($queries)); $rw_ret_obj = RatingWidgetPlugin::RemoteCall("action/query/ratings.php", $details); if (false === $rw_ret_obj){ return; } $rw_ret_obj = json_decode($rw_ret_obj); if (null === $rw_ret_obj || true !== $rw_ret_obj->success){ return; } echo $before_widget; $title = empty($instance['title']) ? __('Top Rated', WP_RW__ID) : apply_filters('widget_title', $instance['title']); echo $before_title . $title . $after_title; $empty = true; foreach($rw_ret_obj->data as $type => $ratings) { if (is_array($ratings) && count($ratings) > 0) { echo '
'; echo '

' . ucwords($type) . '

'; echo '"; echo "
"; $empty = false; } } if (true === $empty){ echo '

There are no rated items for this period.

'; } else { // Set a flag that the widget is loaded. RatingWidgetPlugin::TopRatedWidgetLoaded(); ?> ""); foreach ($types as $type) { $values["show_{$type}"] = "1"; $values["{$type}_count"] = "2"; } $instance = wp_parse_args((array)$instance, $values); $title = strip_tags($instance['title']); foreach ($types as $type) { $values["show_{$type}"] = (int)$instance["show_{$type}"]; $values["{$type}_count"] = (int)$instance["{$type}_count"]; } ?>