<?php\r
+define( 'WP_CACHE', true ); // Added by WP Rocket\r
+\r
+// Check if a freeze has been placed on the site, thereby logging out all users temporarily\r
+// and only allowing whitelisted users to login. See mu-plugins/physioassist/Common/FreezeChanges.php\r
+// This is triggered by the presence of a "_FREEZE_CHANGES_ON" file in the site root\r
+if (file_exists(dirname(__FILE__) . '/_FREEZE_CHANGES_ON')) {\r
+ define('SITE_FREEZE_ACTIVATED', true);\r
+}\r
\r
// Include local configuration\r
if (file_exists(dirname(__FILE__) . '/local-config.php')) {\r
*\r
* @since 2.6.0\r
*/\r
-define('AUTH_KEY', '_SX[2QPUmv6=+HOITzjq/&l[@S$-7iN$0l`ID7_cSBWW!HgP(^7K?h~]q4,)GGB{');\r
-define('SECURE_AUTH_KEY', 'Kmhs<`Sr.c&_U,{E?86+.GNg4tMIj#$N:=IvM-cRv@PE8WsUySAy2W;+{Fp:z+Xw');\r
-define('LOGGED_IN_KEY', ' E2;B@c2HVqB3o+6*yS{t9#j.N_^SV5,^ *NRMDz)%Y&X/4n0Iq(k^*9#r2c 4bD');\r
-define('NONCE_KEY', ']@DKr;JdHp^Z n,aJ;M>/22(;nNi;*~2jaoBJA-a@R&Y-$_M&(#}{sUz%>-GXf m');\r
-define('AUTH_SALT', '(w^_55`>`zS+Zfg,xfx%T=3cmAa[j>FZ~So&Xd)P?[NGtX(%+yrAwMi,;(XF+M3T');\r
-define('SECURE_AUTH_SALT', 'MAIXLPhm]-S/yabF![Bt>cEE+ >_`<Wa1?}W:MttQ2D;_}|FGTIP*QqdU}s<hJay');\r
-define('LOGGED_IN_SALT', 'nx0#K[8+P_`_d&OrsyVxlv=``J)epV5Rh.e{wM2Z*xmyZ$#iXiwI9u,6_}eRP5)m');\r
-define('NONCE_SALT', 's.!6@Tc.P0y--=fo5&.J@*|_j3H-fY]:b2t->[,_UxYpABdmFWf/8j5f1B9=czh;');\r
\r
+// If the site is frozen, we'll use a different set of keys and salts\r
+// in order to temporarily force everyone to be logged out...\r
+if (defined('SITE_FREEZE_ACTIVATED')) {\r
+ // Keys and salts used when site is frozen:\r
+ define('AUTH_KEY', '2rG$l?aI85NG!->{c<yiK ~Uw|LAH^+|YPK]Y^UEG|vZOjNZr~xkB7]k|St_AGL=');\r
+ define('SECURE_AUTH_KEY', 'tG2-`Ke_I-4F|%?=)RK~1Os{<o+Zg$%B5Wl4v3k |dF-hbF-*ehOA[r&qIW};OKm');\r
+ define('LOGGED_IN_KEY', 'x[CQUu3EEk0@z@}FU~g!*:jBb& tG-Lq0/^$|eUkm~OwzWKZ*^h>~h/@{`*oxw?-');\r
+ define('NONCE_KEY', '-;Z4?gF.a-uyJXzE:d)%>1udaKj[vaw^vJJa)OPxu8jWw?BJas gUMz/|`M^g;kT');\r
+ define('AUTH_SALT', '|wStJ`g@;jgt&b.yYbO|1$h_4M9qT^xR{N>; uhY|+V^|+s09sLtI]h4LW@G-3n9');\r
+ define('SECURE_AUTH_SALT', 'TU@)N+{j/7X]9F8Aw5>uuEA2F[_~pb(^P7qVe0wBK|Z0#LHRx~EW?AyrcOGOS!V3');\r
+ define('LOGGED_IN_SALT', 'E+Qa@BQHA!rx}o:;%IaRc|ZP>pX7il3/VD)ss`.n$`K4+t>:yxn.7)6B~j~H#mRq');\r
+ define('NONCE_SALT', 'pvrZi%qile&{&D_1}[cU7<OH}uv1nECWPkhh`}W[f4<>w VdI)F@-|aGqhK|/|Mc');\r
+} else {\r
+ // Standard keys and salts when site is unfrozen:\r
+ define('AUTH_KEY', '_SX[2QPUmv6=+HOITzjq/&l[@S$-7iN$0l`ID7_cSBWW!HgP(^7K?h~]q4,)GGB{');\r
+ define('SECURE_AUTH_KEY', 'Kmhs<`Sr.c&_U,{E?86+.GNg4tMIj#$N:=IvM-cRv@PE8WsUySAy2W;+{Fp:z+Xw');\r
+ define('LOGGED_IN_KEY', ' E2;B@c2HVqB3o+6*yS{t9#j.N_^SV5,^ *NRMDz)%Y&X/4n0Iq(k^*9#r2c 4bD');\r
+ define('NONCE_KEY', ']@DKr;JdHp^Z n,aJ;M>/22(;nNi;*~2jaoBJA-a@R&Y-$_M&(#}{sUz%>-GXf m');\r
+ define('AUTH_SALT', '(w^_55`>`zS+Zfg,xfx%T=3cmAa[j>FZ~So&Xd)P?[NGtX(%+yrAwMi,;(XF+M3T');\r
+ define('SECURE_AUTH_SALT', 'MAIXLPhm]-S/yabF![Bt>cEE+ >_`<Wa1?}W:MttQ2D;_}|FGTIP*QqdU}s<hJay');\r
+ define('LOGGED_IN_SALT', 'nx0#K[8+P_`_d&OrsyVxlv=``J)epV5Rh.e{wM2Z*xmyZ$#iXiwI9u,6_}eRP5)m');\r
+ define('NONCE_SALT', 's.!6@Tc.P0y--=fo5&.J@*|_j3H-fY]:b2t->[,_UxYpABdmFWf/8j5f1B9=czh;');\r
+}\r
/**#@-*/\r
\r
/**\r
--- /dev/null
+<?php
+
+namespace PhysioAssist\Common;
+
+class FreezeChanges {
+
+ // List of usernames allowed to login even when the freeze is in place
+ protected $login_whitelist = [
+ 'cubedesigners',
+ ];
+
+ /**
+ * Determine if site is in freeze-mode and if users should be stopped from logging in
+ */
+ public function register() {
+
+ // The site freeze will be triggered in wp-config.php if a special _FREEZE_CHANGES_ON file is present
+ // This will cause the constant SITE_FREEZE_ACTIVATED to be defined and for the security keys to
+ // be temporarily changed, thereby forcing everyone to be logged out. Upon logging back in during
+ // a freeze, we can check if the user is on the login whitelist or not...
+ if (defined('SITE_FREEZE_ACTIVATED')) {
+ add_action('wp_login', [$this, 'check_login'], 10, 2); // Hook into the post-login action
+ add_filter('login_message', [$this, 'login_message']);
+ add_action('admin_notices', [$this, 'admin_notice']);
+ }
+
+ }
+
+ public function check_login($user_login, $user = null) {
+
+ if (!$user) $user = get_user_by('login', $user_login);
+ if (!$user) return; // not logged in
+
+ // Check if this user is whitelisted to login
+ if (in_array(strtolower($user_login), $this->login_whitelist)) return;
+
+ // If we got this far, the user isn't whitelisted...
+ // Clear cookies to log user out
+ wp_clear_auth_cookie();
+
+ // Redirect back to login page with flag to display message that site is frozen
+ $login_url = site_url('wp-login.php', 'login');
+ $login_url = add_query_arg('frozen', '1', $login_url);
+ wp_redirect($login_url);
+ exit;
+ }
+
+ public function login_message($message) {
+
+ // Show message to users who try logging in while site is frozen
+ if (isset($_GET['frozen']) && $_GET['frozen'] == 1) {
+ $message = '<div id="login_error">'. __("Sorry, the website is currently locked for critical updates. No logins or changes can be made during this period. Please try again later.", 'physioassist') .'</div>';
+ }
+
+ return $message;
+
+ }
+
+ public function admin_notice() {
+ echo '<div class="error"><p><strong>NOTICE: Site freeze currently active. Rename file <code>_FREEZE_CHANGES_ON</code> in the web root to disable.</strong></p></div>';
+ }
+
+}
public static function classes() {
return [
Common\Setup::class,
+ Common\FreezeChanges::class,
Elementor\Setup::class,
WooCommerce\Setup::class,
CookieNotice\Setup::class,
// Get available languages from WPML
public function languages() {
- return apply_filters( 'wpml_active_languages', NULL, 'skip_missing=0');
+ $languages = apply_filters( 'wpml_active_languages', NULL, 'skip_missing=0');
+
+ // In some situations, like WooCommerce product pages, which are not translatable,
+ // WPML will return an empty languages array. In this case, we don't want to German.
+ if (empty($languages)) return $languages;
+
+ // The DE locale has been split from the original site. We need to manually
+ // add it here, so it still appears in the language switcher...
+ $languages['de'] = [
+ 'code' => 'de',
+ 'id' => '3',
+ 'native_name' => 'Deutsch',
+ 'major' => '1',
+ 'active' => '0',
+ 'default_locale' => 'de_DE',
+ 'encode_url' => '0',
+ 'tag' => 'de',
+ 'translated_name' => 'Deutsch',
+ 'url' => 'https://www.physioassist.de/',
+ 'language_code' => 'de',
+ ];
+
+ return $languages;
}
}