Exemplo n.º 1
0
function nirvana_page_fn()
{
    global $nirvana_cleanup_warnings;
    // Load the import form page if the import button has been pressed
    if (isset($_POST['nirvana_import'])) {
        nirvana_import_form();
        return;
    }
    // Load the import form  page after upload button has been pressed
    if (isset($_POST['nirvana_import_confirmed'])) {
        nirvana_import_file();
        return;
    }
    // Load the presets  page after presets button has been pressed
    if (isset($_POST['nirvana_presets'])) {
        nirvana_init_fn();
        nirvana_presets();
        return;
    }
    if (!current_user_can('edit_theme_options')) {
        wp_die(__('Sorry, but you do not have sufficient permissions to access this page.', 'nirvana'));
    }
    ?>
<div id="loading-big"></div>
<div class="wrap"><!-- Admin wrap page -->

<div id="lefty"><!-- Left side of page - the options area -->
<div>
	<div id="admin_header"><img src="<?php 
    echo get_template_directory_uri() . '/admin/images/nirvana-logo.png';
    ?>
" /> </div>
	<div id="admin_links">
		<a target="_blank" href="http://www.cryoutcreations.eu/nirvana">Nirvana Homepage</a>
		<a target="_blank" href="http://www.cryoutcreations.eu/forum">Support</a>
		<a target="_blank" href="http://www.cryoutcreations.eu">Cryout Creations</a>
	</div>
	<div style="clear: both;"></div>
</div>
<?php 
    if (isset($_GET['settings-updated'])) {
        echo "<div class='updated fade' style='clear:left;'><p>";
        echo _e('Nirvana settings updated successfully.', 'nirvana');
        echo "</p></div>";
    }
    // interference warning
    if (count($nirvana_cleanup_warnings['keys'])) {
        $cscript = $nirvana_cleanup_warnings['scripts'];
        $cstyle = $nirvana_cleanup_warnings['styles'];
        ?>
	<div class="error fade nirvana-self-protection"><p><b>Nirvana has protected its own page rendering process against <?php 
        echo $cscript + $cstyle . ' ' . ($cscript + $cstyle == 1 ? "incident" : "incidents");
        ?>
! [ <a href="#" onclick="jQuery('div.nirvana-self-protection-details').slideToggle(); return false;">Details</a> ]</b></p></div>
	<div class="error nirvana-self-protection-details"><p>
	Some authors of plugins and themes do not know or do not care about how they attach scripts and styles into WordPress backend pages. They affect pages belonging to other extensions with their own code/styling and damage the proper functionality of those pages.</p>
	<p>Nirvana includes an injection detection and blocking mechanism that (when enabled) will also display this warning and provide information on what extensions tried to load their resources into this page. The theme does this to protect itself from possible malfunctions that may be caused by external code.</p>
	<p>The following extensions/resources were blocked from interfering with this page:<p>
	<ul>
	<?php 
        foreach ($nirvana_cleanup_warnings['keys'] as $handle => $element) {
            ?>
			<li> <u><?php 
            echo $handle;
            ?>
</u> <br/>
					<?php 
            foreach ($element as $sub) {
                ?>
								&bull; <em><?php 
                echo $sub;
                ?>
</em> <br/>
					<?php 
            }
            ?>
			</li>
	<?php 
        }
        ?>
	<ul>
	</div>
<?php 
    }
    ?>
<div id="jsAlert" class=""><b>Checking jQuery functionality...</b><br/><em>If this message remains visible after the page has loaded then there is a problem with your WordPress jQuery library. This can have several causes, including poorly written plugins.
The Nirvana Settings page cannot function without jQuery. </em></div>
<?php 
    global $nirvanas;
    $nirvana_varalert = cryout_maxvarcheck(count($nirvanas));
    if ($nirvana_varalert) {
        ?>
<div id="varlimitalert"> <?php 
        echo $nirvana_varalert;
        ?>
 </div><?php 
    }
    ?>
	<div id="main-options">
		<form name="nirvana_form" id="nirvana_form" action="options.php" method="post" enctype="multipart/form-data">
			<div id="accordion">
				<?php 
    settings_fields('nirvana_settings');
    ?>
				<?php 
    do_settings_sections(__FILE__);
    ?>
			</div>
			<div id="submitDiv">
			    <br>
				<input class="button" name="nirvana_settings[nirvana_submit]" type="submit" id="nirvana_sumbit" style="float:right;"   value="<?php 
    _e('Save Changes', 'nirvana');
    ?>
" />
				<input class="button" name="nirvana_settings[nirvana_defaults]" id="nirvana_defaults" type="submit" style="float:left;" value="<?php 
    _e('Reset to Defaults', 'nirvana');
    ?>
" />
				</div>
		</form>
		<span id="version">
		Nirvana v<?php 
    echo NIRVANA_VERSION;
    ?>
 by <a href="http://www.cryoutcreations.eu" target="_blank">Cryout Creations</a>
		</span>
	</div><!-- main-options -->
</div><!--lefty -->


<div id="righty" ><!-- Right side of page - Coffee, RSS tips and others -->
	<div id="nirvana-donate" class="postbox donate">
	 <div title="Click to toggle" class="handlediv"><br /></div>
		<h3 class="hndle"> Coffee Break </h3>
		<div class="inside">
		<?php 
    echo "<p>We here at Cryout Creations have reached a higher state of mind. While meticulously crafting WordPress themes we have elevated to another dimension\r\n\t\twhere we have spent ages enhancing our cognitive development, growing infinitely wiser and more experienced. In this surreal place called Nirvana we've finally found\r\n\t\tthe answer to the question humanity has been asking itself since the dawn of time: <i>'What is the meaning of life?'</i> </p>\r\n\t\t<p>And now, thanks to us, that question has an absolute and undisputable answer: <i>'Coffee'</i>. Coffee is the answer to everything, the key to every lock,\r\n\t\tthe source code to the Universe. Coffee powers our bodies and minds and it's what our souls are made of. </p>\r\n\t<p>Also, it's a universal fact that when coffee takes the form of a question ('Coffee?') the answer will always be <i>'Yes, please'</i>, so...</p>";
    ?>
			<div style="display:block;float:none;margin:0 auto;text-align:center;">

			<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
				<input type="hidden" name="cmd" value="_donations">
				<input type="hidden" name="business" value="KYL26KAN4PJC8">
				<input type="hidden" name="item_name" value="Cryout Creations / Nirvana Theme donation">
				<input type="hidden" name="currency_code" value="EUR">
				<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_SM.gif:NonHosted">
				<input type="image" src="<?php 
    echo get_template_directory_uri() . '/admin/images/coffee.png';
    ?>
" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
				<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
			</form>

			</div>
			<p>Or socially smother, caress and embrace us:</p>
			<div style="display:table;float:none;margin:0 auto;">
				<div id="fb-root"></div><div class="fb-like" data-href="https://www.facebook.com/CryoutCreations" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div>
				<a href="https://twitter.com/cryoutcreations" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @cryoutcreations</a>
				<script src="https://apis.google.com/js/platform.js" async defer></script> <div class="g-plusone" data-href="https://plus.google.com/+CryoutcreationsEuCR2"  data-size="medium" data-annotation="none"></div>
			</div>

		</div><!-- inside -->
	</div><!-- donate -->

    <div id="nirvana-export" class="postbox export non-essential-option" style="overflow:hidden;">
            <div title="Click to toggle" class="handlediv"><br /></div>
           	<h3 class="hndle"><?php 
    _e('Import/Export Settings', 'nirvana');
    ?>
</h3>
        <div class="panel-wrap inside">
				<form action="" method="post">
                	<?php 
    wp_nonce_field('nirvana-export', 'nirvana-export');
    ?>
                    <input type="hidden" name="nirvana_export" value="true" />
                    <input type="submit" class="button" value="<?php 
    _e('Export Theme options', 'nirvana');
    ?>
" />
					<p class="imex-text"><?php 
    _e("It's that easy: a mouse click away - the ability to export your Nirvana settings and save them on your computer. Feeling safer? You should!", "nirvana");
    ?>
</p>
                </form>
				<br />
                <form action="" method="post">
                    <input type="hidden" name="nirvana_import" value="true" />
                    <input type="submit" class="button" value="<?php 
    _e('Import Theme options', 'nirvana');
    ?>
" />
					<p class="imex-text"><?php 
    _e("Without the import, the export would just be a fool's exercise. Make sure you have the exported file ready and see you after the mouse click.", "nirvana");
    ?>
</p>
                </form>
			 	<br />
				<form action="" method="post">
                    <input type="hidden" name="nirvana_presets" value="true" />
                    <input type="submit" class="button" id="presets_button" value="<?php 
    _e('Color Schemes', 'nirvana');
    ?>
" />
					<p class="imex-text"><?php 
    _e("A collection of preset color schemes to use as the starting point for your site. Just load one up and see your blog in a different light.", "nirvana");
    ?>
</p>
                </form>
		</div><!-- inside -->
	</div><!-- export -->

    <div id="nirvana-news" class="postbox news" >
	 <div title="Click to toggle" class="handlediv"><br /></div>
        		<h3 class="hndle"><?php 
    _e('Nirvana Latest News', 'nirvana');
    ?>
</h3>
            <div class="panel-wrap inside" style="height:200px;overflow:auto;">

            </div><!-- inside -->
    </div><!-- news -->

</div><!--  righty -->
</div><!--  wrap -->

<script type="text/javascript">
var reset_confirmation = '<?php 
    echo esc_html(__('Reset Nirvana Settings to Defaults?', 'nirvana'));
    ?>
';
var nirvana_help_icon = '<?php 
    echo get_template_directory_uri();
    ?>
/images/icon-tooltip.png';

jQuery(document).ready(function(){
	if (vercomp(jQuery.ui.version,"1.9.0")) {
		tooltip_terain();
		jQuery('.colorthingy').each(function(){
			id = "#"+jQuery(this).attr('id');
			startfarb(id,id+'2');
		});
	} else {
		jQuery("#main-options").addClass('oldwp');
		setTimeout(function(){jQuery('#nirvana_slideType').trigger('click')},1000);
		jQuery('.colorthingy').each(function(){
			id = "#"+jQuery(this).attr('id');
			jQuery(this).on('keyup',function(){coloursel(this)});
			coloursel(this);
		});
		/* warn about the old partially unsupported version */
		jQuery("#jsAlert").after("<div class='updated fade' style='clear:left; font-size: 16px;'><p>Nirvana has detected you are running an older version of Wordpress / jQuery. Some features may not work correctly. Consider updating your Wordpress to the latest version.</p></div>");
	}
});
jQuery('#jsAlert').hide();
</script>

<?php 
}
Exemplo n.º 2
0
function nirvana_page_fn()
{
    // Load the import form page if the import button has been pressed
    if (isset($_POST['nirvana_import'])) {
        nirvana_import_form();
        return;
    }
    // Load the import form  page after upload button has been pressed
    if (isset($_POST['nirvana_import_confirmed'])) {
        nirvana_import_file();
        return;
    }
    // Load the presets  page after presets button has been pressed
    if (isset($_POST['nirvana_presets'])) {
        nirvana_init_fn();
        nirvana_presets();
        return;
    }
    if (!current_user_can('edit_theme_options')) {
        wp_die(__('Sorry, but you do not have sufficient permissions to access this page.', 'nirvana'));
    }
    ?>
<div id="loading-big"></div>
<div class="wrap"><!-- Admin wrap page -->

<div id="lefty"><!-- Left side of page - the options area -->
<div>
	<div id="admin_header"><img src="<?php 
    echo get_template_directory_uri() . '/admin/images/nirvana-logo.png';
    ?>
" /> </div>
	<div id="admin_links">
		<a target="_blank" href="http://www.cryoutcreations.eu/nirvana">Nirvana Homepage</a>
		<a target="_blank" href="http://www.cryoutcreations.eu/forum">Support</a>
		<a target="_blank" href="http://www.cryoutcreations.eu">Cryout Creations</a>
	</div>
	<div style="clear: both;"></div>
</div>
<?php 
    if (isset($_GET['settings-updated'])) {
        echo "<div class='updated fade' style='clear:left;'><p>";
        echo _e('Nirvana settings updated successfully.', 'nirvana');
        echo "</p></div>";
    }
    ?>
<div id="jsAlert" class=""><b>Checking jQuery functionality...</b><br/><em>If this message remains visible after the page has loaded then there is a problem with your WordPress jQuery library. This can have several causes, including poorly written plugins.
The Nirvana Settings page cannot function without jQuery. </em></div>
<?php 
    global $nirvanas;
    $nirvana_varalert = cryout_maxvarcheck(count($nirvanas));
    if ($nirvana_varalert) {
        ?>
<div id="varlimitalert"> <?php 
        echo $nirvana_varalert;
        ?>
 </div><?php 
    }
    ?>
	<div id="main-options">
		<form name="nirvana_form" id="nirvana_form" action="options.php" method="post" enctype="multipart/form-data">
			<div id="accordion">
				<?php 
    settings_fields('nirvana_settings');
    ?>
				<?php 
    do_settings_sections(__FILE__);
    ?>
			</div>
			<div id="submitDiv">
			    <br>
				<input class="button" name="nirvana_settings[nirvana_submit]" type="submit" id="nirvana_sumbit" style="float:right;"   value="<?php 
    _e('Save Changes', 'nirvana');
    ?>
" />
				<input class="button" name="nirvana_settings[nirvana_defaults]" id="nirvana_defaults" type="submit" style="float:left;" value="<?php 
    _e('Reset to Defaults', 'nirvana');
    ?>
" />
				</div>
		</form>
		<span id="version">
		Nirvana v<?php 
    echo NIRVANA_VERSION;
    ?>
 by <a href="http://www.cryoutcreations.eu" target="_blank">Cryout Creations</a>
		</span>
	</div><!-- main-options -->
</div><!--lefty -->


<div id="righty" ><!-- Right side of page - Coffee, RSS tips and others -->
	<div id="nirvana-donate" class="postbox donate">
	 <div title="Click to toggle" class="handlediv"><br /></div>
		<h3 class="hndle"> Coffee Break </h3>
		<div class="inside">
		<?php 
    echo "<p>We here at Cryout Creations have reached a higher state of mind. While meticulously crafting WordPress themes we have elevated to another dimension\r\n\t\twhere we have spent ages enhancing our cognitive development, growing infinitely wiser and more experienced. In this surreal place called Nirvana we've finally found\r\n\t\tthe answer to the question humanity has been asking itself since the dawn of time: <i>'What is the meaning of life?'</i> </p>\r\n\t\t<p>And now, thanks to us, that question has an absolute and undisputable answer: <i>'Coffee'</i>. Coffee is the answer to everything, the key to every lock,\r\n\t\tthe source code to the Universe. Coffee powers our bodies and minds and it's what our souls are made of. </p>\r\n\t<p>Also, it's a universal fact that when coffee takes the form of a question ('Coffee?') the answer will always be <i>'Yes, please'</i>, so...</p>";
    ?>
			<div style="display:block;float:none;margin:0 auto;text-align:center;">
					
			<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
				<input type="hidden" name="cmd" value="_s-xclick">
				<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
							">
				<input type="image" src="<?php 
    echo get_template_directory_uri() . '/admin/images/coffee.png';
    ?>
" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
				<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
			</form>
			</div>
		</div><!-- inside -->
	</div><!-- donate -->

    <div id="nirvana-export" class="postbox export non-essential-option" style="overflow:hidden;">
            <div title="Click to toggle" class="handlediv"><br /></div>
           	<h3 class="hndle"><?php 
    _e('Import/Export Settings', 'nirvana');
    ?>
</h3>
        <div class="panel-wrap inside">
				<form action="" method="post">
                	<?php 
    wp_nonce_field('nirvana-export', 'nirvana-export');
    ?>
                    <input type="hidden" name="nirvana_export" value="true" />
                    <input type="submit" class="button" value="<?php 
    _e('Export Theme options', 'nirvana');
    ?>
" />
					<p class="imex-text"><?php 
    _e("It's that easy: a mouse click away - the ability to export your Nirvana settings and save them on your computer. Feeling safer? You should!", "nirvana");
    ?>
</p>
                </form>
				<br />
                <form action="" method="post">
                    <input type="hidden" name="nirvana_import" value="true" />
                    <input type="submit" class="button" value="<?php 
    _e('Import Theme options', 'nirvana');
    ?>
" />
					<p class="imex-text"><?php 
    _e("Without the import, the export would just be a fool's exercise. Make sure you have the exported file ready and see you after the mouse click.", "nirvana");
    ?>
</p>
                </form>
			<?php 
    /*	<br />
    			<form action="" method="post">
                       <input type="hidden" name="nirvana_presets" value="true" />
                       <input type="submit" class="button" id="presets_button" value="<?php _e('Color Schemes', 'nirvana'); ?>" />
    				<p class="imex-text"><?php _e("A collection of preset color schemes to use as the starting point for your site. Just load one up and see your blog in a different light.","nirvana"); ?></p>
                   </form>
    			*/
    ?>

		</div><!-- inside -->
	</div><!-- export -->

    <div id="nirvana-news" class="postbox news" >
	 <div title="Click to toggle" class="handlediv"><br /></div>
        		<h3 class="hndle"><?php 
    _e('Nirvana Latest News', 'nirvana');
    ?>
</h3>
            <div class="panel-wrap inside" style="height:200px;overflow:auto;">
             
            </div><!-- inside -->
    </div><!-- news -->


</div><!--  righty -->
</div><!--  wrap -->

<script type="text/javascript">
var reset_confirmation = '<?php 
    echo esc_html(__('Reset Nirvana Settings to Defaults?', 'nirvana'));
    ?>
';

function startfarb(a,b) {
	jQuery(b).css('display','none');
	jQuery(b).farbtastic(a).addtitle({id: a});

	jQuery(a).click(function() {
			if(jQuery(b).css('display') == 'none')	{
                                        			jQuery(b).parents('div:eq(0)').addClass('ui-accordion-content-overflow');
                                                    jQuery(b).css({'display':'inline-block','position':'absolute',marginLeft:'100px',opacity:0}).animate({opacity:1,marginLeft:'0px'},150);
                                                       }
	});

	jQuery(document).mousedown( function() {
		if(jQuery(b).css('display') != 'none') setTimeout(function () { jQuery(b).css('display','none');},150);
		jQuery(b).animate({opacity:0,marginLeft:'100px'},150, function(){ jQuery(b).parents('div:eq(0)').removeClass('ui-accordion-content-overflow'); });
			// todo: find a better way to remove class after the fade on IEs
	});
}

function tooltip_terain() {
jQuery('#accordion small').parent('div').append('<a class="tooltip"><img src="<?php 
    echo get_template_directory_uri();
    ?>
/images/icon-tooltip.png" /></a>').
	each(function() {
	//jQuery(this).children('a.tooltip').attr('title',jQuery(this).children('small').html() );
	var tooltip_info = jQuery(this).children('small').html();
	jQuery(this).children('.tooltip').tooltip({content : tooltip_info});
    jQuery(this).children('.tooltip').tooltip( "option", "items", "a" );
	//jQuery(this).children('.tooltip').tooltip( "option", "show", "false");
	jQuery(this).children('.tooltip').tooltip( "option", "hide", "false");
	jQuery(this).children('small').remove();
	if (!jQuery(this).hasClass('slmini') && !jQuery(this).hasClass('slidercontent') && !jQuery(this).hasClass('slideDivs')) jQuery(this).addClass('tooltip_div');
	});
}

function coloursel(el){
	var id = "#"+jQuery(el).attr('id');
	jQuery(id+"2").hide();
	var bgcolor = jQuery(id).val();
	if (bgcolor <= "#666666") { jQuery(id).css('color','#ffffff'); } else { jQuery(id).css('color','#000000'); };
	jQuery(id).css('background-color',jQuery(id).val());
}

function vercomp(ver, req) {
    var v = ver.split('.');
    var q = req.split('.');
    for (var i = 0; i < v.length; ++i) {
        if (q.length == i) { return true; } // v is bigger
        if (parseInt(v[i]) == parseInt(q[i])) { continue; } // nothing to do here, move along
        else if (parseInt(v[i]) > parseInt(q[i])) { return true; } // v is bigger
        else { return false; } // q is bigger
    }
    if (v.length != q.length) { return false; } // q is bigger
    return true; // v = q;
}

// farbtastic title addon function
(function($){
        $.fn.extend({
            addtitle: function(options) {
                var defaults = {
                    id: ''
                }
                var options = $.extend(defaults, options);
            return this.each(function() {
                    var o = options;
					var title = jQuery(o.id).attr('title');
                    if (title===undefined) { } else { jQuery(o.id+'2').children('.farbtastic').append('<span class="mytitle">'+title+'</span>'); }
            });
        }
        });
})(jQuery);


jQuery(document).ready(function(){
	//var _jQueryVer = parseFloat('.'+jQuery().jquery.replace(/\./g, ''));  // jQuery version as float, eg: 0.183
	//var _jQueryUIVer = parseFloat('.'+jQuery.ui.version.replace(/\./g, '')); // jQuery UI version as float, eg: 0.192
	//if (_jQueryUIVer >= 0.190) {
	if (vercomp(jQuery.ui.version,"1.9.0")) {
		tooltip_terain();
		jQuery('.colorthingy').each(function(){
			id = "#"+jQuery(this).attr('id');
			startfarb(id,id+'2');
		});
	} else {
		jQuery("#main-options").addClass('oldwp');
		setTimeout(function(){jQuery('#nirvana_slideType').trigger('click')},1000);
		jQuery('.colorthingy').each(function(){
			id = "#"+jQuery(this).attr('id');
			jQuery(this).on('keyup',function(){coloursel(this)});
			coloursel(this);
		});
		// warn about the old partially unsupported version
		jQuery("#jsAlert").after("<div class='updated fade' style='clear:left; font-size: 16px;'><p>Nirvana has detected you are running an older version of Wordpress / jQuery. Some features may not work correctly. Consider updating your Wordpress to the latest version.</p></div>");
	}
});
jQuery('#jsAlert').hide();
</script>

<?php 
}
Exemplo n.º 3
0
/**
 * This actual import of the options from the file to the settings array.
*/
function nirvana_import_file()
{
    global $nirvanas;
    /* Check authorisation */
    $authorised = true;
    // Check nonce
    if (!wp_verify_nonce($_POST['nirvana-import'], 'nirvana-import')) {
        $authorised = false;
    }
    // Check permissions
    if (!current_user_can('edit_theme_options')) {
        $authorised = false;
    }
    // If the user is authorised, import the theme's options to the database
    if ($authorised) {
        ?>
        <?php 
        // make sure there is an import file uploaded
        if (isset($_FILES["import"]["size"]) && $_FILES["import"]["size"] > 0) {
            $form_fields = array('import');
            $method = '';
            $url = wp_nonce_url('themes.php?page=nirvana-page', 'nirvana-import');
            // Get file writing credentials
            if (false === ($creds = request_filesystem_credentials($url, $method, false, false, $form_fields))) {
                return true;
            }
            if (!WP_Filesystem($creds)) {
                // our credentials were no good, ask the user for them again
                request_filesystem_credentials($url, $method, true, false, $form_fields);
                return true;
            }
            // Write the file if credentials are good
            $upload_dir = wp_upload_dir();
            $filename = trailingslashit($upload_dir['path']) . 'nirvanas.txt';
            // by this point, the $wp_filesystem global should be working, so let's use it to create a file
            global $wp_filesystem;
            if (!$wp_filesystem->move($_FILES['import']['tmp_name'], $filename, true)) {
                echo 'Error saving file!';
                return;
            }
            $file = $_FILES['import'];
            if ($file['type'] == 'text/plain') {
                $data = $wp_filesystem->get_contents($filename);
                // try to read the file
                if ($data !== FALSE) {
                    $settings = json_decode($data, true);
                    // try to read the settings array
                    if (isset($settings['nirvana_db'])) {
                        ?>
        <div class="wrap">
        <div id="icon-tools" class="icon32"><br></div>
        <h2><?php 
                        echo __('Import Nirvana Theme Options ', 'nirvana');
                        ?>
</h2> <?php 
                        $settings = array_merge($nirvanas, $settings);
                        update_option('nirvana_settings', $settings);
                        echo '<div class="updated fade"><p>' . __('Great! The options have been imported!', 'nirvana') . '<br />';
                        echo '<a href="themes.php?page=nirvana-page">' . __('Go back to the Nirvana options page and check them out!', 'nirvana') . '<a></p></div>';
                    } else {
                        // else: try to read the settings array
                        echo '<div class="error"><p><strong>' . __('Oops, there\'s a small problem.', 'nirvana') . '</strong><br />';
                        echo __('The uploaded file does not contain valid Nirvana options. Make sure the file is exported from the Nirvana Options page.', 'nirvana') . '</p></div>';
                        nirvana_import_form();
                    }
                } else {
                    // else: try to read the file
                    echo '<div class="error"><p><strong>' . __('Oops, there\'s a small problem.', 'nirvana') . '</strong><br />';
                    echo __('The uploaded file could not be read.', 'nirvana') . '</p></div>';
                    nirvana_import_form();
                }
            } else {
                // else: make sure the file uploaded was a plain text file
                echo '<div class="error"><p><strong>' . __('Oops, there\'s a small problem.', 'nirvana') . '</strong><br />';
                echo __('The uploaded file is not supported. Make sure the file was exported from the Nirvana page and that it is a text file.', 'nirvana') . '</p></div>';
                nirvana_import_form();
            }
            // Delete the file after we're done
            $wp_filesystem->delete($filename);
        } else {
            // else: make sure there is an import file uploaded
            echo '<div class="error"><p>' . __('Oops! The file is empty or there was no file. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'nirvana') . '</p></div>';
            nirvana_import_form();
        }
        echo '</div> <!-- end wrap -->';
    } else {
        wp_die(__('ERROR: You are not authorised to perform that operation', 'nirvana'));
    }
}