function themedrive_options_page()
{
    global $themedrive_localversion;
    global $wp_themedrive_plugin_url;
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && !wp_verify_nonce(@$_POST['_wpnonce'], 'theme-drive')) {
        wp_die('Nonce invalid. Please re-submit the form.');
        exit;
    }
    if (isset($_POST['button']) && 'Enable Theme Drive' == $_POST['button']) {
        check_admin_referer('theme-drive');
        $themedrive = $_POST['td_themes'];
        update_option('td_themes', $themedrive);
        $access_level = (int) $_POST['access_level'];
        update_option('td_level', $access_level);
        $msg_status = "Theme Test Drive Enabled for administrator with " . $themedrive . ' theme.';
        // Show message
        echo '<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>';
    } elseif (isset($_POST['button']) && 'Disable Theme Drive' == $_POST['button']) {
        check_admin_referer('theme-drive');
        // Delete the option from the DB if it's empty
        delete_option('td_themes');
        $msg_status = "Theme Test Drive has been disabled.";
        // Show message
        echo '<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>';
    }
    $access_level = get_option('td_level');
    if (empty($access_level)) {
        $access_level = '10';
    }
    $imgpath = $wp_themedrive_plugin_url . 'i';
    ?>
  
  <div class="wrap" >
  <h2>Theme Test Drive</h2>
        
  <div id="poststuff" style="margin-top:10px;">
  
   <div id="sideblock" style="float:right;width:270px;margin-left:10px;"> 

		<div class="ad">
					<a href="https://managewp.com/?utm_source=Plugins&amp;utm_medium=Banner&amp;utm_content=mwp250_2&amp;utm_campaign=ThemeTestDrive" title="ManageWP.com - Manage your sites from one dashboard"><img src="<?php 
    echo $imgpath;
    ?>
/mwp250_2.png" alt="ManageWP.com - Manage Multiple WordPress Sites"></a>
					</div>
 	</div>
  
   <div id="mainblock" style="width:710px">
	<?php 
    $action_url;
    ?>
    <div class="dbx-content">
	<?php 
    if (!isset($action_url)) {
        $action_url = '';
    }
    ?>
       <form name="form_apu" method="post" action="<?php 
    echo $action_url;
    ?>
">
       <?php 
    wp_nonce_field('theme-drive');
    if (isset($_POST['theme_install'])) {
        echo '<h3>Theme installation</h3>';
        $install_theme = !isset($_POST['install_theme']) ? '' : $_POST['install_theme'];
        if ($install_theme != '') {
            themedrive_handle_theme($install_theme);
        } else {
            echo "No theme URL specified.<br>";
        }
        echo '<br><br>';
    }
    ?>

 
 
   <h2>Usage</h2>
   <ul>
  <li>1. Select a theme to preview live on the site from the box below (lists all installed themes). </li> 	
  <li>2. Enable Theme Test drive</li>
  <li>3. Once you have customized the theme to my liking, disable Theme Test Drive and enable the theme in WordPress. It will keep all previous settings. (sometimes depending on the theme setting are not saved. I am still investigating this)</li>
   	</ul>
   	<p>Notes: Only administrator will be able to see the selected theme in Theme Test Drive. The site will show your normal theme to everyone else.</p>
  
<p>Additionally you may add "?theme=xxx" to your blog url, where xxx is the slug of the theme you want to test.</p>
<?php 
    themedrive_switcher();
    ?>
<p>You can specify the level of users to have access to the selected theme preview. By default it is set to 10 (admin only). Level 7 are editors, level 4 are authors and level 1 are contributors. The access level is ignored for accessing the site with ?theme=xxx paramaeter. </p>
<input style="border:1px solid #D1D1D1;width:100px;" name="access_level" id="access_level" value="<?php 
    echo esc_attr($access_level);
    ?>
" /> Access level<br />
<p>
<strong>Disabling:</strong> If you wish to stop using Theme Test Drive, press <em>Disable</em> button.
Alternatively, disabling this plug-in should also do the trick.
</p>


<p class="submit">

<input type="submit" name="button" value="Disable Theme Drive" class="button-primary" />

<input type="submit" name="button" value="Enable Theme Drive" class="button-primary" />


</p>


  <h2>Easy Theme Installation</h2>
       
       Enter the URL to the theme zip file and click Install theme.<br><br>
       <input style="border:1px solid #D1D1D1;width:400px;" name="install_theme" id="install_theme" value="" />
      <br>
      <input class="button" type="submit" name="theme_install" value="Install theme &raquo;" class="button-primary" />
  <br /><br />

  
</form>

</div>
</div>
</div>
<h4>a plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h4>
</div>


<?php 
}
Example #2
0
function themedrive_options_page()
{
    global $themedrive_localversion;
    global $wp_themedrive_plugin_url;
    $status = themedrive_getinfo();
    $theVersion = isset($status[1]) ? $status[1] : '';
    $theMessage = isset($status[3]) ? $status[3] : '';
    if (version_compare(strval($theVersion), strval($themedrive_localversion), '>') == 1) {
        $msg = 'Latest version available ' . ' <strong>' . $theVersion . '</strong><br />' . $theMessage;
        echo '<div id="message" class="updated fade"><p>' . $msg . '</p></div>';
    }
    if (isset($_POST['button']) && 'Enable Theme Drive' == $_POST['button']) {
        check_admin_referer('theme-drive');
        $themedrive = $_POST['td_themes'];
        update_option('td_themes', $themedrive);
        $access_level = (int) $_POST['access_level'];
        update_option('td_level', $access_level);
        $msg_status = "Theme Test Drive Enabled for administrator with " . $themedrive . ' theme.';
        // Show message
        echo '<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>';
    } elseif (isset($_POST['button']) && 'Disable Theme Drive' == $_POST['button']) {
        check_admin_referer('theme-drive');
        // Delete the option from the DB if it's empty
        delete_option('td_themes');
        $msg_status = "Theme Test Drive has been disabled.";
        // Show message
        echo '<div id="message" class="updated fade"><p>' . $msg_status . '</p></div>';
    }
    $access_level = get_option('td_level');
    //if (empty($access_level))
    //  $access_level = '10';
    $imgpath = $wp_themedrive_plugin_url . '/i';
    ?>
  
  <div class="wrap" >
  <h2>Theme Test Drive</h2>
        
  <div id="poststuff" style="margin-top:10px;">
  
   <div id="sideblock" style="float:right;width:270px;margin-left:10px;"> 

		 <iframe width=270 height=800 frameborder="0" src="http://www.prelovac.com/plugin/news.php?id=5&utm_source=plugin&utm_medium=plugin&utm_campaign=Theme%2BTest%2BDrive"></iframe>

 	</div>
  
   <div id="mainblock" style="width:710px">
	<?php 
    $action_url;
    ?>
    <div class="dbx-content">
	<?php 
    if (!isset($action_url)) {
        $action_url = '';
    }
    ?>
       <form name="form_apu" method="post" action="<?php 
    echo $action_url;
    ?>
">
       <?php 
    wp_nonce_field('theme-drive');
    if (isset($_POST['theme_install'])) {
        echo '<h3>Theme installation</h3>';
        $install_theme = !isset($_POST['install_theme']) ? '' : $_POST['install_theme'];
        if ($install_theme != '') {
            themedrive_handle_theme($install_theme);
        } else {
            echo "No theme URL specified.<br>";
        }
        echo '<br><br>';
    }
    ?>

 
   <h3>Easy Theme Installation</h3>
       
       Enter the URL to the theme zip file and click Install theme.<br><br>
       <input style="border:1px solid #D1D1D1;width:400px;" name="install_theme" id="install_theme" value="" />
      <br>
      <input class="button" type="submit" name="theme_install" value="Install theme &raquo;" class="button-primary" />
  <br /><br />
   <h3>Usage</h3>
  <p>Select a theme to preview live on the site. Only administrator will be able to see the selected theme. </p>                          
<p>Additionally you may add "?theme=xxx" to your blog url, where xxx is the theme name you want to test.</p>
<?php 
    themedrive_switcher();
    ?>
<p>You can specify the level of users to have access to the selected theme preview. By default it is set to 10 (admin only). Level 7 are editors, level 4 are authors and level 1 are contributors. The access level is ignored for accessing the site with ?theme=xxx paramaeter. </p>
<input style="border:1px solid #D1D1D1;width:100px;" name="access_level" id="access_level" value="<?php 
    echo esc_attr($access_level);
    ?>
" /> Access level<br />
<p>
<strong>Disabling:</strong> If you wish to stop using Theme Test Drive, press <em>Disable</em> button.
Alternatively, disabling this plug-in should also do the trick.
</p>


<p class="submit">

<input type="submit" name="button" value="Disable Theme Drive" class="button-primary" />

<input type="submit" name="button" value="Enable Theme Drive" class="button-primary" />


</p>

</form>

</div>
</div>
</div>
<h4>a plugin by <a href="http://www.prelovac.com/vladimir/">Vladimir Prelovac</a></h4>
</div>


<?php 
}