Skip to content

Commit

Permalink
Added setting for where the admin menu appears.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Ems committed Apr 21, 2012
1 parent 4342196 commit 38aa30d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
19 changes: 15 additions & 4 deletions admin/templates/metabox/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$ssl_host = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $ssl_host, $count);
$ssl_host = rtrim($ssl_host, '/');
?>
<form name="form" id="<?php echo $this->getPlugin()->getSlug(); ?>" action="admin.php?page=wordpress-https" method="post">
<form name="form" id="<?php echo $this->getPlugin()->getSlug(); ?>" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
<?php settings_fields($this->getPlugin()->getSlug()); ?>

<table class="form-table">
Expand Down Expand Up @@ -61,9 +61,9 @@
<td>
<fieldset>
<label for="ssl_proxy" class="label-radio">
<input type="radio" name="ssl_proxy" value="0"<?php echo ((! $this->getPlugin()->getSetting('ssl_proxy')) ? ' checked="checked"' : ''); ?>> No
<input type="radio" name="ssl_proxy" value="auto"<?php echo (($this->getPlugin()->getSetting('ssl_proxy') === 'auto') ? ' checked="checked"' : ''); ?>> Auto
<input type="radio" name="ssl_proxy" value="1"<?php echo (($this->getPlugin()->getSetting('ssl_proxy') == 1) ? ' checked="checked"' : ''); ?>> Yes
<input type="radio" name="ssl_proxy" value="0"<?php echo ((! $this->getPlugin()->getSetting('ssl_proxy')) ? ' checked="checked"' : ''); ?>> <span>No</span>
<input type="radio" name="ssl_proxy" value="auto"<?php echo (($this->getPlugin()->getSetting('ssl_proxy') === 'auto') ? ' checked="checked"' : ''); ?>> <span>Auto</span>
<input type="radio" name="ssl_proxy" value="1"<?php echo (($this->getPlugin()->getSetting('ssl_proxy') == 1) ? ' checked="checked"' : ''); ?>> <span>Yes</span>
</label>
</fieldset>
</td>
Expand All @@ -80,6 +80,17 @@
</fieldset>
</td>
</tr>
<tr valign="top" id="admin_menu_row">
<th scope="row">Admin Menu</th>
<td>
<fieldset>
<label for="admin_menu" class="label-radio">
<input type="radio" name="admin_menu" value="side"<?php echo (($this->getPlugin()->getSetting('admin_menu') === 'side') ? ' checked="checked"' : ''); ?>> <span>Admin Sidebar</span>
<input type="radio" name="admin_menu" value="settings"<?php echo (($this->getPlugin()->getSetting('admin_menu') === 'settings') ? ' checked="checked"' : ''); ?>> <span>General Settings</span>
</label>
</fieldset>
</td>
</tr>
</table>

<input type="hidden" name="action" value="save" />
Expand Down
1 change: 1 addition & 0 deletions lib/WordPressHTTPS.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class WordPressHTTPS extends WordPressHTTPS_Plugin {
'ssl_admin' => 0, // Force SSL Over Administration Panel (The same as FORCE_SSL_ADMIN)
'ssl_proxy' => 0, // Proxy detection
'debug' => 0, // Debug Mode
'admin_menu' => 'side', // HTTPS Admin Menu location
);

/**
Expand Down
8 changes: 5 additions & 3 deletions lib/WordPressHTTPS/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ public function admin_enqueue_scripts() {
* @return void
*/
public function menu() {
add_menu_page('HTTPS', 'HTTPS', 'manage_options', $this->getPlugin()->getSlug(), array($this->getPlugin()->getModule('Admin\Settings'), 'dispatch'), '', 88);
//remove_submenu_page( $this->getPlugin()->getSlug(), $this->getPlugin()->getSlug() );
//add_submenu_page($this->getPlugin()->getSlug() . '-menu', 'Updates', 'Updates', 'manage_options', $this->getPlugin()->getSlug() . '-updates', array(&$this, 'dispatch'));
if ( $this->getPlugin()->getSetting('admin_menu') === 'side' ) {
add_menu_page('HTTPS', 'HTTPS', 'manage_options', $this->getPlugin()->getSlug(), array($this->getPlugin()->getModule('Admin\Settings'), 'dispatch'), '', 88);
} else {
add_options_page('HTTPS', 'HTTPS', 'manage_options', $this->getPlugin()->getSlug(), array($this->getPlugin()->getModule('Admin\Settings'), 'dispatch'));
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/WordPressHTTPS/Module/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function init() {
add_action('plugins_loaded', array(&$this, 'save'), 1);
}

add_action('toplevel_page_' . $this->getPlugin()->getSlug(), array(&$this, 'add_meta_boxes'));
add_action('admin_init', array(&$this, 'add_meta_boxes'));

// Add scripts
add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'));
Expand Down

0 comments on commit 38aa30d

Please sign in to comment.