示例#1
0
function upgrade_db()
{
    //beginning of upgrade function
    $option_settings = get_option('rss_import_options');
    //get shortcode settings (has the plugin version)
    $items_options = get_option('rss_import_items');
    // get rss feeds
    $categoryoptions = get_option('rss_import_categories_images');
    //category images
    $post_options = get_option('rss_post_options');
    //autoPost options
    $wprssmi_admin_options = get_option('rss_admin_options');
    // admin settings
    $catOptions = get_option('rss_import_categories');
    //categories
    //	$wprssmi_admin_options['old_plugin_version'] = $option_settings['plugin_version'];
    $old_version = '';
    if (isset($option_settings['plugin_version'])) {
        $old_version = $option_settings['plugin_version'];
    }
    $wprssmi_admin_options['plugin_version'] = number_format(WP_RSS_MULTI_VERSION, 2);
    update_option('rss_admin_options', $wprssmi_admin_options);
    //put the current version in the database
    //indicate that new installs and beta testers are already activated
    if (empty($items_options) || isset($wprssmi_admin_options['activate']) && $wprssmi_admin_options['activate'] == 1) {
        $wprssmi_admin_options['activate'] = 1;
    } else {
        $wprssmi_admin_options['activate'] = 0;
    }
    update_option('rss_admin_options', $wprssmi_admin_options);
    //update the database
    //  ADD THIS BEFORE LAUNCH AND MAKE VERSION 3.00
    if (floatval($old_version) == 2.68) {
        rssmi_activate_now();
    }
    if (!empty($items_options) && empty($option_settings)) {
        // this transfers data to new table if upgrading
        add_option('rss_import_options', $items_options, '', '');
    }
    if (!empty($option_settings)) {
        //only if not a new install
        if (!isset($option_settings['template']) || $option_settings['template'] === '') {
            foreach ($option_settings as $key => $value) {
                $template_settings[$key] = $value;
            }
            $template_settings['template'] = 'default.php';
            update_option('rss_import_options', $template_settings);
        }
    }
    if (empty($post_options)) {
        $post_settings = array('active' => 0, 'post_status' => 'publish', 'maxperfetch' => 5, 'maxfeed' => 5, 'maximgwidth' => 150, 'category' => 0);
        update_option('rss_post_options', $post_settings);
    }
    //this is for adding multiple categories to the feed to post feature (version 2.47)
    if (!empty($post_options)) {
        if (!isset($post_options['categoryid']['plugcatid']) || $post_options['categoryid']['plugcatid'] === '') {
            foreach ($post_options as $key => $value) {
                $post_settings[$key] = $value;
            }
            $post_settings['categoryid']['plugcatid'][1] = '';
            if (isset($post_options['category'])) {
                $post_settings['categoryid']['plugcatid'][1] = $post_options['category'];
            }
            $post_settings['categoryid']['wpcatid'][1] = '';
            if (isset($post_options['wpcategory'])) {
                $post_settings['categoryid']['wpcatid'][1] = $post_options['wpcategory'];
            }
            update_option('rss_post_options', $post_settings);
        }
    }
    if (!empty($post_options) && isset($post_options['categoryid']) && !is_array($post_options['categoryid']['wpcatid'][1])) {
        foreach ($post_options as $key => $value) {
            if ($key != 'categoryid') {
                $post_settings[$key] = $value;
            }
        }
        $catsize = count($catOptions);
        $postoptionsize = $catsize / 2;
        for ($q = 1; $q <= $postoptionsize; $q++) {
            $post_settings['categoryid']['plugcatid'][$q] = $post_options['categoryid']['plugcatid'][$q];
            $post_settings['categoryid']['wpcatid'][$q][1] = $post_options['categoryid']['wpcatid'][$q];
        }
        update_option('rss_post_options', $post_settings);
    }
    if (!empty($categoryoptions) && !is_array($categoryoptions[1])) {
        foreach ($categoryoptions as $key => $value) {
            $cat_settings[$key]['imageURL'] = $value;
            $cat_settings[$key]['tags'] = '';
        }
        update_option('rss_import_categories_images', $cat_settings);
    }
    //for resetting the admin message
    if (isset($plugin_version) && $plugin_version < 2.4) {
        $wprssmi_admin_options['dismiss_slug'] = 'false';
        //update_option( 'wprssmi_admin_options', $post_settings );
    }
    if (empty($option_settings)) {
        $option_default_settings = array('sortbydate' => 0, 'pag' => 0, 'targetWindow' => 0, 'maxfeed' => 4, 'sourcename' => 'Source', 'showcategory' => 0, 'noFollow' => 0, 'showdesc' => 1, 'descnum' => 50, 'floatType' => 1, 'adjustImageSize' => 1, 'showsocial' => 0);
        update_option('rss_import_options', $option_default_settings);
    }
}
function wp_rss_multi_importer_upload_page()
{
    remove_action('save_post', 'rssmi_save_custom_fields');
    echo '<div class="wrap">';
    echo '<div id="poststuff"><div id="post-body">';
    if (isset($_POST['multilookup']) && $_REQUEST['multiadd'] == "SAVE") {
        $URL_Array = $_POST['multilookup'];
        $URL_arr = explode("\n", $URL_Array);
        $msg = '';
        $activate = 0;
        //	date_default_timezone_set($serverTimezone);
        $rightNow == current_time('timestamp');
        foreach ($URL_arr as $url_a) {
            if (strpos($url_a, "ACTIVATE") !== false) {
                $activate = 1;
                continue;
            }
            $pos = strpos($url_a, ",");
            if ($pos === false) {
                $URL_feed_address = $url_a;
                $URL_title = "Unknown";
            } else {
                $URL_feed = explode(",", $url_a);
                $URL_feed_address = $URL_feed[1];
                $URL_title = $URL_feed[0];
                $URL_category = $URL_feed[2];
                $URL_user = $URL_feed[3];
            }
            $url_result = rssmi_isValidURL(trim($URL_feed_address));
            if (!$url_result) {
                $msg = "  However, one or more of the feeds did not have a valid URL.";
                continue;
            }
            $rss_post = array('post_title' => $URL_title, 'post_status' => 'publish', 'post_type' => 'rssmi_feed', 'post_date' => $rightNow);
            $post_id = wp_insert_post($rss_post, $wp_error);
            update_post_meta($post_id, 'rssmi_url', $URL_feed_address);
            update_post_meta($post_id, 'rssmi_cat', $URL_category);
            update_post_meta($post_id, 'rssmi_user', $URL_user);
        }
        echo '<div id="message" class="updated fade"><p><strong>';
        echo 'The feeds have been saved!';
        echo $msg;
        echo '</strong></p>';
        echo '</div>';
        add_action('save_post', 'rssmi_save_custom_fields');
        rssmi_fetch_all_feed_items();
        if ($activate == 1) {
            rssmi_activate_now();
            //activate if urls are from an upgrade
        }
    }
    ?>
	<div id="icon-themes" class="icon32 icon32-posts-rssmi_feed"></div>
	<h2 class="brand-icon"><?php 
    _e("Multi-Importer", 'wp-rss-multi-importer');
    ?>
</h2>
		<?php 
    settings_errors();
    ?>
		<div class="wrap">
    <h2>Upload Multiple RSS Feeds</h2>

	<div class="postbox">
	
	<div class="inside">



		<form action="" method="post">
		 
		  <h4>Add Multiple Feed Sources</h4>
		  <div>Enter one Feed Name per line, comma delimited (this is important) as follows (the plugin category and Blog User ID are optional):</div><br>
		  <div>[Feed Title],[Feed RSS URL],[Plugin Category ID number], [Blog User ID] (note:  do not use the brackets)</div><br>
		  <div><textarea name="multilookup" rows="8" cols="60"
		  style="vertical-align: top"></textarea></div>
		  <div style="border-top: 1px dotted black; padding-top: 10px">
		  <div class="alignright"><input type="submit" class="button-primary" name="multiadd" value="SAVE" /></div>
		  <div class="alignleft"><input type="button" class="button-secondary" name="action" value="CANCEL"/></div>
		  </div>
		</form>
	<br><br><p>If you need to get the plugin category ID number, simply click on the Categories Tab.  To get the Blog User ID, <a href="http://www.wprssimporter.com/faqs/finding-the-blog-user-id/" target="_blank">use this link to find out how</a>.</p>
	
       
    <?php 
    echo '</div></div>';
    echo '</div></div></div>';
}