Example #1
0
function wp_rp_update_related_posts_callback()
{
    check_ajax_referer('wp_rp_ajax_nonce');
    if (!current_user_can('edit_posts')) {
        die('error');
    }
    $options = wp_rp_get_options();
    if (!isset($_POST['related_posts']) || !isset($_POST['post_id'])) {
        die('error');
    }
    global $wpdb;
    $post_id = intval(stripslashes($_POST['post_id']));
    $articles_json = stripslashes($_POST['related_posts']);
    if ($articles_json) {
        $articles = json_decode($articles_json);
    } else {
        $articles = '';
    }
    update_post_meta($post_id, '_wp_rp_selected_related_posts', $articles);
    delete_post_meta($post_id, '_wp_rp_related_posts_query_result_cache_' . $options['max_related_posts']);
    // Delete existing caches upon update, so that the new recs get calculated
    die('ok');
}
function wp_rp_display_dashboard_widget()
{
    $options = wp_rp_get_options();
    $meta = wp_rp_get_meta();
    ?>
	<input type="hidden" id="wp_rp_dashboard_url" value="<?php 
    esc_attr_e(WP_RP_CTR_DASHBOARD_URL);
    ?>
" />
	<input type="hidden" id="wp_rp_static_base_url" value="<?php 
    esc_attr_e(WP_RP_STATIC_BASE_URL);
    ?>
" />
	<input type="hidden" id="wp_rp_blog_id" value="<?php 
    esc_attr_e($meta['blog_id']);
    ?>
" />
	<input type="hidden" id="wp_rp_auth_key" value="<?php 
    esc_attr_e($meta['auth_key']);
    ?>
" />
	<?php 
    if ($meta['show_traffic_exchange'] && $options['traffic_exchange_enabled']) {
        ?>
	<input type="hidden" id="wp_rp_show_traffic_exchange_statistics" value="1" />
	<?php 
    }
    ?>

	<div id="wp_rp_wrap" class="wp_rp_dashboard">
		<?php 
    wp_rp_print_notifications();
    ?>
		<div id="wp_rp_statistics_wrap"></div>
	</div>
<?php 
}
function wp_rp_activate_hook()
{
    wp_rp_get_options();
    wp_rp_schedule_notifications_cron();
}
Example #4
0
function wp_rp_fetch_random_posts($limit = 10, $exclude_ids = array())
{
    global $wpdb, $post;
    $options = wp_rp_get_options();
    $exclude_ids_str = wp_rp_get_exclude_ids_list_string($exclude_ids);
    $q1 = "SELECT ID FROM {$wpdb->posts} posts WHERE post_status = 'publish' AND post_type = 'post' AND ID NOT IN ({$exclude_ids_str})";
    if ($options['exclude_categories']) {
        $q1 .= " AND ID NOT IN (SELECT tr.object_id FROM {$wpdb->term_taxonomy} tt, {$wpdb->term_relationships} tr WHERE tt.taxonomy = 'category' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tt.term_id IN (" . $options['exclude_categories'] . "))";
    }
    if ($options['max_related_post_age_in_days'] > 0) {
        $q1 .= " AND post_date > DATE_SUB(CURDATE(), INTERVAL " . $options['max_related_post_age_in_days'] . " DAY)";
    }
    $ids = $wpdb->get_col($q1, 0);
    $count = count($ids);
    if ($count === 0) {
        return false;
        /*} else if($count === 1) {
        		$rnd = $ids;*/
    } else {
        if ($count > 1) {
            $display_number = min($limit, $count);
            $next_seed = rand();
            $t = time();
            $seed = $t - $t % 300 + $post->ID << 4;
            // We keep the same seed for 5 minutes, so MySQL can cache the `q2` query.
            srand($seed);
            shuffle($ids);
            $ids = array_slice($ids, 0, $display_number);
            srand($next_seed);
        }
    }
    $q2 = "SELECT ID, post_title, post_content, post_excerpt, post_date, comment_count FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' AND ID IN (" . implode(',', $ids) . ")";
    $results = $wpdb->get_results($q2);
    asort($ids);
    $ids_keys = array_keys($ids);
    array_multisort($ids_keys, $results);
    return $results;
}
Example #5
0
function wp_rp_settings_page()
{
    if (!current_user_can('delete_users')) {
        die('Sorry, you don\'t have permissions to access this page.');
    }
    wp_rp_register();
    $options = wp_rp_get_options();
    $meta = wp_rp_get_meta();
    // Update already subscribed but in the old pipeline
    if (!empty($meta["email"]) && empty($meta["subscribed"])) {
        wp_rp_subscription($meta["email"], $options["subscription_types"]);
    }
    if (isset($_GET['wprp_global_notice']) && $_GET['wprp_global_notice'] === '0') {
        $meta['global_notice'] = null;
        wp_rp_update_meta($meta);
    }
    $postdata = stripslashes_deep($_POST);
    if (sizeof($_POST)) {
        if (!isset($_POST['_wp_rp_nonce']) || !wp_verify_nonce($_POST['_wp_rp_nonce'], 'wp_rp_settings')) {
            die('Sorry, your nonce did not verify.');
        }
        $old_options = $options;
        $new_options = array('on_single_post' => isset($postdata['wp_rp_on_single_post']), 'max_related_posts' => isset($postdata['wp_rp_max_related_posts']) && is_numeric(trim($postdata['wp_rp_max_related_posts'])) ? intval(trim($postdata['wp_rp_max_related_posts'])) : 5, 'on_rss' => isset($postdata['wp_rp_on_rss']), 'related_posts_title' => isset($postdata['wp_rp_related_posts_title']) ? trim($postdata['wp_rp_related_posts_title']) : '', 'promoted_content_enabled' => isset($postdata['wp_rp_promoted_content_enabled']), 'enable_themes' => isset($postdata['wp_rp_enable_themes']), 'max_related_post_age_in_days' => isset($postdata['wp_rp_max_related_post_age_in_days']) && is_numeric(trim($postdata['wp_rp_max_related_post_age_in_days'])) ? intval(trim($postdata['wp_rp_max_related_post_age_in_days'])) : 0, 'custom_size_thumbnail_enabled' => isset($postdata['wp_rp_custom_size_thumbnail_enabled']) && $postdata['wp_rp_custom_size_thumbnail_enabled'] === 'yes', 'custom_thumbnail_width' => isset($postdata['wp_rp_custom_thumbnail_width']) ? intval(trim($postdata['wp_rp_custom_thumbnail_width'])) : WP_RP_CUSTOM_THUMBNAILS_WIDTH, 'custom_thumbnail_height' => isset($postdata['wp_rp_custom_thumbnail_height']) ? intval(trim($postdata['wp_rp_custom_thumbnail_height'])) : WP_RP_CUSTOM_THUMBNAILS_HEIGHT, 'thumbnail_use_custom' => isset($postdata['wp_rp_thumbnail_use_custom']) && $postdata['wp_rp_thumbnail_use_custom'] === 'yes', 'thumbnail_custom_field' => isset($postdata['wp_rp_thumbnail_custom_field']) ? trim($postdata['wp_rp_thumbnail_custom_field']) : '', 'display_zemanta_linky' => $meta['show_zemanta_linky_option'] ? isset($postdata['wp_rp_display_zemanta_linky']) : true, 'only_admins_can_edit_related_posts' => !empty($postdata['wp_rp_only_admins_can_edit_related_posts']), 'desktop' => array('display_comment_count' => isset($postdata['wp_rp_desktop_display_comment_count']), 'display_publish_date' => isset($postdata['wp_rp_desktop_display_publish_date']), 'display_excerpt' => isset($postdata['wp_rp_desktop_display_excerpt']), 'display_thumbnail' => isset($postdata['wp_rp_desktop_display_thumbnail']), 'excerpt_max_length' => isset($postdata['wp_rp_desktop_excerpt_max_length']) && is_numeric(trim($postdata['wp_rp_desktop_excerpt_max_length'])) ? intval(trim($postdata['wp_rp_desktop_excerpt_max_length'])) : 200, 'custom_theme_enabled' => isset($postdata['wp_rp_desktop_custom_theme_enabled'])));
        if (!isset($postdata['wp_rp_exclude_categories'])) {
            $new_options['exclude_categories'] = '';
        } else {
            if (is_array($postdata['wp_rp_exclude_categories'])) {
                $new_options['exclude_categories'] = join(',', $postdata['wp_rp_exclude_categories']);
            } else {
                $new_options['exclude_categories'] = trim($postdata['wp_rp_exclude_categories']);
            }
        }
        foreach (array('desktop') as $platform) {
            if (isset($postdata['wp_rp_' . $platform . '_theme_name'])) {
                // If this isn't set, maybe the AJAX didn't load...
                $new_options[$platform]['theme_name'] = trim($postdata['wp_rp_' . $platform . '_theme_name']);
            } else {
                $new_options[$platform]['theme_name'] = $old_options[$platform]['theme_name'];
            }
            if (isset($postdata['wp_rp_' . $platform . '_theme_custom_css'])) {
                $new_options[$platform]['theme_custom_css'] = $postdata['wp_rp_' . $platform . '_theme_custom_css'];
            } elseif (isset($postdata["wp_rp_{$platform}_custom_theme_enabled"])) {
                $new_options[$platform]['theme_custom_css'] = '';
            } else {
                $new_options[$platform]['theme_custom_css'] = $old_options[$platform]['theme_custom_css'];
            }
        }
        if (isset($postdata['wp_rp_classic_state'])) {
            $meta['classic_user'] = true;
        } else {
            $meta['classic_user'] = false;
        }
        wp_rp_update_meta($meta);
        if (isset($postdata['wp_rp_turn_on_button_pressed'])) {
            $meta['show_turn_on_button'] = false;
            $meta['turn_on_button_pressed'] = $postdata['wp_rp_turn_on_button_pressed'];
            $new_options['desktop']['display_thumbnail'] = true;
        }
        $preprocess_thumbnails = $new_options['desktop']['display_thumbnail'] && !$old_options['desktop']['display_thumbnail'];
        $default_thumbnail_path = wp_rp_upload_default_thumbnail_file();
        if ($default_thumbnail_path === false) {
            // no file uploaded
            if (isset($postdata['wp_rp_default_thumbnail_remove'])) {
                $new_options['default_thumbnail_path'] = false;
            } else {
                $new_options['default_thumbnail_path'] = $old_options['default_thumbnail_path'];
            }
        } else {
            if (is_wp_error($default_thumbnail_path)) {
                // error while upload
                $new_options['default_thumbnail_path'] = $old_options['default_thumbnail_path'];
                wp_rp_add_admin_notice('error', $default_thumbnail_path->get_error_message());
            } else {
                // file successfully uploaded
                $new_options['default_thumbnail_path'] = $default_thumbnail_path;
            }
        }
        if ((array) $old_options != $new_options) {
            if (!wp_rp_update_options($new_options)) {
                wp_rp_add_admin_notice('error', __('Failed to save settings.', 'wp_related_posts'));
            } else {
                wp_rp_add_admin_notice('updated', __('Settings saved.', 'wp_related_posts'));
            }
            if ($preprocess_thumbnails) {
                wp_rp_process_latest_post_thumbnails();
            }
        } else {
            // I should duplicate success message here
            wp_rp_add_admin_notice('updated', __('Settings saved.', 'wp_related_posts'));
        }
    }
    $input_hidden = array('wp_rp_ajax_nonce' => wp_create_nonce("wp_rp_ajax_nonce"), 'wp_rp_json_url' => esc_attr(WP_RP_CONTENT_BASE_URL . WP_RP_STATIC_JSON_PATH), 'wp_rp_version' => esc_attr(WP_RP_VERSION), 'wp_rp_dashboard_url' => esc_attr(WP_RP_CTR_DASHBOARD_URL), 'wp_rp_static_base_url' => esc_attr(WP_RP_STATIC_BASE_URL), 'wp_rp_plugin_static_base_url' => esc_attr(plugins_url("static/", __FILE__)));
    $settings_file = __FILE__;
    $form_url = admin_url('admin.php?page=wordpress-related-posts');
    $form_display = 'block';
    //($meta['show_turn_on_button'] && !$meta['turn_on_button_pressed'] ? 'none' : 'block');
    global $wpdb;
    $custom_fields = $wpdb->get_col("SELECT meta_key FROM {$wpdb->postmeta} GROUP BY meta_key HAVING meta_key NOT LIKE '\\_%' ORDER BY LOWER(meta_key)");
    $exclude_categories = explode(',', $options['exclude_categories']);
    $categories = get_categories(array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false));
    $blog_url = get_site_url();
    include wp_rp_get_template('settings');
}
Example #6
0
function wp_rp_get_related_posts($before_title = '', $after_title = '')
{
    if (wp_rp_should_exclude()) {
        return;
    }
    global $post, $wp_rp_is_first_widget;
    global $wp_rp_test_group;
    // used for AB testing on mobile
    $options = wp_rp_get_options();
    $platform_options = wp_rp_get_platform_options();
    $meta = wp_rp_get_meta();
    $statistics_enabled = $options['ctr_dashboard_enabled'] && $meta['blog_id'] && $meta['auth_key'];
    $remote_recommendations = is_single() && $meta['remote_recommendations'] && $statistics_enabled;
    $posts_and_title = wp_rp_fetch_posts_and_title();
    $related_posts = $posts_and_title['posts'];
    $title = $posts_and_title['title'];
    $selected_related_posts = wp_rp_get_selected_posts();
    $related_posts_content = "";
    if (!$related_posts) {
        return;
    }
    $posts_footer = '';
    if (current_user_can($options['only_admins_can_edit_related_posts'] ? 'manage_options' : 'edit_posts') && $statistics_enabled) {
        $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_edit" href="#" id="wp_rp_edit_related_posts">Edit Related Posts</a></div>';
    }
    if ($options['display_zemanta_linky']) {
        $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_backlink" target="_blank" href="http://www.zemanta.com/?wp-related-posts" rel="nofollow">Zemanta</a></div>';
    }
    $css_classes = 'related_post wp_rp';
    $css_classes_wrap = ' ' . str_replace(array('.css', '-'), array('', '_'), esc_attr('wp_rp_' . $platform_options['theme_name']));
    $related_posts_lis = wp_rp_generate_related_posts_list_items($related_posts, $selected_related_posts);
    $related_posts_ul = '<ul class="' . $css_classes . '" style="visibility: ' . ($remote_recommendations ? 'hidden' : 'visible') . '">' . $related_posts_lis . '</ul>';
    $related_posts_title = $title ? $before_title ? $before_title . $title . $after_title : '<h3 class="related_post_title">' . $title . '</h3>' : '';
    $first_id_attr = '';
    if ($wp_rp_is_first_widget) {
        $wp_rp_is_first_widget = false;
        $first_id_attr = 'id="wp_rp_first"';
    }
    $wrap_style = '';
    //error_log('test group when content:'  . $wp_rp_test_group);
    if ($wp_rp_test_group == 2) {
        $wrap_style = ' style="display:none;"';
    }
    $output = '<div class="wp_rp_wrap ' . $css_classes_wrap . '" ' . $first_id_attr . $wrap_style . '>' . '<div class="wp_rp_content">' . $related_posts_title . $related_posts_ul . $posts_footer . '</div>' . ($remote_recommendations ? '<script type="text/javascript">window._wp_rp_callback_widget_exists ? window._wp_rp_callback_widget_exists() : false;</script>' : '') . '</div>';
    return "\n" . $output . "\n";
}
function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = false)
{
    $options = wp_rp_get_options();
    $platform_options = wp_rp_get_platform_options();
    if (!($platform_options["display_thumbnail"] || $force)) {
        return false;
    }
    $post_title = wptexturize($related_post->post_title);
    if (property_exists($related_post, 'thumbnail')) {
        return wp_rp_get_img_tag($related_post->thumbnail, $post_title, $size);
    }
    $size = wp_rp_get_thumbnail_size_array($size);
    if (!$size) {
        return false;
    }
    if ($options['thumbnail_use_custom']) {
        $thumbnail_src = get_post_meta($related_post->ID, $options["thumbnail_custom_field"], true);
        if ($thumbnail_src) {
            return wp_rp_get_img_tag($thumbnail_src, $post_title, $size);
        }
    }
    $attached_img_url = wp_rp_get_attached_img_url($related_post, $size);
    if ($attached_img_url) {
        return wp_rp_get_img_tag($attached_img_url, $post_title, $size);
    }
    return wp_rp_get_img_tag(wp_rp_get_default_thumbnail_url($related_post->ID, $size), $post_title, $size);
}
Example #8
0
File: init.php Project: AndyA/River
function wp_rp_get_related_posts($before_title = '', $after_title = '')
{
    if (wp_rp_should_exclude()) {
        return;
    }
    global $post, $wp_rp_is_first_widget;
    global $wp_rp_test_group;
    // used for AB testing on mobile
    $options = wp_rp_get_options();
    $platform_options = wp_rp_get_platform_options();
    $meta = wp_rp_get_meta();
    $posts_and_title = wp_rp_fetch_posts_and_title();
    $related_posts = $posts_and_title['posts'];
    $title = $posts_and_title['title'];
    $selected_related_posts = wp_rp_get_selected_posts();
    $related_posts_content = "";
    if (!$related_posts) {
        return;
    }
    $post_categories = array();
    if ($platform_options["display_category"]) {
        $post_categories = wp_rp_get_post_categories();
    }
    $posts_footer = '';
    if (current_user_can($options['only_admins_can_edit_related_posts'] ? 'manage_options' : 'edit_posts')) {
        $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_edit" href="#" id="wp_rp_edit_related_posts">Edit Related Posts</a></div>';
    }
    if ($options['display_zemanta_linky']) {
        $posts_footer .= '<div class="wp_rp_footer"><a class="wp_rp_backlink" target="_blank" href="http://www.sovrn.com/" rel="nofollow">Sovrn</a></div>';
    }
    $css_classes = 'related_post wp_rp';
    $css_classes_wrap = ' ' . str_replace(array('.css', '-'), array('', '_'), esc_attr('wp_rp_' . $platform_options['theme_name']));
    $related_posts_lis = wp_rp_generate_related_posts_list_items($related_posts, $selected_related_posts, $post_categories);
    $related_posts_ul = '<ul class="' . $css_classes . '">' . $related_posts_lis . '</ul>';
    $related_posts_title = $title ? $before_title ? $before_title . $title . $after_title : '<h3 class="related_post_title">' . $title . '</h3>' : '';
    $first_id_attr = '';
    if ($wp_rp_is_first_widget) {
        $wp_rp_is_first_widget = false;
        $first_id_attr = 'id="wp_rp_first"';
    }
    $wrap_style = '';
    //error_log('test group when content:'  . $wp_rp_test_group);
    if ($wp_rp_test_group == 2) {
        $wrap_style = ' style="display:none;"';
    }
    $output = '<div class="wp_rp_wrap ' . $css_classes_wrap . '" ' . $first_id_attr . $wrap_style . '>' . '<div class="wp_rp_content">' . $related_posts_title . $related_posts_ul . $posts_footer . '</div>' . '</div>';
    return "\n" . $output . "\n";
}
function wp_rp_settings_page()
{
    if (!current_user_can('delete_users')) {
        die('Sorry, you don\'t have permissions to access this page.');
    }
    wp_rp_register();
    // handle post if needed
    wp_rp_handle_postdata();
    $options = wp_rp_get_options();
    $meta = wp_rp_get_meta();
    $articles_count = wp_rp_article_count($meta['zemanta_api_key']);
    $articles_uploaded = false;
    if (isset($_GET['wp_rp_upload_articles']) && !empty($meta['zemanta_api_key'])) {
        $articles_uploaded = wp_rp_upload_articles($meta['zemanta_api_key']);
    }
    // Update already subscribed but in the old pipeline
    if (!empty($meta["email"]) && empty($meta["subscribed"])) {
        wp_rp_subscription($meta["email"], $options["subscription_types"]);
    }
    if (isset($_GET['gp_global_notice']) && $_GET['gp_global_notice'] === '0') {
        $meta['global_notice'] = null;
        wp_rp_update_meta($meta);
    }
    $input_hidden = array('wp_rp_ajax_nonce' => wp_create_nonce('wp_rp_ajax_nonce'), 'wp_rp_json_url' => esc_attr(WP_RP_STATIC_BASE_URL . WP_RP_STATIC_JSON_PATH), 'wp_rp_version' => esc_attr(WP_RP_VERSION), 'wp_rp_dashboard_url' => esc_attr(WP_RP_CTR_DASHBOARD_URL), 'wp_rp_static_base_url' => esc_attr(WP_RP_STATIC_BASE_URL));
    $settings_file = __FILE__;
    $form_url = admin_url('admin.php?page=wordpress-related-posts');
    $form_display = !$meta['registered'] && $meta['show_turn_on_button'] && !$meta['turn_on_button_pressed'] ? 'none' : 'block';
    global $wpdb;
    $custom_fields = $wpdb->get_col("SELECT meta_key FROM {$wpdb->postmeta} GROUP BY meta_key HAVING meta_key NOT LIKE '\\_%' ORDER BY LOWER(meta_key)");
    $exclude_categories = explode(',', $options['exclude_categories']);
    $categories = get_categories(array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false));
    $subs = $options["subscription_types"];
    $subs_checked = array();
    foreach (array("activityreport", "newsletter") as $type) {
        $subs_checked[$type] = strpos($subs, $type) !== false ? " checked=checked" : "";
    }
    $blog_url = get_site_url();
    include wp_rp_get_template('settings');
}
function wp_rp_get_post_thumbnail_img($related_post, $size = null, $force = false)
{
    $options = wp_rp_get_options();
    $platform_options = wp_rp_get_platform_options();
    if (!($platform_options["display_thumbnail"] || $force)) {
        return false;
    }
    $post_id = str_replace("in_", "", "{$related_post->ID}");
    $post_title = wptexturize($related_post->post_title);
    $size = wp_rp_get_thumbnail_size_array($size);
    if (!$size) {
        return false;
    }
    if ($options['thumbnail_use_custom']) {
        $thumbnail_src = get_post_meta($post_id, $options["thumbnail_custom_field"], true);
        if ($thumbnail_src) {
            return wp_rp_get_img_tag($thumbnail_src, $post_title, $size);
        }
    }
    $featured_image = get_post_thumbnail_id($post_id);
    if ($featured_image) {
        $featured_image_data = wp_rp_get_image_data($featured_image);
        $featured_image_thumb = wp_rp_get_image_with_exact_size($featured_image_data, $size);
        if ($featured_image_thumb) {
            return wp_rp_get_img_tag($featured_image_thumb["url"], $post_title, $size);
        } else {
            return get_the_post_thumbnail($post_id, $size);
        }
    }
    $attached_img_url = wp_rp_get_attached_img_url($related_post, $size);
    if ($attached_img_url) {
        return wp_rp_get_img_tag($attached_img_url, $post_title, $size);
    }
    return wp_rp_get_img_tag(wp_rp_get_default_thumbnail_url($related_post->ID, $size), $post_title, $size);
}
Example #11
0
function wp_rp_load_remote_notifications()
{
    $meta = wp_rp_get_meta();
    $options = wp_rp_get_options();
    $blog_id = $meta['blog_id'];
    $auth_key = $meta['auth_key'];
    $req_options = array('timeout' => 5);
    if (!$blog_id || !$auth_key || !$options['ctr_dashboard_enabled']) {
        return;
    }
    // receive remote recommendations
    $url = WP_RP_CTR_DASHBOARD_URL . "notifications/?blog_id={$blog_id}&auth_key={$auth_key}";
    $response = wp_remote_get($url, $req_options);
    if (wp_remote_retrieve_response_code($response) == 200) {
        $body = wp_remote_retrieve_body($response);
        if ($body) {
            $json = json_decode($body);
            if ($json && isset($json->status) && $json->status === 'ok' && isset($json->data) && is_object($json->data)) {
                $messages_ref =& $meta['remote_notifications'];
                $data = $json->data;
                if (isset($data->msgs) && is_array($data->msgs)) {
                    // add new messages from server and update old ones
                    foreach ($data->msgs as $msg) {
                        $messages_ref[$msg->msg_id] = $msg->text;
                    }
                    // sort messages by identifier
                    ksort($messages_ref);
                }
                if (isset($data->delete_msgs) && is_array($data->delete_msgs)) {
                    foreach ($data->delete_msgs as $msg_id) {
                        if (array_key_exists($msg_id, $messages_ref)) {
                            unset($messages_ref[$msg_id]);
                        }
                    }
                }
                if (isset($data->turn_on_remote_recommendations) && $data->turn_on_remote_recommendations) {
                    $meta['remote_recommendations'] = true;
                } else {
                    if (isset($data->turn_off_remote_recommendations) && $data->turn_off_remote_recommendations) {
                        $meta['remote_recommendations'] = false;
                    }
                }
                if (isset($data->show_blogger_network_form) && $data->show_blogger_network_form) {
                    $meta['show_blogger_network_form'] = true;
                } else {
                    if (isset($data->hide_blogger_network_form) && $data->hide_blogger_network_form) {
                        $meta['show_blogger_network_form'] = false;
                    }
                }
                if (isset($data->show_traffic_exchange) && $data->show_traffic_exchange) {
                    $meta['show_traffic_exchange'] = true;
                    $options['traffic_exchange_enabled'] = true;
                } else {
                    if (isset($data->hide_traffic_exchange) && $data->hide_traffic_exchange) {
                        $meta['show_traffic_exchange'] = false;
                        $options['traffic_exchange_enabled'] = false;
                    }
                }
                wp_rp_update_meta($meta);
                wp_rp_update_options($options);
            }
        }
    }
}