Example #1
0
function wprssmi_ajax_process_request()
{
    if ($_POST["restore_var"] == 1) {
        //echo $_POST["restore_var"];
        restore_template(0);
        echo __("Your templates have been restored.  Go back to the settings options tab and select your template.", 'wp-rss-multi-importer');
        die;
    } else {
        if ($_POST["save_var"] == 2) {
            delete_option('rss_template_item');
            save_template_function($_POST['post_var']);
            die;
        } else {
            if ($_POST["save_var"] == 3) {
                save_css();
                die;
            }
        }
    }
    // first check if data is being sent and that it is the data we want
    if (!empty($_POST["post_var"]) && !empty($_POST["post_name"])) {
        $templateCSSname = 'templates.css';
        $templatename = $_POST['post_var'];
        $newtemplatename = $_POST['post_name'];
        $templateCODE = file_get_contents(WP_RSS_MULTI_TEMPLATES . $templatename);
        $templateCSS = file_get_contents(WP_RSS_MULTI_TEMPLATES . $templateCSSname);
        $newtemplatename = str_replace(' ', '_', $newtemplatename) . '.php';
        //now, put in DB
        $myTemplateOptions = array('template_name' => $newtemplatename, 'template_code' => $templateCODE, 'template_css' => $templateCSS);
        delete_option('rss_template_item');
        add_option('rss_template_item', $myTemplateOptions);
        echo "<p>" . __("SUCCESS. YOUR TEMPLATE AND CSS FILE HAS BEEN STORED IN THE DATABASE AND WILL BE AUTOMATICALLY RESTORED AFTER UPDATES TO THE PLUGIN.</p><p>At any time you come back to this page, hit RESTORE, and you'll have access to the same template again.</p><p>If you make changes to your template, just return to this page and save it again. It's that simple.", 'wp-rss-multi-importer') . "</p>";
    } else {
        save_css();
    }
    die;
}
function wp_rss_multi_importer_template_page()
{
    ?>
	
	   <div class="wrap">
		<h2><label for="title"><?php 
    _e("How to Use Templates", 'wp-rss-multi-importer');
    ?>
</label></h2>
	<div id="poststuff">
<div class="postbox">

<div class="inside"><p>Many people have asked about styling their own RSS feed layouts on their sites.  While I've tried to provide many ways to do this, the first way is for me to construct various templates..which I've done and are now available in the pull-down menu on the Shortcode Settings panel.  If you don't want to mess with other templates, just use the default template (called DEFAULT).</p>
	
<p><a href="http://www.allenweiss.com/templates/" target="_blank">Go here to see what various templates look like</a>.</p>

<p>First, if you know some CSS you can change the styles of all the templates..and then save the CSS for use when the next update of the plugin happens.</p>

<p>To change the CSS, you can either FTP to your server, or an easier way is to edit the plugin's files...<a href="http://www.youtube.com/watch?v=H5HXzIBPD80" target="_blank">watch this video to see how to do this</a></p>


<p>Even more, if you know a bit of PHP coding, you can go in and make your own template.  All the templates are in the folder called Templates. I've included a file (called example.txt) that shows the foundation php code you must use with all templates.  Look through the other templates and you'll see other options you can include.</p>

<p>Also, now if you are using a template that you've changed or customized, you can save it.  Just choose a name for the template below, like (My great template), and hit save.  Then, when the plugin gets it's next update (that overwrites all the files) you can come back to this page, hit Restore, and your template will be available for use again.</p>
	
	
<p>Thank you.<br>Allen</p>
	
	</div></div></div></div>
<h2>Save Your Template</h2>
<?php 
    $options = get_option('rss_import_options');
    $thistemplate = $options['template'];
    save_template_function($thistemplate);
}