/**
         * To get a list of all custom user defined posts:
         *
         *       get_post_types(array('public'=>true,'_builtin' => false))
         */
        public function SettingsPage()
        {
            RWLogger::LogEnterence('SettingsPage');
            // Must check that the user has the required capability.
            if (!current_user_can('manage_options')) {
                wp_die(__rw('no-sufficient-permissions'));
            }
            global $plugin_page;
            // Variables for the field and option names
            $rw_form_hidden_field_name = 'rw_form_hidden_field_name';
            $settings_data = array();
            $selected_key = 'dummy';
            if ($plugin_page === $this->GetMenuSlug('buddypress') && $this->IsBuddyPressInstalled()) {
                $settings_data = array('activity-blog-posts' => array('tab' => __rw('activity-blog-posts'), 'class' => 'new-blog-post', 'options' => WP_RW__ACTIVITY_BLOG_POSTS_OPTIONS, 'align' => WP_RW__ACTIVITY_BLOG_POSTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__ACTIVITY_BLOG_POSTS_ALIGN], 'excerpt' => false, 'show_align' => true), 'activity-blog-comments' => array('tab' => __rw('activity-blog-comments'), 'class' => 'new-blog-comment', 'options' => WP_RW__ACTIVITY_BLOG_COMMENTS_OPTIONS, 'align' => WP_RW__ACTIVITY_BLOG_COMMENTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__ACTIVITY_BLOG_COMMENTS_ALIGN], 'excerpt' => false, 'show_align' => true), 'activity-updates' => array('tab' => __rw('activity-updates'), 'class' => 'activity-update', 'options' => WP_RW__ACTIVITY_UPDATES_OPTIONS, 'align' => WP_RW__ACTIVITY_UPDATES_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__ACTIVITY_UPDATES_ALIGN], 'excerpt' => false, 'show_align' => true), 'activity-comments' => array('tab' => __rw('activity-comments'), 'class' => 'activity-comment', 'options' => WP_RW__ACTIVITY_COMMENTS_OPTIONS, 'align' => WP_RW__ACTIVITY_COMMENTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__ACTIVITY_COMMENTS_ALIGN], 'excerpt' => false, 'show_align' => true), 'users' => array('tab' => __rw('user-profiles'), 'class' => 'user', 'options' => WP_RW__USERS_OPTIONS, 'align' => WP_RW__USERS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_ALIGN], 'excerpt' => false, 'show_align' => false));
                $selected_key = isset($_GET['rating']) ? $_GET['rating'] : 'activity-blog-posts';
                if (!isset($settings_data[$selected_key])) {
                    $selected_key = 'activity-blog-posts';
                }
            } else {
                if ($plugin_page === $this->GetMenuSlug('bbpress') && $this->IsBBPressInstalled()) {
                    $settings_data = array('forum-posts' => array('tab' => __rw('forum-posts'), 'class' => 'forum-post', 'options' => WP_RW__FORUM_POSTS_OPTIONS, 'align' => WP_RW__FORUM_POSTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__FORUM_POSTS_ALIGN], 'excerpt' => false, 'show_align' => true), 'activity-forum-posts' => array('tab' => __rw('activity-forum-posts'), 'class' => 'new-forum-post', 'options' => WP_RW__ACTIVITY_FORUM_POSTS_OPTIONS, 'align' => WP_RW__ACTIVITY_FORUM_POSTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__ACTIVITY_FORUM_POSTS_ALIGN], 'excerpt' => false, 'show_align' => true), 'users' => array('tab' => __rw('user-profiles'), 'class' => 'user', 'options' => WP_RW__USERS_OPTIONS, 'align' => WP_RW__USERS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_ALIGN], 'excerpt' => false, 'show_align' => false));
                    $selected_key = isset($_GET['rating']) ? $_GET['rating'] : 'forum-posts';
                    if (!isset($settings_data[$selected_key])) {
                        $selected_key = 'forum-posts';
                    }
                } else {
                    if ($plugin_page === $this->GetMenuSlug('user')) {
                        $settings_data = array('users-posts' => array('tab' => __rw('posts'), 'class' => 'user-post', 'options' => WP_RW__USERS_POSTS_OPTIONS, 'align' => WP_RW__USERS_POSTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_POSTS_ALIGN], 'excerpt' => false, 'show_align' => false), 'users-pages' => array('tab' => __rw('pages'), 'class' => 'user-page', 'options' => WP_RW__USERS_PAGES_OPTIONS, 'align' => WP_RW__USERS_PAGES_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_PAGES_ALIGN], 'excerpt' => false, 'show_align' => false), 'users-comments' => array('tab' => __rw('comments'), 'class' => 'user-comment', 'options' => WP_RW__USERS_COMMENTS_OPTIONS, 'align' => WP_RW__USERS_COMMENTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_COMMENTS_ALIGN], 'excerpt' => false, 'show_align' => false));
                        if ($this->IsBuddyPressInstalled()) {
                            $settings_data['users-activity-updates'] = array('tab' => __rw('activity-updates'), 'class' => 'user-activity-update', 'options' => WP_RW__USERS_ACTIVITY_UPDATES_OPTIONS, 'align' => WP_RW__USERS_ACTIVITY_UPDATES_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_ACTIVITY_UPDATES_ALIGN], 'excerpt' => false, 'show_align' => false);
                            $settings_data['users-activity-comments'] = array('tab' => __rw('activity-comments'), 'class' => 'user-activity-comment', 'options' => WP_RW__USERS_ACTIVITY_COMMENTS_OPTIONS, 'align' => WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN], 'excerpt' => false, 'show_align' => false);
                            if ($this->IsBBPressInstalled()) {
                                $settings_data['users-forum-posts'] = array('tab' => __rw('forum-posts'), 'class' => 'user-forum-post', 'options' => WP_RW__USERS_FORUM_POSTS_OPTIONS, 'align' => WP_RW__USERS_FORUM_POSTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__USERS_FORUM_POSTS_ALIGN], 'excerpt' => false, 'show_align' => false);
                            }
                        }
                        $selected_key = isset($_GET['rating']) ? $_GET['rating'] : 'users-posts';
                        if (!isset($settings_data[$selected_key])) {
                            $selected_key = 'users-posts';
                        }
                    } else {
                        $is_extension = false;
                        foreach ($this->_extensions as $ext) {
                            if ($plugin_page !== $this->GetMenuSlug($ext->GetSlug())) {
                                continue;
                            }
                            $is_extension = true;
                            $settings_data = $ext->GetSettings();
                            $selected_key = isset($_GET['rating']) && isset($settings_data[$_GET['rating']]) ? $_GET['rating'] : $this->GetFirstKey($settings_data);
                        }
                        if (!$is_extension) {
                            $settings_data = array('blog-posts' => array('tab' => __rw('blog-posts'), 'class' => 'blog-post', 'options' => WP_RW__BLOG_POSTS_OPTIONS, 'align' => WP_RW__BLOG_POSTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__BLOG_POSTS_ALIGN], 'excerpt' => true, 'show_align' => true), 'front-posts' => array('tab' => __rw('front-page-posts'), 'class' => 'front-post', 'options' => WP_RW__FRONT_POSTS_OPTIONS, 'align' => WP_RW__FRONT_POSTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__FRONT_POSTS_ALIGN], 'excerpt' => false, 'show_align' => true), 'comments' => array('tab' => __rw('comments'), 'class' => 'comment', 'options' => WP_RW__COMMENTS_OPTIONS, 'align' => WP_RW__COMMENTS_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__COMMENTS_ALIGN], 'excerpt' => false, 'show_align' => true), 'pages' => array('tab' => __rw('pages'), 'class' => 'page', 'options' => WP_RW__PAGES_OPTIONS, 'align' => WP_RW__PAGES_ALIGN, 'default_align' => $this->_OPTIONS_DEFAULTS[WP_RW__PAGES_ALIGN], 'excerpt' => false, '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];
            // Some alias.
            $rw_class = $rw_current_settings['class'];
            $is_blog_post = 'blog-post' === $rw_current_settings['class'];
            $item_with_category = in_array($rw_current_settings['class'], array('blog-post', 'front-post', 'comment'));
            // Visibility list must be loaded anyway.
            $this->_visibilityList = $this->GetOption(WP_RW__VISIBILITY_SETTINGS);
            if ($item_with_category) {
                // Categories Availability list must be loaded anyway.
                $this->categories_list = $this->GetOption(WP_RW__CATEGORIES_AVAILABILITY_SETTINGS);
            }
            // Availability list must be loaded anyway.
            $this->availability_list = $this->GetOption(WP_RW__AVAILABILITY_SETTINGS);
            $this->custom_settings_enabled_list = $this->GetOption(WP_RW__CUSTOM_SETTINGS_ENABLED);
            $this->custom_settings_list = $this->GetOption(WP_RW__CUSTOM_SETTINGS);
            $this->multirating_settings_list = $this->GetOption(WP_RW__MULTIRATING_SETTINGS);
            // Accumulated user ratings support.
            if ('users' === $selected_key && $this->IsBBPressInstalled()) {
                $rw_is_user_accumulated = $this->GetOption(WP_RW__IS_ACCUMULATED_USER_RATING);
            }
            // Comment "Reviews" mode support.
            if ('comments' === $selected_key) {
                $comment_ratings_mode_settings = $this->get_comment_ratings_mode_settings();
                $comment_ratings_mode = $comment_ratings_mode_settings->comment_ratings_mode;
            }
            // Reset categories.
            $rw_categories = array();
            // 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') {
                // Set settings into save mode.
                $this->settings->SetSaveMode();
                /* Multi-rating options.
                   ---------------------------------------------------------------------------------------------------------------*/
                if (isset($_POST['multi_rating'])) {
                    $multi_rating = $_POST['multi_rating'];
                    if (count($multi_rating['criteria']) > 3) {
                        $multi_rating['criteria'] = array_splice($multi_rating['criteria'], 0, 3);
                    }
                    // Unset empty labels
                    foreach ($multi_rating['criteria'] as $criteria_id => $criteria) {
                        $criteria_label = isset($criteria['label']) ? trim($criteria['label']) : '';
                        if (empty($criteria_label)) {
                            unset($multi_rating['criteria'][$criteria_id]['label']);
                        }
                    }
                    // Retrieve the current multi-rating options
                    if (!isset($this->multirating_settings_list)) {
                        $this->multirating_settings_list = new stdClass();
                    }
                    $multirating_options = $this->multirating_settings_list->{$rw_class};
                    // Save the new criteria IDs and labels
                    $multirating_options->criteria = $multi_rating['criteria'];
                    // Save the summary label
                    $summary_label = isset($multi_rating['summary_label']) ? trim($multi_rating['summary_label']) : '';
                    if (!empty($summary_label)) {
                        $multirating_options->summary_label = $summary_label;
                    } else {
                        unset($multirating_options->summary_label);
                    }
                    // Save the state of the Show Summary Rating option
                    $multirating_options->show_summary_rating = isset($multi_rating['show_summary_rating']) ? true : false;
                    // Save the updated multi-rating options
                    if (!isset($this->multirating_settings_list)) {
                        $this->multirating_settings_list = new stdClass();
                    }
                    $this->multirating_settings_list->{$rw_class} = $multirating_options;
                    $this->SetOption(WP_RW__MULTIRATING_SETTINGS, $this->multirating_settings_list);
                }
                /* Widget align options.
                   ---------------------------------------------------------------------------------------------------------------*/
                $rw_show_rating = isset($_POST['rw_show']) ? true : false;
                $rw_align = !$rw_show_rating ? new stdClass() : $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->ver = $align[0];
                            $rw_align->hor = $align[1];
                        }
                    }
                }
                $this->SetOption($rw_current_settings['align'], $rw_align);
                /* Rating-Widget options.
                   ---------------------------------------------------------------------------------------------------------------*/
                $rw_options = json_decode(preg_replace('/\\%u([0-9A-F]{4})/i', '\\u$1', urldecode(stripslashes($_POST['rw_options']))));
                if (null !== $rw_options) {
                    $this->SetOption($rw_current_settings['options'], $rw_options);
                }
                /* 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, $this->availability_list);
                if ($item_with_category) {
                    /* Categories Availability settings.
                       ---------------------------------------------------------------------------------------------------------------*/
                    $rw_categories = isset($_POST['rw_categories']) && is_array($_POST['rw_categories']) ? $_POST['rw_categories'] : array();
                    if (!isset($this->categories_list)) {
                        $this->categories_list = new stdClass();
                    }
                    $this->categories_list->{$rw_class} = in_array('-1', $rw_categories) ? array('-1') : $rw_categories;
                    $this->SetOption(WP_RW__CATEGORIES_AVAILABILITY_SETTINGS, $this->categories_list);
                }
                // Accumulated user ratings support.
                if ('users' === $selected_key && $this->IsBBPressInstalled() && isset($_POST['rw_accumulated_user_rating'])) {
                    $rw_is_user_accumulated = 'true' == (in_array($_POST['rw_accumulated_user_rating'], array('true', 'false')) ? $_POST['rw_accumulated_user_rating'] : 'true');
                    $this->SetOption(WP_RW__IS_ACCUMULATED_USER_RATING, $rw_is_user_accumulated);
                }
                // Comment ratings mode
                if ('comments' === $selected_key && isset($_POST['rw_comment_review_mode'])) {
                    $comment_ratings_mode = $_POST['rw_comment_review_mode'];
                    // Save the new comment ratings mode.
                    $comment_ratings_mode_settings = $this->get_comment_ratings_mode_settings();
                    $comment_ratings_mode_settings->comment_ratings_mode = $comment_ratings_mode;
                    $this->SetOption(WP_RW__DB_OPTION_IS_ADMIN_COMMENT_RATINGS_SETTINGS, $comment_ratings_mode_settings);
                }
                /* 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'] : '';
                $rw_custom_settings_enabled = isset($_POST['rw_custom_settings_enabled']) ? true : false;
                if (!isset($this->custom_settings_enabled_list)) {
                    $this->custom_settings_enabled_list = new stdClass();
                }
                $this->custom_settings_enabled_list->{$rw_class} = $rw_custom_settings_enabled;
                $this->SetOption(WP_RW__CUSTOM_SETTINGS_ENABLED, $this->custom_settings_enabled_list);
                $rw_custom_settings = isset($_POST['rw_custom_settings']) ? $_POST['rw_custom_settings'] : '';
                if (!isset($this->custom_settings_list)) {
                    $this->custom_settings_list = new stdClass();
                }
                $this->custom_settings_list->{$rw_class} = $rw_custom_settings;
                $this->SetOption(WP_RW__CUSTOM_SETTINGS, $this->custom_settings_list);
                if (!isset($this->_visibilityList)) {
                    $this->_visibilityList = new stdClass();
                }
                if (!isset($this->_visibilityList->{$rw_class})) {
                    $this->_visibilityList->{$rw_class} = new stdClass();
                }
                $this->_visibilityList->{$rw_class}->selected = $rw_visibility;
                $this->_visibilityList->{$rw_class}->exclude = self::IDsCollectionToArray($rw_visibility_exclude);
                $this->_visibilityList->{$rw_class}->include = self::IDsCollectionToArray($rw_visibility_include);
                $this->SetOption(WP_RW__VISIBILITY_SETTINGS, $this->_visibilityList);
                ?>
					<div class="updated"><p><strong><?php 
                _erw('settings-successfully-saved');
                ?>
</strong>
						</p></div>
				<?php 
            } else {
                /* Get rating alignment.
                   ---------------------------------------------------------------------------------------------------------------*/
                $rw_align = $this->GetOption($rw_current_settings['align']);
                /* Get show on excerpts option.
                   ---------------------------------------------------------------------------------------------------------------*/
                // Already loaded.
                /* Get rating options.
                   ---------------------------------------------------------------------------------------------------------------*/
                $rw_options = $this->GetOption($rw_current_settings['options']);
            }
            $rw_language_str = isset($rw_options->lng) ? $rw_options->lng : WP_RW__DEFAULT_LNG;
            if (!isset($this->_visibilityList->{$rw_class})) {
                $this->_visibilityList->{$rw_class} = new stdClass();
                $this->_visibilityList->{$rw_class}->selected = 0;
                $this->_visibilityList->{$rw_class}->exclude = '';
                $this->_visibilityList->{$rw_class}->include = '';
            }
            $rw_visibility_settings = $this->_visibilityList->{$rw_class};
            if (!isset($this->availability_list->{$rw_class})) {
                $this->availability_list->{$rw_class} = 0;
            }
            $rw_availability_settings = $this->availability_list->{$rw_class};
            if ($item_with_category) {
                if (!isset($this->categories_list->{$rw_class})) {
                    $this->categories_list->{$rw_class} = array(-1);
                }
                $rw_categories = $this->categories_list->{$rw_class};
            }
            if (!isset($this->custom_settings_enabled_list->{$rw_class})) {
                $this->custom_settings_enabled_list->{$rw_class} = false;
            }
            $rw_custom_settings_enabled = $this->custom_settings_enabled_list->{$rw_class};
            if (!isset($this->custom_settings_list->{$rw_class})) {
                $this->custom_settings_list->{$rw_class} = '';
            }
            $rw_custom_settings = $this->custom_settings_list->{$rw_class};
            $dictionary = array('DUMMY');
            $dir = $hor = 'dummy';
            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';
            global $DEFAULT_OPTIONS;
            rw_set_language_options($DEFAULT_OPTIONS, $dictionary, $dir, $hor);
            $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_once WP_RW__PLUGIN_DIR . '/themes/dir.php';
                global $RW_THEMES;
                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])) {
                    $theme = array('DUMMY');
                    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_languages = $this->languages;
            $this->settings->rating_type = $selected_key;
            $this->settings->options = $rw_options;
            $this->settings->languages = $rw_languages;
            $this->settings->language_str = $rw_language_str;
            $this->settings->categories = $rw_categories;
            $this->settings->availability = $rw_availability_settings;
            $this->settings->visibility = $rw_visibility_settings;
            $this->settings->form_hidden_field_name = $rw_form_hidden_field_name;
            $this->settings->custom_settings_enabled = $rw_custom_settings_enabled;
            $this->settings->custom_settings = $rw_custom_settings;
            // Accumulated user ratings support.
            if ('users' === $selected_key && $this->IsBBPressInstalled()) {
                $this->settings->is_user_accumulated = $rw_is_user_accumulated;
            } else {
                if ('comments' === $selected_key) {
                    // Comment ratings mode support
                    $this->settings->comment_ratings_mode = $comment_ratings_mode;
                }
            }
            ?>
				<div class="wrap rw-dir-ltr rw-wp-container">
					<h2 class="nav-tab-wrapper rw-nav-tab-wrapper">
						<?php 
            foreach ($settings_data as $key => $settings) {
                ?>
							<a href="<?php 
                echo esc_url(add_query_arg(array('rating' => $key, 'message' => false)));
                ?>
"
							   class="nav-tab<?php 
                if ($settings_data[$key] == $rw_current_settings) {
                    echo ' nav-tab-active';
                }
                ?>
"><?php 
                echo $settings['tab'];
                ?>
</a>
						<?php 
            }
            ?>
					</h2>

					<form method="post" action="">
						<div id="poststuff">
							<div id="rw_wp_set">
								<?php 
            rw_require_once_view('preview.php');
            ?>
								<div class="has-sidebar has-right-sidebar">
									<div class="has-sidebar-content">
										<div class="postbox rw-body">
											<?php 
            $enabled = isset($rw_align->ver);
            ?>
											<div style="padding: 10px;">
												<label for="rw_show">
													<input id="rw_show" type="checkbox" name="rw_show"
													       value="true"<?php 
            if ($enabled) {
                echo ' checked="checked"';
            }
            ?>
 onclick="RWM_WP.enable(this);"/> Enable
													for <?php 
            echo $rw_current_settings['tab'];
            ?>
												</label>
												<?php 
            if (true === $rw_current_settings['show_align']) {
                ?>
														<div class="rw-post-rating-align"<?php 
                if (!$enabled) {
                    echo ' style="display: none;"';
                }
                ?>
>
															<?php 
                $vers = array('top', 'bottom');
                $hors = array('left', 'center', 'right');
                ?>
															<select>
																<?php 
                foreach ($vers as $ver) {
                    foreach ($hors as $hor) {
                        $checked = false;
                        if ($enabled) {
                            $checked = $ver == $rw_align->ver && $hor == $rw_align->hor;
                        }
                        ?>
																			<option
																				value="<?php 
                        echo $ver . ' ' . $hor;
                        ?>
"<?php 
                        if ($checked) {
                            echo ' selected="selected"';
                        }
                        ?>
><?php 
                        echo ucwords($ver) . ' ' . ucwords($hor);
                        ?>
</option>
																		<?php 
                    }
                }
                ?>
															</select>
															<input id="rw_align" name="rw_align" type="hidden"
															       value="<?php 
                echo $rw_align->ver . ' ' . $rw_align->hor;
                ?>
">
															<script>
																(function ($) {
																	$('.rw-post-rating-align select').chosen({width: '100%'}).change(function (evt, params) {
																		$('#rw_align').val(params.selected);
																	});
																})(jQuery);
															</script>
														</div>
													<?php 
            }
            ?>
											</div>
										</div>
									</div>
								</div>
								<?php 
            if ('users' === $selected_key) {
                rw_require_once_view('user_rating_type_options.php');
            } else {
                if ('comments' === $selected_key) {
                    rw_require_once_view('comment_rating_mode_options.php');
                }
            }
            rw_require_once_view('options.php');
            rw_require_once_view('availability_options.php');
            rw_require_once_view('visibility_options.php');
            if ($is_blog_post) {
                rw_require_once_view('post_views_visibility.php');
            }
            if ($item_with_category) {
                rw_require_once_view('categories_availability_options.php');
            }
            rw_require_once_view('settings/frequency.php');
            rw_require_once_view('powerusers.php');
            ?>
							</div>
							<div id="rw_wp_set_widgets">
								<?php 
            if ($this->fs->is_not_paying()) {
                // Show random.
                if (0 == rand(0, 1)) {
                    rw_require_once_view('rich-snippets.php');
                } else {
                    rw_require_once_view('upgrade.php');
                }
            }
            ?>
							</div>
						</div>
					</form>
				</div>
				<?php 
            fs_require_template('powered-by.php');
            ?>
				<?php 
            // Store options if in save mode.
            if ($this->settings->IsSaveMode()) {
                $this->_options->store();
            }
        }
Exemple #2
0
        $vars['likes'] = 8;
        $vars['dislikes'] = 3;
        require dirname(dirname(__FILE__)) . "/{$type}_rating.php";
        $selected_theme = $default_theme;
    }
    ?>
        </div>
        <ul id="rw_<?php 
    echo $type;
    ?>
_theme_select_list" class="rw-list" style="display: none;">
        <?php 
    foreach ($type_themes as $theme_name => $data) {
        if ($data['type'] == $type) {
            require WP_RW__PLUGIN_DIR . '/themes/' . $data['file'];
            $options = rw_enrich_options1($theme['options'], $DEFAULT_OPTIONS);
            ?>
            <li class="rw-li<?php 
            if ($selected_theme === $theme_name) {
                echo ' rw-selected';
            }
            ?>
" onclick="jQuery('#rw_<?php 
            echo $type;
            ?>
_theme_selected').html(this.innerHTML); jQuery('#rw_<?php 
            echo $type;
            ?>
_theme_select_list li.rw-li.rw-selected').removeClass('rw-selected'); this.className += ' rw-selected'; RWM.Set.theme('<?php 
            echo $theme_name;
            ?>
function rw_enrich_options1($settings, $defaults, $loadTheme = false, $fromDefaults = false)
{
    $ret = @rw_get_default_value($settings, new stdClass());
    $ret->boost = @rw_get_default_value($settings->boost, new stdClass());
    $ret->imgUrl = @rw_get_default_value($settings->imgUrl, new stdClass());
    $ret->mobile = @rw_get_default_value($settings->mobile, new stdClass());
    $ret->label = @rw_get_default_value($settings->label, new stdClass());
    $ret->label->text = @rw_get_default_value($settings->label->text, new stdClass());
    $ret->label->text->star = @rw_get_default_value($settings->label->text->star, new stdClass());
    $ret->label->text->nero = @rw_get_default_value($settings->label->text->nero, new stdClass());
    $ret->advanced = @rw_get_default_value($settings->advanced, new stdClass());
    $ret->advanced->star = @rw_get_default_value($settings->advanced->star, new stdClass());
    $ret->advanced->nero = @rw_get_default_value($settings->advanced->nero, new stdClass());
    $ret->advanced->nero->text = @rw_get_default_value($settings->advanced->nero->text, new stdClass());
    $ret->advanced->nero->text->like = @rw_get_default_value($settings->advanced->nero->text->like, new stdClass());
    $ret->advanced->nero->text->dislike = @rw_get_default_value($settings->advanced->nero->text->dislike, new stdClass());
    $ret->advanced->font = @rw_get_default_value($settings->advanced->font, new stdClass());
    $ret->advanced->font->hover = @rw_get_default_value($settings->advanced->font->hover, new stdClass());
    $ret->advanced->layout = @rw_get_default_value($settings->advanced->layout, new stdClass());
    $ret->advanced->layout->align = @rw_get_default_value($settings->advanced->layout->align, new stdClass());
    $ret->advanced->text = @rw_get_default_value($settings->advanced->text, new stdClass());
    $ret->advanced->css = @rw_get_default_value($settings->advanced->css, new stdClass());
    if ($fromDefaults) {
        if (isset($settings->size)) {
            require_once dirname(__FILE__) . "/defaults.php";
            global $DEF_FONT_SIZE, $DEF_LINE_HEIGHT;
            $size = strtoupper($settings->size);
            $settings->advanced->font->size = @rw_get_default_value($settings->advanced->font->size, $DEF_FONT_SIZE->{$size});
            $settings->advanced->layout->lineHeight = @rw_get_default_value($settings->advanced->layout->lineHeight, $DEF_LINE_HEIGHT->{$size});
        }
        if (isset($settings->lng)) {
            require RW__PATH_LANGUAGES . $settings->lng . ".php";
            $settings->advanced->layout->dir = @rw_get_default_value($settings->advanced->layout->dir, $dir);
            $settings->advanced->layout->align->hor = @rw_get_default_value($settings->advanced->layout->align->hor, $hor);
            $settings->advanced->text->rateAwful = @rw_get_default_value($settings->advanced->text->rateAwful, $dictionary["rateAwful"]);
            $settings->advanced->text->ratePoor = @rw_get_default_value($settings->advanced->text->ratePoor, $dictionary["ratePoor"]);
            $settings->advanced->text->rateAverage = @rw_get_default_value($settings->advanced->text->rateAverage, $dictionary["rateAverage"]);
            $settings->advanced->text->rateGood = @rw_get_default_value($settings->advanced->text->rateGood, $dictionary["rateGood"]);
            $settings->advanced->text->rateExcellent = @rw_get_default_value($settings->advanced->text->rateExcellent, $dictionary["rateExcellent"]);
            $settings->advanced->text->rateThis = @rw_get_default_value($settings->advanced->text->rateThis, $dictionary["rateThis"]);
            $settings->advanced->text->like = @rw_get_default_value($settings->advanced->text->like, $dictionary["like"]);
            $settings->advanced->text->dislike = @rw_get_default_value($settings->advanced->text->dislike, $dictionary["dislike"]);
            $settings->advanced->text->vote = @rw_get_default_value($settings->advanced->text->vote, $dictionary["vote"]);
            $settings->advanced->text->votes = @rw_get_default_value($settings->advanced->text->votes, $dictionary["votes"]);
            $settings->advanced->text->thanks = @rw_get_default_value($settings->advanced->text->thanks, $dictionary["thanks"]);
            $settings->advanced->text->outOf = @rw_get_default_value($settings->advanced->text->outOf, $dictionary["outOf"]);
            $settings->advanced->text->weRecommend = @rw_get_default_value($settings->advanced->text->weRecommend, $dictionary["weRecommend"]);
        }
    }
    $hasTheme = $loadTheme && isset($settings->theme);
    require_once RW__PATH_THEMES . "dir.php";
    global $RW_THEMES;
    // Get rating type.
    $ret->type = @rw_get_default_value($settings->type, !$hasTheme ? $defaults->type : ($RW_THEMES['star'][$settings->theme] ? 'star' : 'nero'));
    if ($hasTheme) {
        // Load theme options.
        require RW__PATH_THEMES . $RW_THEMES[$ret->type][$settings->theme]["file"];
        return rw_enrich_options1($settings, rw_enrich_options1($theme_options, $defaults));
    }
    $ret->uarid = @rw_get_default_value($settings->uarid, $defaults->uarid);
    $ret->lng = @rw_get_default_value($settings->lng, $defaults->lng);
    $ret->url = @rw_get_default_value($settings->url, $defaults->url);
    $ret->img = @rw_get_default_value($settings->img, $defaults->img);
    $ret->title = @rw_get_default_value($settings->title, $defaults->title);
    $ret->rclass = @rw_get_default_value($settings->rclass, $defaults->rclass);
    $ret->size = @rw_get_default_value($settings->size, $defaults->size);
    $ret->style = @rw_get_default_value($settings->style, $defaults->style);
    $ret->imgUrl->ltr = @rw_get_default_value($settings->imgUrl->ltr, $defaults->imgUrl->ltr);
    $ret->imgUrl->rtl = @rw_get_default_value($settings->imgUrl->rtl, $defaults->imgUrl->rtl);
    $ret->mobile->optimized = @rw_get_default_value($settings->mobile->optimized, $defaults->mobile->optimized);
    $ret->mobile->showTrigger = @rw_get_default_value($settings->mobile->showTrigger, $defaults->mobile->showTrigger);
    $ret->label->background = @rw_get_default_value($settings->label->background, $defaults->label->background);
    $ret->label->text->star->empty = @rw_get_default_value($settings->label->text->star->empty, $defaults->label->text->star->empty);
    $ret->label->text->star->normal = @rw_get_default_value($settings->label->text->star->normal, $defaults->label->text->star->normal);
    $ret->label->text->star->rated = @rw_get_default_value($settings->label->text->star->rated, $defaults->label->text->star->rated);
    $ret->label->text->nero->empty = @rw_get_default_value($settings->label->text->nero->empty, $defaults->label->text->nero->empty);
    $ret->label->text->nero->normal = @rw_get_default_value($settings->label->text->nero->normal, $defaults->label->text->nero->normal);
    $ret->label->text->nero->rated = @rw_get_default_value($settings->label->text->nero->rated, $defaults->label->text->nero->rated);
    $ret->readOnly = @rw_get_default_value($settings->readOnly, $defaults->readOnly);
    $ret->sync = @rw_get_default_value($settings->sync, $defaults->sync);
    $ret->forceSync = @rw_get_default_value($settings->forceSync, $defaults->forceSync);
    $ret->reVote = @rw_get_default_value($settings->reVote, $defaults->reVote);
    $ret->frequency = @rw_get_default_value($settings->frequency, $defaults->frequency);
    $ret->showInfo = @rw_get_default_value($settings->showInfo, $defaults->showInfo);
    $ret->showTooltip = @rw_get_default_value($settings->showTooltip, $defaults->showTooltip);
    $ret->showAverage = @rw_get_default_value($settings->showAverage, $defaults->showAverage);
    $ret->showReport = @rw_get_default_value($settings->showReport, $defaults->showReport);
    $ret->showRecommendations = @rw_get_default_value($settings->showRecommendations, $defaults->showRecommendations);
    $ret->hideRecommendations = @rw_get_default_value($settings->hideRecommendations, $defaults->hideRecommendations);
    $ret->showSponsored = @rw_get_default_value($settings->showSponsored, $defaults->showSponsored);
    $ret->showLoader = @rw_get_default_value($settings->showLoader, $defaults->showLoader);
    $ret->beforeRate = @rw_get_default_value($settings->beforeRate, $defaults->beforeRate);
    $ret->afterRate = @rw_get_default_value($settings->afterRate, $defaults->afterRate);
    $ret->boost->votes = @rw_get_default_value($settings->boost->votes, $defaults->boost->votes);
    $ret->boost->rate = @rw_get_default_value($settings->boost->rate, $defaults->boost->rate);
    $ret->advanced->star->stars = @rw_get_default_value($settings->advanced->star->stars, $defaults->advanced->star->stars);
    $ret->advanced->nero->showDislike = @rw_get_default_value($settings->advanced->nero->showDislike, $defaults->advanced->nero->showDislike);
    $ret->advanced->nero->showLike = @rw_get_default_value($settings->advanced->nero->showLike, $defaults->advanced->nero->showLike);
    $ret->advanced->nero->text->like->empty = @rw_get_default_value($settings->advanced->nero->text->like->empty, $defaults->advanced->nero->text->like->empty);
    $ret->advanced->nero->text->like->rated = @rw_get_default_value($settings->advanced->nero->text->like->rated, $defaults->advanced->nero->text->like->rated);
    $ret->advanced->nero->text->dislike->empty = @rw_get_default_value($settings->advanced->nero->text->dislike->empty, $defaults->advanced->nero->text->dislike->empty);
    $ret->advanced->nero->text->dislike->rated = @rw_get_default_value($settings->advanced->nero->text->dislike->rated, $defaults->advanced->nero->text->dislike->rated);
    $ret->advanced->font->bold = @rw_get_default_value($settings->advanced->font->bold, $defaults->advanced->font->bold);
    $ret->advanced->font->italic = @rw_get_default_value($settings->advanced->font->italic, $defaults->advanced->font->italic);
    $ret->advanced->font->color = @rw_get_default_value($settings->advanced->font->color, $defaults->advanced->font->color);
    $ret->advanced->font->size = @rw_get_default_value($settings->advanced->font->size, $defaults->advanced->font->size);
    $ret->advanced->font->type = @rw_get_default_value($settings->advanced->font->type, $defaults->advanced->font->type);
    $ret->advanced->font->hover->color = @rw_get_default_value($settings->advanced->font->hover->color, $defaults->advanced->font->hover->color);
    $ret->advanced->layout->dir = @rw_get_default_value($settings->advanced->layout->dir, $defaults->advanced->layout->dir);
    $ret->advanced->layout->lineHeight = @rw_get_default_value($settings->advanced->layout->lineHeight, $defaults->advanced->layout->lineHeight);
    $ret->advanced->layout->align->hor = @rw_get_default_value($settings->advanced->layout->align->hor, $defaults->advanced->layout->align->hor);
    $ret->advanced->layout->align->ver = @rw_get_default_value($settings->advanced->layout->align->ver, $defaults->advanced->layout->align->ver);
    $ret->advanced->text->rateAwful = @rw_get_default_value($settings->advanced->text->rateAwful, $defaults->advanced->text->rateAwful);
    $ret->advanced->text->ratePoor = @rw_get_default_value($settings->advanced->text->ratePoor, $defaults->advanced->text->ratePoor);
    $ret->advanced->text->rateAverage = @rw_get_default_value($settings->advanced->text->rateAverage, $defaults->advanced->text->rateAverage);
    $ret->advanced->text->rateGood = @rw_get_default_value($settings->advanced->text->rateGood, $defaults->advanced->text->rateGood);
    $ret->advanced->text->rateExcellent = @rw_get_default_value($settings->advanced->text->rateExcellent, $defaults->advanced->text->rateExcellent);
    $ret->advanced->text->rateThis = @rw_get_default_value($settings->advanced->text->rateThis, $defaults->advanced->text->rateThis);
    $ret->advanced->text->like = @rw_get_default_value($settings->advanced->text->like, $defaults->advanced->text->like);
    $ret->advanced->text->dislike = @rw_get_default_value($settings->advanced->text->dislike, $defaults->advanced->text->dislike);
    $ret->advanced->text->vote = @rw_get_default_value($settings->advanced->text->vote, $defaults->advanced->text->vote);
    $ret->advanced->text->votes = @rw_get_default_value($settings->advanced->text->votes, $defaults->advanced->text->votes);
    $ret->advanced->text->thanks = @rw_get_default_value($settings->advanced->text->thanks, $defaults->advanced->text->thanks);
    $ret->advanced->text->outOf = @rw_get_default_value($settings->advanced->text->outOf, $defaults->advanced->text->outOf);
    $ret->advanced->text->weRecommend = @rw_get_default_value($settings->advanced->text->weRecommend, $defaults->advanced->text->weRecommend);
    $ret->advanced->css->container = @rw_get_default_value($settings->advanced->css->container, $defaults->advanced->css->container);
    return $ret;
}
        $vars["likes"] = 8;
        $vars["dislikes"] = 3;
        require dirname(dirname(__FILE__)) . "/{$type}_rating.php";
        $selected_theme = $default_theme;
    }
    ?>
				</div>
				<ul id="rw_<?php 
    echo $type;
    ?>
_theme_select_list" class="rw-list" style="display: none;">
					<?php 
    foreach ($type_themes as $theme_name => $data) {
        if ($data["type"] == $type) {
            require WP_RW__PLUGIN_DIR . "/themes/" . $data["file"];
            $options = rw_enrich_options1($theme["options"], $DEFAULT_OPTIONS);
            ?>
								<li class="rw-li<?php 
            if ($selected_theme === $theme_name) {
                echo " rw-selected";
            }
            ?>
"
								    onclick="jQuery('#rw_<?php 
            echo $type;
            ?>
_theme_selected').html(this.innerHTML); jQuery('#rw_<?php 
            echo $type;
            ?>
_theme_select_list li.rw-li.rw-selected').removeClass('rw-selected'); this.className += ' rw-selected'; RWM.Set.theme('<?php 
            echo $theme_name;
Exemple #5
0
        /**
         * To get a list of all custom user defined posts:
         *   
         *       get_post_types(array('public'=>true,'_builtin' => false))
         */
        public function SettingsPage()
        {
            // Must check that the user has the required capability.
            if (!current_user_can('manage_options')) {
                wp_die(__('You do not have sufficient permissions to access this page.', WP_RW__ID));
            }
            global $plugin_page;
            // Variables for the field and option names
            $rw_form_hidden_field_name = "rw_form_hidden_field_name";
            if ($plugin_page === $this->GetMenuSlug('buddypress') && $this->IsBuddyPressInstalled()) {
                $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), "users" => array("tab" => "Users Profiles", "class" => "user", "options" => WP_RW__USERS_OPTIONS, "align" => WP_RW__USERS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_ALIGN], "excerpt" => false, "show_align" => false));
                $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "activity-blog-posts";
                if (!isset($settings_data[$selected_key])) {
                    $selected_key = "activity-blog-posts";
                }
            } else {
                if ($plugin_page === $this->GetMenuSlug('bbpress') && $this->IsBBPressInstalled()) {
                    $settings_data = array("forum-posts" => array("tab" => "Forum Posts", "class" => "forum-post", "options" => WP_RW__FORUM_POSTS_OPTIONS, "align" => WP_RW__FORUM_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__FORUM_POSTS_ALIGN], "excerpt" => false, "show_align" => true), "activity-forum-posts" => array("tab" => "Activity Forum Posts", "class" => "new-forum-post", "options" => WP_RW__ACTIVITY_FORUM_POSTS_OPTIONS, "align" => WP_RW__ACTIVITY_FORUM_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__ACTIVITY_FORUM_POSTS_ALIGN], "excerpt" => false, "show_align" => true), "users" => array("tab" => "Users Profiles", "class" => "user", "options" => WP_RW__USERS_OPTIONS, "align" => WP_RW__USERS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_ALIGN], "excerpt" => false, "show_align" => false));
                    $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "forum-posts";
                    if (!isset($settings_data[$selected_key])) {
                        $selected_key = "forum-posts";
                    }
                } else {
                    if ($plugin_page === $this->GetMenuSlug('user')) {
                        $settings_data = array("users-posts" => array("tab" => "Posts", "class" => "user-post", "options" => WP_RW__USERS_POSTS_OPTIONS, "align" => WP_RW__USERS_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_POSTS_ALIGN], "excerpt" => false, "show_align" => false), "users-pages" => array("tab" => "Pages", "class" => "user-page", "options" => WP_RW__USERS_PAGES_OPTIONS, "align" => WP_RW__USERS_PAGES_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_PAGES_ALIGN], "excerpt" => false, "show_align" => false), "users-comments" => array("tab" => "Comments", "class" => "user-comment", "options" => WP_RW__USERS_COMMENTS_OPTIONS, "align" => WP_RW__USERS_COMMENTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_COMMENTS_ALIGN], "excerpt" => false, "show_align" => false));
                        if ($this->IsBuddyPressInstalled()) {
                            $settings_data["users-activity-updates"] = array("tab" => "Activity Updates", "class" => "user-activity-update", "options" => WP_RW__USERS_ACTIVITY_UPDATES_OPTIONS, "align" => WP_RW__USERS_ACTIVITY_UPDATES_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_ACTIVITY_UPDATES_ALIGN], "excerpt" => false, "show_align" => false);
                            $settings_data["users-activity-comments"] = array("tab" => "Activity Comments", "class" => "user-activity-comment", "options" => WP_RW__USERS_ACTIVITY_COMMENTS_OPTIONS, "align" => WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN], "excerpt" => false, "show_align" => false);
                            if ($this->IsBBPressInstalled()) {
                                $settings_data["users-forum-posts"] = array("tab" => "Forum Posts", "class" => "user-forum-post", "options" => WP_RW__USERS_FORUM_POSTS_OPTIONS, "align" => WP_RW__USERS_FORUM_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_FORUM_POSTS_ALIGN], "excerpt" => false, "show_align" => false);
                            }
                        }
                        $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "users-posts";
                        if (!isset($settings_data[$selected_key])) {
                            $selected_key = "users-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" => false, "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" => false, "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];
            $is_blog_post = 'blog-post' === $rw_current_settings['class'];
            $item_with_category = in_array($rw_current_settings['class'], array('blog-post', 'front-post', 'comment'));
            // 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->_visibilityList = json_decode($this->GetOption(WP_RW__VISIBILITY_SETTINGS));
            if ($item_with_category) {
                // Categories Availability list must be loaded anyway.
                $this->categories_list = json_decode($this->GetOption(WP_RW__CATEGORIES_AVAILABILITY_SETTINGS));
            }
            // Availability list must be loaded anyway.
            $this->availability_list = json_decode($this->GetOption(WP_RW__AVAILABILITY_SETTINGS));
            $this->custom_settings_enabled_list = json_decode($this->GetOption(WP_RW__CUSTOM_SETTINGS_ENABLED));
            $this->custom_settings_list = json_decode($this->GetOption(WP_RW__CUSTOM_SETTINGS));
            // Accumulated user ratings support.
            if ('users' === $selected_key && $this->IsBBPressInstalled()) {
                $rw_is_user_accumulated = $this->GetOption(WP_RW__IS_ACCUMULATED_USER_RATING);
            }
            // 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') {
                // Set settings into save mode.
                $this->settings->SetSaveMode();
                /* 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);
                /* Rating-Widget options.
                   ---------------------------------------------------------------------------------------------------------------*/
                $rw_options_str = preg_replace('/\\%u([0-9A-F]{4})/i', '\\u$1', urldecode(stripslashes($_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));
                if ($item_with_category) {
                    /* Categories Availability settings.
                       ---------------------------------------------------------------------------------------------------------------*/
                    $rw_categories = isset($_POST["rw_categories"]) && is_array($_POST["rw_categories"]) ? $_POST["rw_categories"] : array();
                    $this->categories_list->{$rw_class} = in_array("-1", $rw_categories) ? array("-1") : $rw_categories;
                    $this->SetOption(WP_RW__CATEGORIES_AVAILABILITY_SETTINGS, json_encode($this->categories_list));
                }
                // Accumulated user ratings support.
                if ('users' === $selected_key && $this->IsBBPressInstalled() && isset($_POST['rw_accumulated_user_rating'])) {
                    $rw_is_user_accumulated = in_array($_POST['rw_accumulated_user_rating'], array('true', 'false')) ? $_POST['rw_accumulated_user_rating'] : 'true';
                    $this->SetOption(WP_RW__IS_ACCUMULATED_USER_RATING, $rw_is_user_accumulated);
                }
                /* 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"] : "";
                $rw_custom_settings_enabled = isset($_POST["rw_custom_settings_enabled"]) ? true : false;
                $this->custom_settings_enabled_list->{$rw_class} = $rw_custom_settings_enabled;
                $this->SetOption(WP_RW__CUSTOM_SETTINGS_ENABLED, json_encode($this->custom_settings_enabled_list));
                $rw_custom_settings = isset($_POST["rw_custom_settings"]) ? $_POST["rw_custom_settings"] : '';
                $this->custom_settings_list->{$rw_class} = $rw_custom_settings;
                $this->SetOption(WP_RW__CUSTOM_SETTINGS, json_encode($this->custom_settings_list));
                $this->_visibilityList->{$rw_class}->selected = $rw_visibility;
                $this->_visibilityList->{$rw_class}->exclude = self::IDsCollectionToArray($rw_visibility_exclude);
                $this->_visibilityList->{$rw_class}->include = self::IDsCollectionToArray($rw_visibility_include);
                $this->SetOption(WP_RW__VISIBILITY_SETTINGS, json_encode($this->_visibilityList));
                ?>
    <div class="updated"><p><strong><?php 
                _e('settings saved.', WP_RW__ID);
                ?>
</strong></p></div>
    <?php 
            } else {
                /* Get rating alignment.
                   ---------------------------------------------------------------------------------------------------------------*/
                $rw_align_str = $this->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->_visibilityList->{$rw_class})) {
                $this->_visibilityList->{$rw_class} = new stdClass();
                $this->_visibilityList->{$rw_class}->selected = 0;
                $this->_visibilityList->{$rw_class}->exclude = "";
                $this->_visibilityList->{$rw_class}->include = "";
            }
            $rw_visibility_settings = $this->_visibilityList->{$rw_class};
            if (!isset($this->availability_list->{$rw_class})) {
                $this->availability_list->{$rw_class} = 0;
            }
            $rw_availability_settings = $this->availability_list->{$rw_class};
            if ($item_with_category) {
                if (!isset($this->categories_list->{$rw_class})) {
                    $this->categories_list->{$rw_class} = array(-1);
                }
                $rw_categories = $this->categories_list->{$rw_class};
            }
            if (!isset($this->custom_settings_enabled_list->{$rw_class})) {
                $this->custom_settings_enabled_list->{$rw_class} = false;
            }
            $rw_custom_settings_enabled = $this->custom_settings_enabled_list->{$rw_class};
            if (!isset($this->custom_settings_list->{$rw_class})) {
                $this->custom_settings_list->{$rw_class} = '';
            }
            $rw_custom_settings = $this->custom_settings_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_once WP_RW__PLUGIN_DIR . "/themes/dir.php";
                global $RW_THEMES;
                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;
            $this->settings->rating_type = $selected_key;
            $this->settings->options = $rw_options;
            $this->settings->languages = $rw_languages;
            $this->settings->language_str = $rw_language_str;
            $this->settings->categories = $rw_categories;
            $this->settings->availability = $rw_availability_settings;
            $this->settings->visibility = $rw_visibility_settings;
            $this->settings->form_hidden_field_name = $rw_form_hidden_field_name;
            $this->settings->custom_settings_enabled = $rw_custom_settings_enabled;
            $this->settings->custom_settings = $rw_custom_settings;
            // Accumulated user ratings support.
            if ('users' === $selected_key && $this->IsBBPressInstalled()) {
                $this->settings->is_user_accumulated = 'true' === $rw_is_user_accumulated;
            }
            ?>
<div class="wrap rw-dir-ltr rw-wp-container">
    <h2><?php 
            echo __('Rating-Widget Settings', WP_RW__ID);
            ?>
</h2>
    <!--<div class="widget-liquid-left widgets-sortables">
        <div id="widgets-left">
            <div class="widgets-holder-wrap ui-droppable">
                <div class="sidebar-name">
                    <div class="sidebar-name-arrow"><br></div>
                    <h3>Available Widgets <span id="removing-widget">Deactivate <span></span></span></h3>
                </div>
                <div class="widget-holder">
                    <p class="description">Drag widgets from here to a sidebar on the right to activate them. Drag widgets back here to deactivate them and delete their settings.</p>
                </div>
                <br class="clear">
            </div>
        </div>
    </div>
    <div class="widget-liquid-right">
        <div id="widgets-right">
            <div class="widgets-holder-wrap ui-droppable">
                <?php 
            //require_once(dirname(__FILE__) . "/view/twitter.php");
            ?>
            </div>
        </div>
    </div>-->
    
    <form method="post" action="">
        <div id="poststuff">       
            <div id="rw_wp_set">
                <?php 
            rw_require_once_view('preview.php');
            ?>
                <div id="side-sortables"> 
                    <div id="categorydiv" class="categorydiv">
                        <ul id="category-tabs" class="category-tabs">
                            <?php 
            foreach ($settings_data as $key => $settings) {
                if ($settings_data[$key] == $rw_current_settings) {
                    ?>
                                    <li class="tabs"><?php 
                    echo _e($settings["tab"], WP_RW__ID);
                    ?>
</li>
                                <?php 
                } else {
                    ?>
                                    <li><a href="<?php 
                    echo esc_url(add_query_arg(array('rating' => $key, 'message' => false)));
                    ?>
"><?php 
                    echo _e($settings["tab"], WP_RW__ID);
                    ?>
</a></li>
                                <?php 
                }
            }
            ?>
                        </ul>
                        <div class="tabs-panel rw-body" id="categories-all">
                            <?php 
            $enabled = isset($rw_align->ver);
            ?>
                            <div class="rw-ui-light-bkg">
                                <label for="rw_show">
                                    <input id="rw_show" type="checkbox" name="rw_show" value="true"<?php 
            if ($enabled) {
                echo ' checked="checked"';
            }
            ?>
 onclick="RWM_WP.enable(this);" /> Enable for <?php 
            echo $rw_current_settings["tab"];
            ?>
                                </label>
                            <?php 
            if (true === $rw_current_settings["show_align"]) {
                ?>
                                <div class="rw-post-rating-align">
                                    <div class="rw-ui-disabled"<?php 
                if ($enabled) {
                    echo ' style="display: none;"';
                }
                ?>
></div>
                                <?php 
                $vers = array("top", "bottom");
                $hors = array("left", "center", "right");
                foreach ($vers as $ver) {
                    ?>
                                    <div style="height: 89px; padding: 5px;">
                                <?php 
                    foreach ($hors as $hor) {
                        $checked = false;
                        if ($enabled) {
                            $checked = $ver == $rw_align->ver && $hor == $rw_align->hor;
                        }
                        ?>
                                        <div class="rw-ui-img-radio<?php 
                        if ($checked) {
                            echo ' rw-selected';
                        }
                        ?>
">
                                            <i class="rw-ui-holder"><i class="rw-ui-sprite rw-ui-post-<?php 
                        echo $ver . $hor;
                        ?>
"></i></i>
                                            <span><?php 
                        echo ucwords($ver) . ucwords($hor);
                        ?>
</span>
                                            <input type="radio" name="rw_align" value="<?php 
                        echo $ver . " " . $hor;
                        ?>
"<?php 
                        if ($checked) {
                            echo ' checked="checked"';
                        }
                        ?>
 />
                                        </div>
                                <?php 
                    }
                    ?>
                                    </div>
                                <?php 
                }
                ?>
                                </div>
                            <?php 
            }
            ?>
                            </div>
                        </div>
                    </div>
                </div>
                <br />
                <?php 
            if ('users' === $selected_key) {
                rw_require_once_view('user_rating_type_options.php');
            }
            rw_require_once_view('options.php');
            rw_require_once_view('availability_options.php');
            rw_require_once_view('visibility_options.php');
            if ($is_blog_post) {
                rw_require_once_view('post_views_visibility.php');
            }
            if ($item_with_category) {
                rw_require_once_view('categories_availability_options.php');
            }
            rw_require_once_view('settings/frequency.php');
            rw_require_once_view('powerusers.php');
            ?>
            </div>
            <div id="rw_wp_set_widgets">
                <?php 
            if (false === WP_RW__USER_SECRET) {
                rw_require_once_view('upgrade.php');
            }
            ?>
                <?php 
            rw_require_once_view('fb.php');
            ?>
                <?php 
            rw_require_once_view('twitter.php');
            ?>
            </div>
        </div>
    </form>
    <div class="rw-body">
    <?php 
            rw_include_once_view('settings/custom_color.php');
            ?>
    </div>
</div>

<?php 
        }
    function rw_settings_page()
    {
        // Must check that the user has the required capability.
        if (!current_user_can('manage_options')) {
            wp_die(__('You do not have sufficient permissions to access this page.', WP_RW__ID));
        }
        $action = isset($_REQUEST["action"]) ? $_REQUEST["action"] : false;
        if ($action == "reports") {
            if (false === WP_RW__USER_SECRET) {
                $this->rw_report_example_page();
            } else {
                if (isset($_GET["urid"]) && is_numeric($_GET["urid"])) {
                    $this->rw_rating_report_page();
                } else {
                    if (isset($_GET["ip"]) || isset($_GET["vid"]) || isset($_GET["pcid"])) {
                        $this->rw_explicit_report_page();
                    } else {
                        $this->rw_general_report_page();
                    }
                }
            }
            //            if (RWLogger::IsOn())
            //            {
            echo "\n<!-- RATING-WIDGET LOG START\n\n";
            RWLogger::Output("    ");
            echo "\n RATING-WIDGET LOG END-->\n";
            //            }
            return;
        } else {
            if ($action == "advanced") {
                $this->rw_advanced_settings_page();
                if (RWLogger::IsOn()) {
                    echo "\n<!-- RATING-WIDGET LOG START\n\n";
                    RWLogger::Output("    ");
                    echo "\n RATING-WIDGET LOG END-->\n";
                }
                return;
            } else {
                if ($action == "boost") {
                    if (false !== WP_RW__USER_SECRET) {
                        $this->rw_boost_page();
                    }
                    return;
                }
            }
        }
        // Variables for the field and option names
        $rw_form_hidden_field_name = "rw_form_hidden_field_name";
        if ($action === "buddypress" && self::$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), "users" => array("tab" => "Users Profiles", "class" => "user", "options" => WP_RW__USERS_OPTIONS, "align" => WP_RW__USERS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_ALIGN], "excerpt" => false, "show_align" => false));
            $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "activity-blog-posts";
            if (!isset($settings_data[$selected_key])) {
                $selected_key = "activity-blog-posts";
            }
        } else {
            if ($action === "bbpress" && defined('WP_RW__BBP_INSTALLED') && is_plugin_active(WP_RW__BP_CORE_FILE)) {
                $settings_data = array("forum-posts" => array("tab" => "Forum Posts", "class" => "forum-post", "options" => WP_RW__FORUM_POSTS_OPTIONS, "align" => WP_RW__FORUM_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__FORUM_POSTS_ALIGN], "excerpt" => false, "show_align" => true), "activity-forum-posts" => array("tab" => "Activity Forum Posts", "class" => "new-forum-post", "options" => WP_RW__ACTIVITY_FORUM_POSTS_OPTIONS, "align" => WP_RW__ACTIVITY_FORUM_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__ACTIVITY_FORUM_POSTS_ALIGN], "excerpt" => false, "show_align" => true));
                $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "forum-posts";
                if (!isset($settings_data[$selected_key])) {
                    $selected_key = "forum-posts";
                }
            } else {
                if ($action === "user") {
                    $settings_data = array("users-posts" => array("tab" => "Posts", "class" => "user-post", "options" => WP_RW__USERS_POSTS_OPTIONS, "align" => WP_RW__USERS_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_POSTS_ALIGN], "excerpt" => false, "show_align" => false), "users-pages" => array("tab" => "Pages", "class" => "user-page", "options" => WP_RW__USERS_PAGES_OPTIONS, "align" => WP_RW__USERS_PAGES_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_PAGES_ALIGN], "excerpt" => false, "show_align" => false), "users-comments" => array("tab" => "Comments", "class" => "user-comment", "options" => WP_RW__USERS_COMMENTS_OPTIONS, "align" => WP_RW__USERS_COMMENTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_COMMENTS_ALIGN], "excerpt" => false, "show_align" => false));
                    if (self::$WP_RW__BP_INSTALLED && is_plugin_active(WP_RW__BP_CORE_FILE)) {
                        $settings_data["users-activity-updates"] = array("tab" => "Activity Updates", "class" => "user-activity-update", "options" => WP_RW__USERS_ACTIVITY_UPDATES_OPTIONS, "align" => WP_RW__USERS_ACTIVITY_UPDATES_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_ACTIVITY_UPDATES_ALIGN], "excerpt" => false, "show_align" => false);
                        $settings_data["users-activity-comments"] = array("tab" => "Activity Comments", "class" => "user-activity-comment", "options" => WP_RW__USERS_ACTIVITY_COMMENTS_OPTIONS, "align" => WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_ACTIVITY_COMMENTS_ALIGN], "excerpt" => false, "show_align" => false);
                        if (defined('WP_RW__BBP_INSTALLED')) {
                            $settings_data["users-forum-posts"] = array("tab" => "Forum Posts", "class" => "user-forum-post", "options" => WP_RW__USERS_FORUM_POSTS_OPTIONS, "align" => WP_RW__USERS_FORUM_POSTS_ALIGN, "default_align" => self::$OPTIONS_DEFAULTS[WP_RW__USERS_FORUM_POSTS_ALIGN], "excerpt" => false, "show_align" => false);
                        }
                    }
                    $selected_key = isset($_GET["rating"]) ? $_GET["rating"] : "users-posts";
                    if (!isset($settings_data[$selected_key])) {
                        $selected_key = "users-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));
        // Categories Availability list must be loaded anyway.
        $this->categories_list = json_decode($this->_getOption(WP_RW__CATEGORIES_AVAILABILITY_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));
            /* Categories Availability settings.
               ---------------------------------------------------------------------------------------------------------------*/
            $rw_categories = isset($_POST["rw_categories"]) ? $_POST["rw_categories"] : array();
            $this->categories_list->{$rw_class} = in_array("-1", $_POST["rw_categories"]) ? array("-1") : $rw_categories;
            $this->_setOption(WP_RW__CATEGORIES_AVAILABILITY_SETTINGS, json_encode($this->categories_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));
            ?>
    <div class="updated"><p><strong><?php 
            _e('settings saved.', WP_RW__ID);
            ?>
</strong></p></div>
    <?php 
        } else {
            /* Get rating alignment.
               ---------------------------------------------------------------------------------------------------------------*/
            $rw_align_str = $this->_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->categories_list->{$rw_class})) {
            $this->categories_list->{$rw_class} = array(-1);
        }
        $rw_categories = $this->categories_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;
        ?>
<div class="wrap rw-dir-ltr">
    <h2><?php 
        echo __('Rating-Widget Settings', WP_RW__ID);
        ?>
</h2>
    <form method="post" action="">
        <div id="poststuff">       
            <div style="float: left;">
                <div id="side-sortables"> 
                    <div id="categorydiv" class="categorydiv">
                        <ul id="category-tabs" class="category-tabs" style="height: 21px;">
                            <?php 
        foreach ($settings_data as $key => $settings) {
            if ($settings_data[$key] == $rw_current_settings) {
                ?>
                                    <li class="tabs" style="float: left;"><?php 
                echo _e($settings["tab"], WP_RW__ID);
                ?>
</li>
                                <?php 
            } else {
                ?>
                                    <li style="float: left;"><a href="<?php 
                echo esc_url(add_query_arg(array('rating' => $key, 'message' => false)));
                ?>
"><?php 
                echo _e($settings["tab"], WP_RW__ID);
                ?>
</a></li>
                                <?php 
            }
        }
        ?>
                        </ul>
                        <div class="tabs-panel rw-body" id="categories-all" style="background: white; height: auto; overflow: visible; width: 602px;">
                            <?php 
        $enabled = isset($rw_align->ver);
        ?>
                            <div class="rw-ui-content-container rw-ui-light-bkg" style="width: 580px; margin: 10px 0 10px 0;">
                                <label for="rw_show">
                                    <input id="rw_show" type="checkbox" name="rw_show" value="true"<?php 
        if ($enabled) {
            echo ' checked="checked"';
        }
        ?>
 onclick="RWM_WP.enable(this);" /> Enable for <?php 
        echo $rw_current_settings["tab"];
        ?>
                                </label>
                            <?php 
        if (true === $rw_current_settings["show_align"]) {
            ?>
                                <br />
                                <div class="rw-post-rating-align" style="height: 220px;">
                                    <div class="rw-ui-disabled"<?php 
            if ($enabled) {
                echo ' style="display: none;"';
            }
            ?>
></div>
                                <?php 
            $vers = array("top", "bottom");
            $hors = array("left", "center", "right");
            foreach ($vers as $ver) {
                ?>
                                    <div style="height: 89px; padding: 5px;">
                                <?php 
                foreach ($hors as $hor) {
                    $checked = false;
                    if ($enabled) {
                        $checked = $ver == $rw_align->ver && $hor == $rw_align->hor;
                    }
                    ?>
                                        <div class="rw-ui-img-radio<?php 
                    if ($checked) {
                        echo ' rw-selected';
                    }
                    ?>
">
                                            <i class="rw-ui-holder"><i class="rw-ui-sprite rw-ui-post-<?php 
                    echo $ver . $hor;
                    ?>
"></i></i>
                                            <span><?php 
                    echo ucwords($ver) . ucwords($hor);
                    ?>
</span>
                                            <input type="radio" name="rw_align" value="<?php 
                    echo $ver . " " . $hor;
                    ?>
"<?php 
                    if ($checked) {
                        echo ' checked="checked"';
                    }
                    ?>
 />
                                        </div>
                                <?php 
                }
                ?>
                                    </div>
                                <?php 
            }
            if (true === $rw_current_settings["excerpt"]) {
                ?>
                                    <label for="rw_show_excerpt" style="margin-left: 20px; font-weight: bold;">
                                        <input id="rw_show_excerpt" type="checkbox" name="rw_show_excerpt" value="true"<?php 
                if ($rw_show_on_excerpts) {
                    echo ' checked="checked"';
                }
                ?>
 /> Show on excerpts as well.
                                    </label>
                                <?php 
            }
            ?>
                                </label>
                                </div>
                            <?php 
        }
        ?>
                            </div>
                        </div>
                    </div>
                </div>
                <br />
                <?php 
        require_once dirname(__FILE__) . "/view/options.php";
        ?>
                <?php 
        require_once dirname(__FILE__) . "/view/availability_options.php";
        ?>
                <?php 
        require_once dirname(__FILE__) . "/view/visibility_options.php";
        ?>
                <?php 
        require_once dirname(__FILE__) . "/view/categories_availability_options.php";
        ?>
            </div>
            <div id="rw_floating_container">
                <?php 
        require_once dirname(__FILE__) . "/view/preview.php";
        ?>
                <?php 
        // require_once(dirname(__FILE__) . "/view/save.php");
        ?>
            </div>
            <div style="margin-left: 650px; padding-top: 215px; width: 350px; padding-right: 20px;">
                <?php 
        require_once dirname(__FILE__) . "/view/twitter.php";
        ?>
                <?php 
        require_once dirname(__FILE__) . "/view/fb.php";
        ?>
                <?php 
        require_once dirname(__FILE__) . "/view/sponsor.php";
        ?>
            </div>
        </div>
    </form>
    <div class="rw-body">
    <?php 
        include_once WP_RW__PLUGIN_DIR . "/view/settings/custom_color.php";
        ?>
    </div>
</div>

<?php 
    }