PluginProbe
Virtual Robots.txt / trunk
Virtual Robots.txt vtrunk
pc-robotstxt / admin.php

admin.php in Virtual Robots.txt trunk, at admin.php

65 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class pc_robotstxt_admin {
3
4 function __construct() {
5 // stuff to do when the plugin is loaded
6 add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
7 }
8
9 function admin_menu() {
10 add_options_page( 'Virtual Robots.txt Settings', 'Virtual Robots.txt', 'manage_options', __FILE__, array( &$this, 'settings_page' ) );
11 }// end function
12
13 function settings_page() {
14
15 global $pc_robotstxt;
16 $options = $pc_robotstxt->get_options();
17
18 $protocol = ( ( !empty($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ) || $_SERVER['SERVER_PORT'] == 443 ) ? "https://" : "http://";
19 $host = $_SERVER['HTTP_HOST'];
20
21 if ( isset($_POST['update']) ) {
22
23 // check user is authorised
24 if ( function_exists( 'current_user_can' ) && !current_user_can( 'manage_options' ) ) {
25 die( 'Sorry, not allowed...' );
26 }
27 check_admin_referer( 'pc_robotstxt_settings' );
28
29 $options['user_agents'] = trim( $_POST['user_agents'] );
30
31 isset( $_POST['remove_settings'] ) ? $options['remove_settings'] = true : $options['remove_settings'] = false;
32
33 update_option( 'pc_robotstxt', $options );
34
35 echo '<div id="message" class="updated fade"><p><strong>Settings saved.</strong></p></div>';
36
37 }// end if
38
39 echo '<div class="wrap">'
40 .'<h2>Virtual Robots.txt Settings</h2>'
41 .'<form method="post">';
42 if ( function_exists( 'wp_nonce_field' ) ) wp_nonce_field( 'pc_robotstxt_settings' );
43 echo '<h3>User Agents and Directives for this site</h3>'
44 .'<p>The default rules that are set when the plugin is first activated are appropriate for WordPress.</p>'
45 .'<p>You can <a href="' . $protocol . $host . '/robots.txt" target="_blank" onclick="window.open(\'' . $protocol . $host . '/robots.txt\', \'popupwindow\', \'resizable=1,scrollbars=1,width=760,height=500\');return false;">preview your robots.txt file here</a> (opens a new window). If your robots.txt file doesn\'t match what is shown below, you may have a physical file that is being displayed instead.</p>'
46 .'<table class="form-table">'
47 .'<tr>'
48 .'<td colspan="2"><textarea name="user_agents" rows="6" id="user_agents" style="width:99%;height:300px;">' .strip_tags( stripslashes( $options['user_agents'] ) ) . '</textarea></td>'
49 .'</tr>'
50 .'<tr>'
51 .'<th scope="row">Delete settings when deactivating this plugin:</th>'
52 .'<td><input type="checkbox" id="remove_settings" name="remove_settings"';
53 if ( $options['remove_settings'] ) echo 'checked="checked"';
54 echo ' /> <span class="setting-description">When you tick this box all saved settings will be deleted when you deactivate this plugin.</span></td>'
55 .'</tr>'
56 .'</table>'
57 .'<p class="submit"><input type="submit" name="update" class="button-primary" value="Save Changes" /></p>'
58 .'</form>'
59 .'</div>';
60
61 }// end function
62
63 }// end class
64 $pc_robotstxt_admin = new pc_robotstxt_admin;
65