| 5 | | @define("LB_THEME", "widget"); |
|---|
| 6 | | // Type the Login-box theme |
|---|
| | 12 | // If a from was sended, update the options |
|---|
| | 13 | if ($_POST['submit']) { |
|---|
| | 14 | $newoptions['theme'] = strip_tags(stripslashes($_POST['loginbox-theme'])); |
|---|
| | 15 | $newoptions['key'] = strip_tags(stripslashes($_POST['loginbox-key'])); |
|---|
| | 16 | $newoptions['ctrl'] = strip_tags(stripslashes($_POST['loginbox-ctrl'])); |
|---|
| | 17 | $newoptions['backtopage'] = strip_tags(stripslashes($_POST['loginbox-backtopage'])); |
|---|
| | 18 | $newoptions['fade'] = strip_tags(stripslashes($_POST['loginbox-fade'])); |
|---|
| 8 | | @define("LB_KEY", "e"); |
|---|
| 9 | | // Choose the key (case insensitive) that will be open/close Login-box with Ctrl or Alt |
|---|
| 10 | | // Note that this may cancel the default function of the Ctrl/Alt + key of the browser |
|---|
| 11 | | // Ex: If you choose A, users cannot use Ctrl + A to select all texts in your blog |
|---|
| | 20 | // Merge new and old options |
|---|
| | 21 | // To use a unique database key for LB options and LB widget options |
|---|
| | 22 | $newoptions = array_merge($options, $newoptions); |
|---|
| | 23 | update_option('loginbox', $newoptions); |
|---|
| 17 | | @define("LB_BACKTOPAGE", true); |
|---|
| 18 | | // true: When login, you will be redirected to the actual page |
|---|
| 19 | | // false: When login, you will be redirected to the WordPress Dashboard |
|---|
| | 29 | echo '<div class="wrap">'; |
|---|
| | 30 | echo '<h2>Login-box</h2>'; |
|---|
| | 31 | ?> |
|---|
| | 32 | <form method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> |
|---|
| 25 | | // Only for development, you don't need change this |
|---|
| 26 | | //@define("LB_WPDIR", "/home/danillo/htdocs/wordpress/"); |
|---|
| | 37 | <?php |
|---|
| | 38 | function loginbox_get_themes() { |
|---|
| | 39 | $options = get_option('loginbox'); |
|---|
| | 40 | $olddir = getcwd(); |
|---|
| | 41 | chdir(ABSPATH.'/wp-content/plugins/login-box'); |
|---|
| | 42 | if ($dh = opendir('.')) { |
|---|
| | 43 | while (($file = readdir($dh)) !== false) { |
|---|
| | 44 | if (is_file($file.'/style.css')) { ?> |
|---|
| | 45 | <br/> |
|---|
| | 46 | <label> |
|---|
| | 47 | <input type="radio" name="loginbox-theme" value="<?php echo $file; ?>" |
|---|
| | 48 | <?php if ($options['theme'] == $file) echo 'checked="checked"'; ?> |
|---|
| | 49 | > |
|---|
| | 50 | <?php echo $file; ?> |
|---|
| | 51 | </label> |
|---|
| | 52 | <?php |
|---|
| | 53 | } |
|---|
| | 54 | } |
|---|
| | 55 | closedir($dh); |
|---|
| | 56 | } |
|---|
| | 57 | chdir($olddir); |
|---|
| | 58 | } |
|---|
| | 62 | </p> |
|---|
| | 63 | |
|---|
| | 64 | <p> |
|---|
| | 65 | <label><?php _e('Open with <strong>Alt</strong> +', 'login-box'); ?> |
|---|
| | 66 | <input type="text" name="loginbox-key" value="<?php echo $options['key']; ?>" size="1"> |
|---|
| | 67 | </label> |
|---|
| | 68 | |
|---|
| | 69 | <br/> |
|---|
| | 70 | <label> |
|---|
| | 71 | <input type="checkbox" name="loginbox-ctrl" value="1" <?php if ($options['ctrl']) echo 'checked="checked"'; ?>> |
|---|
| | 72 | <?php printf(__('Also open with <strong>Ctrl</strong> + <span>%s</span>', 'login-box'), $options['key']); ?> |
|---|
| | 73 | </label> |
|---|
| | 74 | </p> |
|---|
| | 75 | |
|---|
| | 76 | <p> |
|---|
| | 77 | <strong><?php _e('When login', 'login-box'); ?></strong>, |
|---|
| | 78 | |
|---|
| | 79 | <br/> |
|---|
| | 80 | <label> |
|---|
| | 81 | <input type="radio" name="loginbox-backtopage" value="1" <?php if ($options['backtopage']) echo 'checked="checked"'; ?>> |
|---|
| | 82 | <?php _e('Back to page', 'login-box'); ?> |
|---|
| | 83 | </label> |
|---|
| | 84 | |
|---|
| | 85 | <br/> |
|---|
| | 86 | <label> |
|---|
| | 87 | <input type="radio" name="loginbox-backtopage" value="0" <?php if ($options['backtopage'] == 0) echo 'checked="checked"'; ?>> |
|---|
| | 88 | <?php _e('Go to Dashboard', 'login-box'); ?> |
|---|
| | 89 | </label> |
|---|
| | 90 | </p> |
|---|
| | 91 | |
|---|
| | 92 | <p> |
|---|
| | 93 | <label> |
|---|
| | 94 | <input type="checkbox" name="loginbox-fade" value="1" <?php if ($options['fade']) echo 'checked="checked"'; ?>> |
|---|
| | 95 | <?php _e('Use <strong>fadeIn/fadeOut</strong> effects', 'login-box'); ?> |
|---|
| | 96 | </label> |
|---|
| | 97 | </p> |
|---|
| | 98 | |
|---|
| | 99 | <hr /> |
|---|
| | 100 | <p class="submit"> |
|---|
| | 101 | <input type="submit" id="submit" name="submit" value="<?php _e('Update Options ยป') ?>" /> |
|---|
| | 102 | </p> |
|---|
| | 103 | |
|---|
| | 104 | </form> |
|---|
| | 105 | </div> |
|---|
| | 106 | |
|---|
| | 107 | <?php |
|---|
| | 108 | } |
|---|
| | 109 | |
|---|
| | 110 | // Add the function above as a new page in WordPress panel |
|---|
| | 111 | function loginbox_add_page() { |
|---|
| | 112 | add_submenu_page('themes.php', 'Login-box', 'Login-box', 'edit_themes', 'login-box', 'loginbox_options'); |
|---|
| | 113 | } |
|---|
| | 114 | |
|---|
| | 115 | add_action('admin_menu', 'loginbox_add_page'); |
|---|
| | 116 | |
|---|
| | 117 | // Function to set default options and update in database |
|---|
| | 118 | function loginbox_set_default_options() { |
|---|
| | 119 | $options['theme'] = 'wp25'; |
|---|
| | 120 | $options['key'] = 'E'; |
|---|
| | 121 | $options['ctrl'] = '1'; |
|---|
| | 122 | $options['backtopage'] = '1'; |
|---|
| | 123 | $options['fade'] = '1'; |
|---|
| | 124 | |
|---|
| | 125 | update_option('loginbox', $options); |
|---|
| | 126 | } |
|---|
| | 127 | |
|---|
| | 128 | // Now, defines the options as constants, to be used by Login-box core |
|---|
| | 129 | function loginbox_set_options() { |
|---|
| | 130 | $options = get_option('loginbox'); |
|---|
| | 131 | |
|---|
| | 132 | if (!defined('LB_THEME')) define("LB_THEME", $options['theme']); |
|---|
| | 133 | if (!defined('LB_KEY')) define("LB_KEY", $options['key']); |
|---|
| | 134 | if (!defined('LB_CTRL')) define("LB_CTRL", $options['ctrl']); |
|---|
| | 135 | if (!defined('LB_BACKTOPAGE')) define("LB_BACKTOPAGE", $options['backtopage']); |
|---|
| | 136 | if (!defined('LB_AUTO')) define("LB_AUTO", true); |
|---|
| | 137 | } |
|---|
| | 138 | |
|---|
| | 139 | loginbox_set_options(); |
|---|
| | 140 | ?> |
|---|