public static function PowerOn() { self::$_on = true; $bt = debug_backtrace(); $caller = array_shift($bt); self::$_start = strpos($caller['file'], '/plugins/rating-widget/') + strlen('/plugins/rating-widget'); self::$_logger = rw_fs()->get_logger(); self::$_logger->on(); if (WP_RW__LOG_DUMP) { self::$_logger->echo_on(); } }
/** * Optional data migration based on the database stored options. * * @author Vova Feldman (@svovaf) * @since 2.6.3 */ private function optional_migration() { $site_id = $this->_options->get_option(WP_RW__DB_OPTION_SITE_ID); if (empty($site_id)) { $fs_options = rw_fs()->get_options_manager(WP_FS__ACCOUNTS_OPTION_NAME, true, false); if (false === $fs_options) { } else { // Check if RW account stored in FS accounts object (was set in one of the first FS semi-integrated versions. $sites = $fs_options->get_option('sites'); if (!empty($sites) && is_array($sites) && 0 < count($sites)) { foreach ($sites as $basename => $site) { if ('/rating-widget.php' !== substr($basename, -strlen('/rating-widget.php'))) { continue; } if (is_object($site) && !empty($site->secret_key) && 'sk_' !== substr($site->secret_key, 0, 3) && !empty($site->public_key) && 'pk_' !== substr($site->public_key, 0, 3)) { $this->migrate_from_fs_options($fs_options, $basename); } } } } } }
private function __construct() { $this->fs = rw_fs(); $this->_options_manager = rw_fs_options(); if (WP_RW__DEBUG) { $this->InitLogger(); } // Load plugin options. $this->LoadDefaultOptions(); $this->LoadOptions(); // Give 2nd chance to logger after options are loaded. if (!RWLogger::IsOn() && $this->GetOption(WP_RW__LOGGER)) { $this->InitLogger(); } // If not in admin dashboard and account don't exist, don't continue with plugin init. if (!$this->fs->is_registered() && !is_admin()) { return; } // Load config after keys are loaded. require_once WP_RW__PLUGIN_DIR . "/lib/config.php"; // Load top-rated require_once WP_RW__PLUGIN_LIB_DIR . "rw-top-rated-widget.php"; }
</td> <input type="hidden" class="multi-rating-label" name="multi_rating[criteria][][label]" value="<?php echo isset($criterion['label']) ? $criterion['label'] : ''; ?> "/> </tr> <?php } ?> <tr class="rw-add-rating-container"> <td colspan="3"> <div class="rw-dash"> <?php $upgrade_label_text = __rw('upgrade_criteria-limit'); if ($total_criteria >= 3 && !rw_fs()->is_plan_or_trial('professional')) { ?> <a class="rw-add-rating upgrade" href="<?php echo $rw_fs->get_upgrade_url(); ?> " data-upgrade-href="<?php echo $rw_fs->get_upgrade_url(); ?> " data-upgrade-text="[+] <?php echo $upgrade_label_text; ?> " data-default-text="[+] <?php echo $add_criteria_str;
echo WP_RW__ADMIN_MENU_SLUG; ?> :hover .wp-menu-image a, ul#adminmenu li.toplevel_page_<?php echo WP_RW__ADMIN_MENU_SLUG; ?> .wp-has-current-submenu .wp-menu-image a, ul#adminmenu li.toplevel_page_<?php echo WP_RW__ADMIN_MENU_SLUG; ?> .current .wp-menu-image a { background-position: -1px 0; } ul#adminmenu li.toplevel_page_<?php echo WP_RW__ADMIN_MENU_SLUG; ?> .wp-menu-image a img { display: none; } <?php if (rw_fs()->is_not_paying()) { ?> ul#adminmenu li.toplevel_page_<?php echo WP_RW__ADMIN_MENU_SLUG; ?> ul li:last-child a { color: yellowgreen; font-weight: bold; text-transform: uppercase; } <?php } ?> </style>
<table cellpadding="0" cellspacing="0"> <tr> <td style="width: 50%; vertical-align: top;"> <div style="font-size: 15px;line-height: 21px;"> <?php _erw('dummy-report-marketing'); ?> </div> <div id="rw_new_wp_subscribe"> <input type="hidden" id="rw_wp_uid" value="<?php echo rw_account()->site_public_key; ?> "/> <a href="<?php echo rw_fs()->get_upgrade_url(); ?> " onclick="_gaq.push(['_trackEvent', 'upgrade', 'wordpress', 'gopro_button', 1, true]); _gaq.push(['_link', this.href]); return false;" class="button-primary gradient" style="display: block; text-align: center;"><?php _erw('learn-more'); ?> </a> </div> </td> <td> <ul id="rw_wp_premium_features" style="float: right; padding-left: 50px; border-left: 1px solid rgb(152, 223, 152);"> <li><b><?php _erw('upgrade_rich-snippets');
if ('laccount' === $settings->identify_by) { echo ' checked="checked"'; } ?> > <span><?php _e('Identify visitor by Cookie / Device.', WP_RW__ID); ?> </span> </div> <div class="rw-ui-img-radio rw-ui-hor<?php if ('ip' === $settings->identify_by) { echo ' rw-selected'; } ?> "<?php if (!rw_fs()->is_plan_or_trial('professional')) { ?> data-alert="<?php _e('Visitor by IP identification is only supported in Professional plan and above.', WP_RW__ID); ?> "<?php } ?> > <input type="radio" name="rw_identify_by" value="ip" <?php if ('ip' === $settings->identify_by) { echo ' checked="checked"'; } ?> > <span><?php _e('Identify visitor by IP / Location. <b>Especially for Voting Contests</b> (included in Professional Plan).', WP_RW__ID);
/** * Generates the main JavaScript which renders all the ratings on the page. * * @param bool $pElement */ public 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), 'forum-reply' => 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)); foreach ($this->_extensions as $ext) { $ext_settings = $ext->GetSettings(); foreach ($ext_settings as $type => $options) { $rw_settings[$options['class']] = array('options' => $options['options']); } } $attach_js = false; $criteria_suffix_part = '-criteria'; if (is_array(self::$ratings) && count(self::$ratings) > 0) { foreach (self::$ratings as $urid => $data) { $rclass = $data['rclass']; if (RWLogger::IsOn()) { RWLogger::Log('rw_attach_rating_js', 'Urid = ' . $urid . '; Class = ' . $rclass . ';'); } $suffix_pos = strpos($rclass, $criteria_suffix_part); if (false !== $suffix_pos) { /* Use dummy value for the criteria options but * use the settings of the summary rating when * calling RW.initClass below */ $rw_settings[$rclass] = 'DUMMY'; /* * Make sure that the following code (the if block) will have the main option class, e.g. blog-post, * and not the criterion class, e.g. blog-post-criteria-1. This is because the following * code needs the main option class in order to load the type (blog, page, etc.) settings which include * the themes and other display options. A criterion rating will use these display options, * so this code extracts the main option class from the criterion class. */ $rclass = substr($rclass, 0, $suffix_pos); } if (isset($rw_settings[$rclass]) && is_array($rw_settings[$rclass]) && !isset($rw_settings[$rclass]['enabled'])) { if (RWLogger::IsOn()) { RWLogger::Log('rw_attach_rating_js', 'Class = ' . $rclass . ';'); } // Forum reply should have exact same settings as forum post. $alias = 'forum-reply' === $rclass ? 'forum-post' : $rclass; $rw_settings[$rclass]['enabled'] = true; // Get rating front posts settings. $rw_settings[$rclass]['options'] = $this->GetOption($rw_settings[$rclass]['options']); /* * We don't want to display the number of votes when the comment rating mode is "Review" or "Admin-only ratings". * So we're modifying the rating label so that it will be based on the vote. e.g.: 5-star vote = "Excellent". */ if ('comment' === $rclass && ($this->is_comment_review_mode() || $this->is_comment_admin_ratings_mode())) { $options = $rw_settings[$rclass]['options']; if (!isset($options->label)) { $options->label = new stdClass(); } if (!isset($options->label->text)) { $options->label->text = new stdClass(); } if (!isset($options->label->text->star)) { $options->label->text->star = new stdClass(); } if (!isset($options->label->text->nero)) { $options->label->text->nero = new stdClass(); } /** * The following will show the same label when the rating is not empty whether the viewer has already voted or has not voted yet. * * e.g.: Instead of showing "Rate this (2 Votes)" or "5 Votes", the label will be "Excellent", "Good", or "Awful", depending on the label settings. */ $options->label->text->star->normal = '{{rating.lastVote}}'; $options->label->text->star->rated = '{{rating.lastVote}}'; $options->label->text->nero->rated = '{{rating.lastVote}}'; $options->label->text->nero->normal = '{{text.rateThis}}'; $options->showToolip = false; $options->showReport = false; } if (WP_RW__AVAILABILITY_DISABLED === $this->rw_validate_availability($alias)) { // Disable ratings (set them to be readOnly). $rw_settings[$rclass]['options']->readOnly = true; } $attach_js = true; } } } $is_bp_activity_component = function_exists('bp_is_activity_component') && bp_is_activity_component(); if (!$attach_js) { // Necessary for rendering newly inserted activity ratings // when the are no status updates or comments yet if ($is_bp_activity_component) { $bp_rclasses = array('activity-update', 'activity-comment'); foreach ($bp_rclasses as $rclass) { if (isset($rw_settings[$rclass]) && !isset($rw_settings[$rclass]['enabled'])) { if (RWLogger::IsOn()) { RWLogger::Log('rw_attach_rating_js', 'Class = ' . $rclass . ';'); } $rw_settings[$rclass]['enabled'] = true; // Get rating class 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). $rw_settings[$rclass]['options']->readOnly = true; } $attach_js = true; } } } } if ($attach_js || $this->_TOP_RATED_WIDGET_LOADED) { ?> <!-- This site's ratings are powered by RatingWidget plugin v<?php echo WP_RW__VERSION; ?> - https://rating-widget.com/wordpress-plugin/ --> <div class="rw-js-container"> <?php if (rw_fs()->_has_addons()) { rw_wf()->print_site_script(); } ?> <script type="text/javascript"> // Initialize ratings. function RW_Async_Init(){ RW.init({<?php // User key (uid). echo 'uid: "' . $this->account->site_public_key . '"'; // User id (huid). if ($this->account->has_site_id()) { echo ', huid: "' . $this->account->site_id . '"'; } global $pagenow; $vid = 0; // Only set the vid to 1 if the comment ratings mode is set to "Admin ratings only". if ('comment.php' === $pagenow && $this->is_comment_admin_ratings_mode()) { $vid = 1; } else { // User logged-in. $user = wp_get_current_user(); $vid = $user->ID; } if ($vid !== 0) { // Set voter id to logged user id. echo ", vid: {$vid}"; } ?> , source: "wordpress", options: { <?php ?> }, identifyBy: "<?php echo $this->GetOption(WP_RW__IDENTIFY_BY); ?> " }); <?php foreach ($rw_settings as $rclass => $options) { $criteria_class = $rclass; $suffix_pos = strpos($rclass, $criteria_suffix_part); if (false !== $suffix_pos) { $rclass = substr($rclass, 0, $suffix_pos); } if (isset($rw_settings[$rclass]['enabled']) && true === $rw_settings[$rclass]['enabled']) { $alias = 'forum-reply' === $rclass ? 'forum-post' : $rclass; ?> var options = <?php echo !empty($rw_settings[$alias]['options']) ? json_encode($rw_settings[$rclass]['options']) : '{}'; ?> ; <?php echo $this->GetCustomSettings($alias); ?> <?php if (rw_fs()->_has_addons()) { ?> if ( WF_Engine ) { var _beforeRate = options.beforeRate ? options.beforeRate : false; options.beforeRate = function(rating, score) { var returnValue = true; if (false !== _beforeRate) { returnValue = _beforeRate(rating, score); } return WF_Engine.eval( 'beforeVote', rating, score, returnValue ); }; var _afterRate = options.afterRate ? options.afterRate : false; options.afterRate = function(success, score, rating) { if (false !== _afterRate) { _afterRate(success, score, rating); } WF_Engine.eval( 'afterVote', rating, score ); return true; }; } <?php } ?> RW.initClass("<?php echo $criteria_class; ?> ", options); <?php } } foreach (self::$ratings as $urid => $data) { if (is_string($data['title']) && !empty($data['title']) || is_string($data['permalink']) && !empty($data['permalink']) || isset($data['img'])) { $properties = array(); if (is_string($data['title']) && !empty($data['title'])) { $properties[] = 'title: ' . json_encode(esc_js($data['title'])); } if (is_string($data['permalink']) && !empty($data['permalink'])) { $properties[] = 'url: ' . json_encode(esc_js($data['permalink'])); } if (isset($data['img'])) { $properties[] = 'img: ' . json_encode(esc_js($data['img'])); } echo 'RW.initRating("' . $urid . '", {' . implode(', ', $properties) . '});'; } } ?> RW.render(function() { (function($) { $('.rw-rating-table:not(.rw-no-labels):not(.rw-comment-admin-rating)').each(function() { var ratingTable = $(this); // Find the current width before floating left or right to // keep the ratings aligned var col1 = ratingTable.find('td:first'); var widthCol1 = col1.width(); ratingTable.find('td:first-child').width(widthCol1); if (ratingTable.hasClass('rw-rtl')) { ratingTable.find('td').css({float: 'right'}); } else { ratingTable.find('td').css({float: 'left'}); } }); })(jQuery); }, <?php echo !$this->_TOP_RATED_WIDGET_LOADED ? 'true' : 'false'; ?> ); } RW_Advanced_Options = { blockFlash: !(<?php $flash = $this->GetOption(WP_RW__FLASH_DEPENDENCY, true); echo in_array($flash, array('true', 'false')) ? $flash : (false === $flash ? 'false' : 'true'); ?> ) }; // 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 rw_get_js_url('external' . (!WP_RW__DEBUG ? '.min' : '') . '.php'); ?> ?wp=<?php echo WP_RW__VERSION; ?> "; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(rw, s); })(); } </script> </div> <!-- / RatingWidget plugin --> <?php // Enqueue the script that will handle the rendering // of the rating of the newly inserted BuddyPress status update // or comment if ($is_bp_activity_component) { rw_enqueue_script('rw-site-ajax-handler', WP_RW__PLUGIN_URL . 'resources/js/site-ajax-handler.js'); } } }
echo $p['title']; ?> :</nobr> </td> <td> <code><?php echo htmlspecialchars($p['value']); ?> </code> </td> <?php if (WP_RW__DEBUG) { ?> <td class="fs-right"> <form action="<?php echo rw_fs()->_get_admin_page_url('account'); ?> " method="POST" onsubmit="var val = prompt('<?php printf(__rw('what-is-your'), $p['title']); ?> ', '<?php echo $p['value']; ?> '); if (null == val || '' === val) return false; jQuery('input[name=rw_<?php echo $p['id']; ?> ]').val(val); return true;"> <input type="hidden" name="rw_action" value="update_<?php echo $p['id']; ?>
case 'last_7_days': $since_created = WP_RW__TIME_WEEK_IN_SEC; break; case 'last_24_hours': $since_created = WP_RW__TIME_24_HOURS_IN_SEC; break; default: $since_created = WP_RW__TIME_ALL_TIME; break; } // Validate the direction attribute $direction = strtolower($direction); if ('ltr' !== $direction && 'rtl' !== $direction) { $direction = 'ltr'; } if (!rw_fs()->is_plan_or_trial__premium_only('professional')) { // Ensure that the maximum number of items is 10 for the free version. $max_items = min($max_items, 10); } $rw_ret_obj = ratingwidget()->GetTopRatedData(array($type), $max_items, 0, $min_votes, false, false, $order_by, $order, $since_created); if ($rw_ret_obj && count($rw_ret_obj->data)) { // Retrieve the rating types settings $types = ratingwidget()->get_rating_types(); $container_class = 'rw-top-rated-page ' . $direction; $html = '<div class="' . $container_class . '">'; foreach ($rw_ret_obj->data as $type => $ratings) { // Now, retrieve the rclass from the type settings $rclass = $types[$type]['rclass']; if (is_array($ratings) && count($ratings) > 0) { $html .= '<div class="rw-top-rated-page-' . $type . '" class="rw-wp-ui-top-rated-list-container">'; $html .= '<ul class="rw-wp-ui-top-rated-list">';
/** * Configures the admin menus and registers the hooks and filters needed for the admin area and site. * * @author Leo Fajardo (@leorw) */ function init() { if (is_admin() && rw_fs()->has_installed_addons()) { $this->_init_admin(); } else { $this->_init_site(); } }
function widget($args, $instance) { /** * @var RatingWidgetPlugin $rwp */ global $rwp; if (RWLogger::IsOn()) { $params = func_get_args(); RWLogger::LogEnterence("RatingWidgetPlugin_TopRatedWidget.widget", $params, true); } if (!rw_account()->is_registered()) { return; } if (RatingWidgetPlugin::$WP_RW__HIDE_RATINGS) { return; } extract($args, EXTR_SKIP); $bpInstalled = $rwp->IsBuddyPressInstalled(); if (rw_fs()->is__premium_only()) { $bbInstalled = $rwp->IsBBPressInstalled(); } else { $bbInstalled = false; } $types = $this->GetTypesInfo(); $show_any = false; foreach ($types as $type => $data) { if (false !== $instance["show_{$type}"]) { $show_any = true; break; } } if (RWLogger::IsOn()) { RWLogger::Log('RatingWidgetPlugin_TopRatedWidget', 'show_any = ' . ($show_any ? 'TRUE' : 'FALSE')); } if (false === $show_any) { // Nothing to show. return; } $details = array("uid" => rw_account()->site_public_key); $queries = array(); foreach ($types as $type => $type_data) { if (isset($instance["show_{$type}"]) && $instance["show_{$type}"] && $instance["{$type}_count"] > 0) { $options = ratingwidget()->GetOption($type_data["options"]); $queries[$type] = array("rclasses" => $type_data["classes"], "votes" => max(1, (int) $instance["{$type}_min_votes"]), "orderby" => $instance["{$type}_orderby"], "order" => $instance["{$type}_order"], "limit" => (int) $instance["{$type}_count"], "types" => isset($options->type) ? $options->type : "star"); $since_created = isset($instance["{$type}_since_created"]) ? (int) $instance["{$type}_since_created"] : WP_RW__TIME_ALL_TIME; // since_created should be at least 24 hours (86400 seconds), skip otherwise. if ($since_created >= WP_RW__TIME_24_HOURS_IN_SEC) { $time = current_time('timestamp', true) - $since_created; // c: ISO 8601 full date/time, e.g.: 2004-02-12T15:19:21+00:00 $queries[$type]['since_created'] = date('c', $time); } } } $details["queries"] = urlencode(json_encode($queries)); $rw_ret_obj = ratingwidget()->RemoteCall("action/query/ratings.php", $details, WP_RW__CACHE_TIMEOUT_TOP_RATED); 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; } // Check if data is available if (!isset($rw_ret_obj->data)) { return; } $title = empty($instance['title']) ? __rw('top-rated') : apply_filters('widget_title', $instance['title']); $titleMaxLength = isset($instance['title_max_length']) && is_numeric($instance['title_max_length']) ? (int) $instance['title_max_length'] : 30; $empty = true; $toprated_data = new stdClass(); $toprated_data->id = rand(1, 100); $toprated_data->title = array('label' => $title, 'show' => true, 'before' => $this->EncodeHtml($before_title), 'after' => $this->EncodeHtml($after_title)); $toprated_data->options = array('align' => 'vertical', 'direction' => 'ltr', 'html' => array('before' => $this->EncodeHtml($before_widget), 'after' => $this->EncodeHtml($after_widget))); $toprated_data->site = array('id' => rw_account()->site_id, 'domain' => $_SERVER['HTTP_HOST'], 'type' => 'WordPress'); $toprated_data->itemGroups = array(); if (count($rw_ret_obj->data) > 0) { foreach ($rw_ret_obj->data as $type => $ratings) { if (is_array($ratings) && count($ratings) > 0) { $item_group = new stdClass(); $item_group->type = $type; $item_group->title = $instance["{$type}_title"]; $item_group->showTitle = 1 === $instance["show_{$type}_title"] && '' !== trim($item_group->title); if (is_numeric($instance["{$type}_style"])) { switch ($instance["{$type}_style"]) { case 0: $instance["{$type}_style"] = 'legacy'; break; case 1: default: $instance["{$type}_style"] = 'thumbs'; break; } } $item_group->style = $instance["{$type}_style"]; $item_group->options = array('title' => array('maxLen' => $titleMaxLength)); $item_group->items = array(); $has_thumb = strtolower($instance["{$type}_style"]) !== 'legacy'; $thumb_width = 160; $thumb_height = 100; if ($has_thumb) { switch ($instance["{$type}_style"]) { case '2': case 'compact_thumbs': $thumb_width = 50; $thumb_height = 40; break; case '1': case 'thumbs': default: $thumb_width = 160; $thumb_height = 100; break; } $item_group->options['thumb'] = array('width' => $thumb_width, 'height' => $thumb_height); } $cell = 0; foreach ($ratings as $rating) { $urid = $rating->urid; $rclass = $types[$type]["rclass"]; $rclasses[$rclass] = true; $extension_type = false; if (RWLogger::IsOn()) { RWLogger::Log('HANDLED_ITEM', 'Urid = ' . $urid . '; Class = ' . $rclass . ';'); } if ('posts' === $type || 'pages' === $type) { $post = null; $id = RatingWidgetPlugin::Urid2PostId($urid); $status = @get_post_status($id); if (false === $status) { if (RWLogger::IsOn()) { RWLogger::Log('POST_NOT_EXIST', $id); } // Post not exist. continue; } else { if ('publish' !== $status && 'private' !== $status) { if (RWLogger::IsOn()) { RWLogger::Log('POST_NOT_VISIBLE', 'status = ' . $status); } // Post not yet published. continue; } else { if ('private' === $status && !is_user_logged_in()) { if (RWLogger::IsOn()) { RWLogger::Log('RatingWidgetPlugin_TopRatedWidget::widget', 'POST_PRIVATE && USER_LOGGED_OUT'); } // Private post but user is not logged in. continue; } } } $post = @get_post($id); $title = trim(strip_tags($post->post_title)); $permalink = get_permalink($post->ID); } else { if ('comments' === $type) { $comment = null; $id = RatingWidgetPlugin::Urid2CommentId($urid); $status = @wp_get_comment_status($id); if (false === $status) { if (RWLogger::IsOn()) { RWLogger::Log('COMMENT_NOT_EXIST', $id); } // Comment not exist. continue; } else { if ('approved' !== $status) { if (RWLogger::IsOn()) { RWLogger::Log('COMMENT_NOT_VISIBLE', 'status = ' . $status); } // Comment not approved. continue; } } $comment = @get_comment($id); $title = trim(strip_tags($comment->comment_content)); $permalink = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; } else { if ('activity_updates' === $type || 'activity_comments' === $type) { $id = RatingWidgetPlugin::Urid2ActivityId($urid); $activity = new bp_activity_activity($id); if (!is_object($activity)) { if (RWLogger::IsOn()) { RWLogger::Log('BP_ACTIVITY_NOT_EXIST', $id); } // Activity not exist. continue; } else { if (!empty($activity->is_spam)) { if (RWLogger::IsOn()) { RWLogger::Log('BP_ACTIVITY_NOT_VISIBLE (SPAM or TRASH)'); } // Activity marked as SPAM or TRASH. continue; } else { if (!empty($activity->hide_sitewide)) { if (RWLogger::IsOn()) { RWLogger::Log('BP_ACTIVITY_HIDE_SITEWIDE'); } // Activity marked as hidden in site. continue; } } } $title = trim(strip_tags($activity->content)); $permalink = bp_activity_get_permalink($id); } else { if ('users' === $type) { $id = RatingWidgetPlugin::Urid2UserId($urid); if ($bpInstalled) { $title = trim(strip_tags(bp_core_get_user_displayname($id))); $permalink = bp_core_get_user_domain($id); } else { if ($bbInstalled) { $title = trim(strip_tags(bbp_get_user_display_name($id))); $permalink = bbp_get_user_profile_url($id); } else { continue; } } } else { if ('forum_posts' === $type || 'forum_replies' === $type) { $id = RatingWidgetPlugin::Urid2ForumPostId($urid); if (function_exists('bp_forums_get_post')) { $forum_post = @bp_forums_get_post($id); if (!is_object($forum_post)) { continue; } $title = trim(strip_tags($forum_post->post_text)); $page = bb_get_page_number($forum_post->post_position); $permalink = get_topic_link($id, $page) . "#post-{$id}"; } else { if (function_exists('bbp_get_reply_id')) { $forum_item = bbp_get_topic($id); if (is_object($forum_item)) { $is_topic = true; } else { $is_topic = false; $forum_item = bbp_get_reply($id); if (!is_object($forum_item)) { if (RWLogger::IsOn()) { RWLogger::Log('BBP_FORUM_ITEM_NOT_EXIST', $id); } // Invalid id (no topic nor reply). continue; } if (RWLogger::IsOn()) { RWLogger::Log('BBP_IS_TOPIC_REPLY', $is_topic ? 'FALSE' : 'TRUE'); } } // Visible statueses: Public or Closed. $visible_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id()); if (!in_array($forum_item->post_status, $visible_statuses)) { if (RWLogger::IsOn()) { RWLogger::Log('BBP_FORUM_ITEM_HIDDEN', $forum_item->post_status); } // Item is not public nor closed. continue; } $is_reply = !$is_topic; if ($is_reply) { // Get parent topic. $forum_item = bbp_get_topic($forum_item->post_parent); if (!in_array($forum_item->post_status, $visible_statuses)) { if (RWLogger::IsOn()) { RWLogger::Log('BBP_PARENT_FORUM_TOPIC_IS_HIDDEN', 'TRUE'); } // Parent topic is not public nor closed. continue; } } $title = trim(strip_tags($forum_item->post_title)); $permalink = get_permalink($forum_item->ID); } else { continue; } } } else { $found_handler = false; $extensions = ratingwidget()->GetExtensions(); foreach ($extensions as $ext) { $result = $ext->GetElementInfoByRating($type, $rating); if (false !== $result) { $found_handler = true; break; } } if ($found_handler) { $id = $result['id']; $title = $result['title']; $permalink = $result['permalink']; $img = rw_get_thumb_url($result['img'], $thumb_width, $thumb_height, $result['permalink']); $extension_type = true; } else { continue; } } } } } } $queued = ratingwidget()->QueueRatingData($urid, "", "", $rclass); // Override rating class in case the same rating has already been queued with a different rclass. $rclass = $queued['rclass']; $short = mb_strlen($title) > $titleMaxLength ? trim(mb_substr($title, 0, $titleMaxLength)) . "..." : $title; $item = array('site' => array('id' => rw_account()->site_id, 'domain' => $_SERVER['HTTP_HOST']), 'page' => array('externalID' => $id, 'url' => $permalink, 'title' => $short), 'rating' => array('localID' => $urid, 'options' => array('rclass' => $rclass))); // Add thumb url. if ($extension_type && is_string($img)) { $item['page']['img'] = $img; } else { if ($has_thumb && in_array($type, array('posts', 'pages'))) { $item['page']['img'] = rw_get_post_thumb_url($post, $thumb_width, $thumb_height); } } $item_group->items[] = $item; $cell++; $empty = false; } $toprated_data->itemGroups[] = $item_group; } } } if (true === $empty) { // echo '<p style="margin: 0;">There are no rated items for this period.</p>'; // echo $before_widget; // echo $after_widget; } else { // Set a flag that the widget is loaded. ratingwidget()->TopRatedWidgetLoaded(); ?> <b class="rw-ui-recommendations" data-id="<?php echo $toprated_data->id; ?> "></b> <script type="text/javascript"> var _rwq = _rwq || []; _rwq.push(['_setRecommendations', <?php echo json_encode($toprated_data); ?> ]); </script> <?php } }
?> "> <?php rw_include_once_view("settings/theme.php"); ?> </tr> <tr id="rw_star_size" class="rw-<?php echo ($odd = !$odd) ? "odd" : "even"; ?> "> <?php rw_include_once_view("settings/size.php"); ?> </tr> <?php if (rw_fs()->is__premium_only()) { ?> <?php if (ratingwidget()->IsBuddyPressInstalled() || ratingwidget()->IsBBPressInstalled()) { ?> <tr id="rw_rate_background" class="rw-<?php echo ($odd = !$odd) ? "odd" : "even"; ?> "> <?php rw_include_once_view("settings/background.php"); ?> </tr> <?php } ?>
private function __construct($load = false) { $this->optional_migration(); $this->_options = rw_fs()->get_options_manager(WP_RW__OPTIONS, true, false); }