function nr_rc_add_defaults() { nrelate_system_check(); // run system check // Calculate plugin file path $dir = substr(realpath(dirname(__FILE__) . '/..'), strlen(WP_PLUGIN_DIR)); $file = key(get_plugins($dir)); $plugin_file = substr($dir, 1) . '/' . $file; nrelate_products("related", NRELATE_RELATED_PLUGIN_VERSION, NRELATE_RELATED_ADMIN_VERSION, 1, $plugin_file); // add this product to the nrelate_products array global $nr_rc_std_options, $nr_rc_ad_options, $nr_rc_layout_options; $tmp = get_option('nrelate_related_options'); // If related_reset value is on or if nrelate_related_options was never created, insert default values if ($tmp['related_reset'] == 'on' || !is_array($tmp)) { update_option('nrelate_related_options', $nr_rc_std_options); update_option('nrelate_related_options_ads', $nr_rc_ad_options); update_option('nrelate_related_options_styles', $nr_rc_layout_options); // Convert some values to send to nrelate server $number = 3; $r_bar = "Low"; $r_title = "You may also like -"; $r_max_age = 10; $r_max_frame = "Year(s)"; $r_display_post_title = true; $r_max_char_per_line = 100; $r_max_char_post_excerpt = 100; $r_display_ad = ""; $r_display_logo = ""; $r_related_reset = ""; $related_blogoption = array(); $related_thumbnail = "Thumbnails"; $backfillimage = NULL; $number_ext = 3; $related_thumbnail_size = 110; $r_number_of_ads = 0; $r_ad_placement = "Last"; $r_ad_title = "More from the Web -"; $r_nonjs = 0; // Convert max age time frame to minutes switch ($r_max_frame) { case 'Hour(s)': $maxageposts = $r_max_age * 60; break; case 'Day(s)': $maxageposts = $r_max_age * 1440; break; case 'Week(s)': $maxageposts = $r_max_age * 10080; break; case 'Month(s)': $maxageposts = $r_max_age * 44640; break; case 'Year(s)': $maxageposts = $r_max_age * 525600; break; } // Convert ad parameter switch ($r_display_ad) { case true: $ad = 1; break; default: $ad = 0; } // Convert display post title parameter switch ($r_display_post_title) { case 'on': $r_display_post_title = 1; break; default: $r_display_post_title = 0; } // Convert logo parameter switch ($r_display_logo) { case 'on': $logo = 1; break; default: $logo = 0; } // Convert blogroll option parameter if (is_array($related_blogoption) && count($related_blogoption) > 0) { $blogroll = 1; } else { $blogroll = 0; } // Convert thumbnail option parameter switch ($related_thumbnail) { case 'Thumbnails': $thumb = 1; break; default: $thumb = 0; } // Get the wordpress root url and the rss url $bloglist = nrelate_get_blogroll(); // Write the parameters to be sent $r_show_post_title = isset($r_show_post_title) ? $r_show_post_title : null; $r_show_post_excerpt = isset($r_show_post_excerpt) ? $r_show_post_excerpt : null; $backfill = isset($backfill) ? $backfill : null; $body = array('DOMAIN' => NRELATE_BLOG_ROOT, 'VERSION' => NRELATE_RELATED_PLUGIN_VERSION, 'KEY' => get_option('nrelate_key'), 'NUM' => $number, 'NUMEXT' => $number_ext, 'R_BAR' => $r_bar, 'HDR' => $r_title, 'BLOGOPT' => $blogroll, 'BLOGLI' => $bloglist, 'MAXPOST' => $maxageposts, 'SHOWPOSTTITLE' => $r_show_post_title, 'MAXCHAR' => $r_max_char_per_line, 'SHOWEXCERPT' => $r_show_post_excerpt, 'MAXCHAREXCERPT' => $r_max_char_post_excerpt, 'ADOPT' => $ad, 'THUMB' => $thumb, 'LOGO' => $logo, 'IMAGEURL' => $backfill, 'THUMBSIZE' => $related_thumbnail_size, 'ADNUM' => $r_number_of_ads, 'ADPLACE' => $r_ad_placement, 'ADTITLE' => $r_ad_title, 'NONJS' => $r_nonjs); $url = 'http://api.nrelate.com/rcw_wp/' . NRELATE_RELATED_PLUGIN_VERSION . '/processWPrelatedAll.php'; $result = wp_remote_post($url, array('body' => $body, 'blocking' => false, 'timeout' => 15)); } // RSS mode is sent again just incase if the user already had nrelate_related_options in their wordpress db // and doesn't get sent above $excerptset = get_option('rss_use_excerpt'); $rss_mode = "FULL"; if ($excerptset != '0') { // are RSS feeds set to excerpt update_option('nrelate_admin_msg', 'yes'); $rss_mode = "SUMMARY"; } $rssurl = get_bloginfo('rss2_url'); // Add our ping host to the ping list $current_ping_sites = get_option('ping_sites'); $pingexist = strpos($current_ping_sites, "http://api.nrelate.com/rpcpinghost/"); if ($pingexist == false) { $pinglist = <<<EOD {$current_ping_sites} http://api.nrelate.com/rpcpinghost/ EOD; update_option('ping_sites', $pinglist); } // Enable xmlrpc for the user update_option('enable_xmlrpc', 1); //Set up a unique nrelate key, for secure feed access $key = get_option('nrelate_key'); if (empty($key)) { $key = wp_generate_password(24, false, false); update_option('nrelate_key', $key); } // Send notification to nrelate server of activation and send us rss feed mode information $action = "ACTIVATE"; $body = array('DOMAIN' => NRELATE_BLOG_ROOT, 'ACTION' => $action, 'RSSMODE' => $rss_mode, 'VERSION' => NRELATE_RELATED_PLUGIN_VERSION, 'KEY' => get_option('nrelate_key'), 'ADMINVERSION' => NRELATE_RELATED_ADMIN_VERSION, 'PLUGIN' => 'related', 'RSSURL' => $rssurl); $url = 'http://api.nrelate.com/common_wp/' . NRELATE_RELATED_ADMIN_VERSION . '/wordpressnotify_activation.php'; $result = wp_remote_post($url, array('body' => $body, 'blocking' => false, 'timeout' => 15)); }
function update_nrelate_data_fo() { // Get nrelate_flyout options from wordpress database $option = get_option('nrelate_flyout_options'); $number = urlencode($option['flyout_number_of_posts']); $r_bar = $option['flyout_bar']; $r_title = urlencode($option['flyout_title']); $r_max_age = $option['flyout_max_age_num']; $r_max_frame = $option['flyout_max_age_frame']; $r_box_width = $option['flyout_anim_width']; $r_box_width_type = $option['flyout_anim_width_type']; $r_show_post_title = empty($option['flyout_show_post_title']) ? false : true; $r_max_char_per_line = $option['flyout_max_chars_per_line']; $r_show_post_excerpt = empty($option['flyout_show_post_excerpt']) ? false : true; $r_max_char_post_excerpt = $option['flyout_max_chars_post_excerpt']; $r_display_logo = empty($option['flyout_display_logo']) ? false : true; //$r_flyout_reset = $option['flyout_reset']; $flyout_blogoption = isset($option['flyout_blogoption']) ? $option['flyout_blogoption'] : null; $flyout_thumbnail = isset($option['flyout_thumbnail']) ? $option['flyout_thumbnail'] : null; $backfill = isset($option['flyout_default_image']) ? $option['flyout_default_image'] : null; $number_ext = isset($option['flyout_number_of_posts_ext']) ? $option['flyout_number_of_posts_ext'] : null; $flyout_thumbnail_size = isset($option['flyout_thumbnail_size']) ? $option['flyout_thumbnail_size'] : null; $flyout_loc = isset($option['flyout_loc']) ? $option['flyout_loc'] : null; $flyout_animation = isset($option['flyout_animation']) ? $option['flyout_animation'] : nulls; $noflyoutposts = isset($option['flyout_number_of_posts']) ? $option['flyout_number_of_posts'] : null; $flyout_offset = isset($option['flyout_offset']) ? $option['flyout_offset'] : null; $flyout_offset_element = isset($option['flyout_offset_element']) ? $option['flyout_offset_element'] : null; $flyout_nonjs = isset($option['flyout_nonjs']) ? $option['flyout_nonjs'] : null; $flyout_from_bot = isset($option['flyout_from_bot']) ? $option['flyout_from_bot'] : null; $flyout_from_bot_type = isset($option['flyout_from_bot_type']) ? $option['flyout_from_bot_type'] : null; // Convert max age time frame to minutes switch ($r_max_frame) { case 'Hour(s)': $maxageposts = $r_max_age * 60; break; case 'Day(s)': $maxageposts = $r_max_age * 1440; break; case 'Week(s)': $maxageposts = $r_max_age * 10080; break; case 'Month(s)': $maxageposts = $r_max_age * 44640; break; case 'Year(s)': $maxageposts = $r_max_age * 525600; break; } // Convert show post title parameter $r_show_post_title = $r_show_post_title ? 1 : 0; // Convert show post excerpt parametet $r_show_post_excerpt = $r_show_post_excerpt ? 1 : 0; // Convert logo parameter $logo = $r_display_logo ? 1 : 0; // Convert blogroll option parameter $blogroll = is_array($flyout_blogoption) && count($flyout_blogoption) > 0 ? 1 : 0; // Convert thumbnail option parameter switch ($flyout_thumbnail) { case 'Thumbnails': $thumb = 1; break; default: $thumb = 0; } // Get the wordpress root url and the wordpress rss url. $bloglist = nrelate_get_blogroll(); // Write the parameters to be sent $body = array('DOMAIN' => NRELATE_BLOG_ROOT, 'VERSION' => NRELATE_FLYOUT_PLUGIN_VERSION, 'KEY' => get_option('nrelate_key'), 'NUM' => $number, 'NUMEXT' => $number_ext, 'R_BAR' => $r_bar, 'HDR' => $r_title, 'BLOGOPT' => $blogroll, 'BLOGLI' => $bloglist, 'MAXPOST' => $maxageposts, 'SHOWPOSTTITLE' => $r_show_post_title, 'MAXCHAR' => $r_max_char_per_line, 'SHOWEXCERPT' => $r_show_post_excerpt, 'MAXCHAREXCERPT' => $r_max_char_post_excerpt, 'THUMB' => $thumb, 'LOGO' => $logo, 'IMAGEURL' => $backfill, 'THUMBSIZE' => $flyout_thumbnail_size, 'LAYOUT' => isset($flyout_layout) ? $flyout_layout : null, 'NONJS' => $flyout_nonjs, 'OFFSET' => $flyout_offset, 'ELEMENT' => $flyout_offset_element, 'ANIMATION' => $flyout_animation, 'LOCATION' => $flyout_loc, 'OFFSET' => $flyout_offset, 'FROMBOT' => $flyout_from_bot, 'FROMBOTTYPE' => urlencode($flyout_from_bot_type), 'WIDTH' => $r_box_width, 'WIDTHTYPE' => urlencode($r_box_width_type)); $url = 'http://api.nrelate.com/fow_wp/' . NRELATE_FLYOUT_PLUGIN_VERSION . '/processWPflyout.php'; $result = wp_remote_post($url, array('body' => $body, 'blocking' => false, 'timeout' => 15)); }
function update_nrelate_data_rc() { // Get nrelate_related options from wordpress database $option = get_option('nrelate_related_options'); $number = urlencode($option['related_number_of_posts']); $r_bar = $option['related_bar']; $r_title = urlencode($option['related_title']); $r_max_age = $option['related_max_age_num']; $r_max_frame = $option['related_max_age_frame']; $r_show_post_title = empty($option['related_show_post_title']) ? false : true; $r_max_char_per_line = $option['related_max_chars_per_line']; $r_show_post_excerpt = empty($option['related_show_post_excerpt']) ? false : true; $r_max_char_post_excerpt = $option['related_max_chars_post_excerpt']; $r_display_logo = empty($option['related_display_logo']) ? false : true; //$r_related_reset = $option['related_reset']; $related_blogoption = $option['related_blogoption']; $related_thumbnail = $option['related_thumbnail']; $backfill = $option['related_default_image']; $number_ext = $option['related_number_of_posts_ext']; $related_thumbnail_size = $option['related_thumbnail_size']; $related_loc_top = isset($option['related_loc_top']) ? $option['related_loc_top'] : null; $related_loc_bot = isset($option['related_loc_bottom']) ? $option['related_loc_bottom'] : null; $related_nonjs = isset($option['related_nonjs']) ? $option['related_nonjs'] : null; $related_layout = ''; if ($related_loc_top == 'on') { $related_layout .= '(TOP)'; } if ($related_loc_bot == 'on') { $related_layout .= '(BOT)'; } // Convert max age time frame to minutes switch ($r_max_frame) { case 'Hour(s)': $maxageposts = $r_max_age * 60; break; case 'Day(s)': $maxageposts = $r_max_age * 1440; break; case 'Week(s)': $maxageposts = $r_max_age * 10080; break; case 'Month(s)': $maxageposts = $r_max_age * 44640; break; case 'Year(s)': $maxageposts = $r_max_age * 525600; break; } // Convert show post title parameter $r_show_post_title = $r_show_post_title ? 1 : 0; // Convert show post excerpt parametet $r_show_post_excerpt = $r_show_post_excerpt ? 1 : 0; // Convert logo parameter $logo = $r_display_logo ? 1 : 0; // Convert blogroll option parameter $blogroll = is_array($related_blogoption) && count($related_blogoption) > 0 ? 1 : 0; // Convert thumbnail option parameter switch ($related_thumbnail) { case 'Thumbnails': $thumb = 1; break; default: $thumb = 0; } // Get the wordpress root url and the wordpress rss url. $bloglist = nrelate_get_blogroll(); // Write the parameters to be sent $body = array('DOMAIN' => NRELATE_BLOG_ROOT, 'VERSION' => NRELATE_RELATED_PLUGIN_VERSION, 'KEY' => get_option('nrelate_key'), 'NUM' => $number, 'NUMEXT' => $number_ext, 'R_BAR' => $r_bar, 'HDR' => $r_title, 'BLOGOPT' => $blogroll, 'BLOGLI' => $bloglist, 'MAXPOST' => $maxageposts, 'SHOWPOSTTITLE' => $r_show_post_title, 'MAXCHAR' => $r_max_char_per_line, 'SHOWEXCERPT' => $r_show_post_excerpt, 'MAXCHAREXCERPT' => $r_max_char_post_excerpt, 'THUMB' => $thumb, 'LOGO' => $logo, 'IMAGEURL' => $backfill, 'THUMBSIZE' => $related_thumbnail_size, 'LAYOUT' => $related_layout, 'NONJS' => $related_nonjs); $url = 'http://api.nrelate.com/rcw_wp/' . NRELATE_RELATED_PLUGIN_VERSION . '/processWPrelated.php'; $result = wp_remote_post($url, array('body' => $body, 'blocking' => false, 'timeout' => 15)); }