Skip to content

Commit

Permalink
safemode to constant
Browse files Browse the repository at this point in the history
changed safe mode into a constant
  • Loading branch information
rlankhorst committed Feb 26, 2017
1 parent 38e4bf1 commit 807e798
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
45 changes: 15 additions & 30 deletions class-admin.php
Expand Up @@ -29,7 +29,6 @@ class rsssl_admin extends rsssl_front_end {
public $ABSpath;

public $do_not_edit_htaccess = FALSE;
public $safe_mode = FALSE;
public $htaccess_redirect = FALSE;
public $htaccess_warning_shown = FALSE;
public $ssl_success_message_shown = FALSE;
Expand Down Expand Up @@ -382,7 +381,6 @@ public function get_admin_options(){
$this->plugin_db_version = isset($options['plugin_db_version']) ? $options['plugin_db_version'] : "1.0";
$this->debug = isset($options['debug']) ? $options['debug'] : FALSE;
$this->do_not_edit_htaccess = isset($options['do_not_edit_htaccess']) ? $options['do_not_edit_htaccess'] : FALSE;
$this->safe_mode = isset($options['safe_mode']) ? $options['safe_mode'] : FALSE;
$this->htaccess_redirect = isset($options['htaccess_redirect']) ? $options['htaccess_redirect'] : FALSE;
$this->debug_log = isset($options['debug_log']) ? $options['debug_log'] : $this->debug_log;
}
Expand Down Expand Up @@ -517,6 +515,9 @@ public function trace_log($msg) {
*/

public function configure_ssl() {
$safe_mode = FALSE;
if (defined('RSSSL_SAFE_MODE') && RSSSL_SAFE_MODE) $safe_mode = RSSSL_SAFE_MODE;

global $rsssl_server;
if (!current_user_can($this->capability)) return;
$this->trace_log("** Configuring SSL **");
Expand Down Expand Up @@ -544,16 +545,16 @@ public function configure_ssl() {
//only use .htaccess when explicitly acitvated in settings
if ($this->htaccess_redirect && $this->htaccess_test_success) {
$this->editHtaccess();
} elseif (!$this->safe_mode && $this->clicked_activate_ssl()) {
} elseif (!$safe_mode && $this->clicked_activate_ssl()) {
//set wp redirect, but only when just activated.
$this->wp_redirect = TRUE;
$this->save_options();
}

if (!$this->safe_mode && $this->wpconfig_siteurl_not_fixed)
if (!$safe_mode && $this->wpconfig_siteurl_not_fixed)
$this->fix_siteurl_defines_in_wpconfig();

if (!$this->safe_mode)
if (!$safe_mode)
$this->set_siteurl_to_ssl();
}
}
Expand Down Expand Up @@ -972,7 +973,6 @@ public function remove_wpconfig_edit() {
*/

public function set_siteurl_to_ssl() {
if (defined("RSSSL_DO_NOT_CHANGE_SITEURL") && RSSSL_DO_NOT_CHANGE_SITEURL) return;

if ($this->debug) {$this->trace_log("converting siteurl and homeurl to https");}
$siteurl_ssl = str_replace ( "http://" , "https://" , get_option('siteurl'));
Expand Down Expand Up @@ -1019,7 +1019,6 @@ public function save_options() {
'plugin_db_version' => $this->plugin_db_version,
'debug' => $this->debug,
'do_not_edit_htaccess' => $this->do_not_edit_htaccess,
'safe_mode' => $this->safe_mode,
'htaccess_redirect' => $this->htaccess_redirect,
'ssl_enabled' => $this->ssl_enabled,
'javascript_redirect' => $this->javascript_redirect,
Expand Down Expand Up @@ -1073,7 +1072,6 @@ public function deactivate($networkwide) {
$this->ssl_success_message_shown = FALSE;
$this->autoreplace_insecure_links = TRUE;
$this->do_not_edit_htaccess = FALSE;
$this->safe_mode = FALSE;
$this->htaccess_redirect = FALSE;
$this->javascript_redirect = FALSE;
$this->wp_redirect = FALSE;
Expand Down Expand Up @@ -2332,7 +2330,6 @@ public function create_form(){
}

add_settings_field('id_debug', __("Debug","really-simple-ssl"), array($this,'get_option_debug'), 'rlrsssl', 'rlrsssl_settings');
add_settings_field('id_safe_mode', __("Configure with safe mode","really-simple-ssl"), array($this,'get_option_safe_mode'), 'rlrsssl', 'rlrsssl_settings');

if ($rsssl_server->uses_htaccess())
add_settings_field('id_do_not_edit_htaccess', __("Stop editing the .htaccess file","really-simple-ssl"), array($this,'get_option_do_not_edit_htaccess'), 'rlrsssl', 'rlrsssl_settings');
Expand Down Expand Up @@ -2412,12 +2409,6 @@ public function options_validate($input) {
$newinput['do_not_edit_htaccess'] = FALSE;
}

if (!empty($input['safe_mode']) && $input['safe_mode']=='1') {
$newinput['safe_mode'] = TRUE;
} else {
$newinput['safe_mode'] = FALSE;
}

if (!empty($input['htaccess_redirect']) && $input['htaccess_redirect']=='1') {
$newinput['htaccess_redirect'] = TRUE;
} else {
Expand Down Expand Up @@ -2473,21 +2464,7 @@ public function get_option_wp_redirect() {

}

/**
* Insert option into settings form
*
* @since 2.5.8
*
* @access public
*
*/

public function get_option_safe_mode() {
$options = get_option('rlrsssl_options');
echo '<input id="rlrsssl_options" name="rlrsssl_options[safe_mode]" size="40" type="checkbox" value="1"' . checked( 1, $this->safe_mode, false ) ." />";

rsssl_help::this()->get_help_tip(__("If activating Really Simple SSL causes issues on your site, try the safe mode.", "really-simple-ssl")." ".__("The siteurl will be left as it is, and no redirect will be added. Only the mixed content fixer will be active.", "really-simple-ssl")." ".__("Then try activating the WordPress redirect.", "really-simple-ssl"));
}

/**
* Insert option into settings form
Expand All @@ -2502,7 +2479,15 @@ public function get_option_htaccess_redirect() {
$options = get_option('rlrsssl_options');
echo '<input id="rlrsssl_options" name="rlrsssl_options[htaccess_redirect]" size="40" type="checkbox" value="1"' . checked( 1, $this->htaccess_redirect, false ) ." />";

rsssl_help::this()->get_help_tip(__("A .htaccess redirect is faster. Really Simple SSL detects the best redirect code, but there are configurations where redirect loops might occur.", "really-simple-ssl")." ".__("If that happens, remove the redirect from the .htaccess again and add DEFINE('RLRSSSL_DO_NOT_EDIT_HTACCESS', TRUE); to your wp-config.php.", "really-simple-ssl"));
rsssl_help::this()->get_help_tip(__("A .htaccess redirect is faster. Really Simple SSL detects the best redirect code, but make sure you know how to regain access to your site if anything goes wrong!", "really-simple-ssl"));

$link_start = '<a target="_blank" href="https://really-simple-ssl.com/knowledge-base/remove-htaccess-redirect-site-lockout/">';
$link_end = '</a>';
printf(
__( 'Before you enable this, make sure you know how to %1$sregain access%2$s to your site in case of a redirect loop.', 'really-simple-ssl' ),
$link_start,
$link_end
);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions readme.txt
Expand Up @@ -76,8 +76,7 @@ If you are experiencing redirect loops on your site, try these [instructions](ht
= 2.5.8 =
* Removed automatic insertion of .htaccess redirects. The .htaccess redirects work fine for most people, but can cause issues in some edge cases.
* Added option to explicitly insert .htaccess redirect
* Added safe mode option to enable activating in a minimized way
* Added Constant RSSSL_DO_NOT_CHANGE_SITEURL which gives the option not to change the site url to https. In certain configurations a https url leads to redirect loops.
* Added safe mode constand RSSSL_SAFE_MODE to enable activating in a minimized way
* Fix: RLRSSSL_DO_NOT_EDIT_HTACCESS constant did not override setting correctly when setting was used before.
* Dropped cache flushing on activation, as this does not always work as expected

Expand Down

0 comments on commit 807e798

Please sign in to comment.