| 1 |
<?php |
| 2 |
/* |
| 3 |
* This file has the sole purpose to help solve compatibility issues with other plugins |
| 4 |
* |
| 5 |
*/ |
| 6 |
|
| 7 |
|
| 8 |
/**************************************************** |
| 9 |
* Plugin Name: Captcha |
| 10 |
* Plugin URI: https://wordpress.org/plugins/captcha/ |
| 11 |
****************************************************/ |
| 12 |
|
| 13 |
/* |
| 14 |
* Function that ads the Captcha HTML to Profile Builder login form |
| 15 |
* |
| 16 |
*/ |
| 17 |
if( function_exists('cptch_display_captcha_custom') ) { |
| 18 |
function wppb_captcha_add_form_login($form_part, $args) { |
| 19 |
|
| 20 |
$cptch_options = get_option('cptch_options'); |
| 21 |
if( !empty( $cptch_options['cptch_login_form'] ) && 1 == $cptch_options['cptch_login_form'] ) |
| 22 |
$form_part .= cptch_display_captcha_custom(); |
| 23 |
elseif( !empty( $cptch_options['forms']['wp_login']['enable'] ) && $cptch_options['forms']['wp_login']['enable'] ) |
| 24 |
$form_part .= cptch_display_captcha_custom(); |
| 25 |
|
| 26 |
return $form_part; |
| 27 |
} |
| 28 |
|
| 29 |
add_filter('login_form_middle', 'wppb_captcha_add_form_login', 10, 2); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
/* |
| 34 |
* Function that ads the Captcha HTML to Profile Builder form builder |
| 35 |
* |
| 36 |
*/ |
| 37 |
if( function_exists('cptch_display_captcha_custom') ) { |
| 38 |
|
| 39 |
function wppb_captcha_add_form_form_builder( $output, $form_location = '' ) { |
| 40 |
|
| 41 |
if ( $form_location == 'register' ) { |
| 42 |
$cptch_options = get_option('cptch_options'); |
| 43 |
|
| 44 |
if (!empty( $cptch_options['cptch_register_form'] ) && 1 == $cptch_options['cptch_register_form']) { |
| 45 |
$output = '<li>' . cptch_display_captcha_custom() . '</li>' . $output; |
| 46 |
} |
| 47 |
elseif( !empty( $cptch_options['forms']['wp_register']['enable'] ) && $cptch_options['forms']['wp_register']['enable'] ) |
| 48 |
$output = '<li>' . cptch_display_captcha_custom() . '</li>' . $output; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
return $output; |
| 53 |
} |
| 54 |
|
| 55 |
add_filter( 'wppb_after_form_fields', 'wppb_captcha_add_form_form_builder', 10, 2 ); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
/* |
| 60 |
* Function that displays the Captcha error on register form |
| 61 |
* |
| 62 |
*/ |
| 63 |
if( function_exists('cptch_register_check') ) { |
| 64 |
|
| 65 |
function wppb_captcha_register_form_display_error() { |
| 66 |
|
| 67 |
$cptch_options = get_option('cptch_options'); |
| 68 |
|
| 69 |
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'register' && ( ( !empty( $cptch_options['cptch_register_form'] ) && 1 == $cptch_options['cptch_register_form'] ) || ( !empty( $cptch_options['forms']['wp_register']['enable'] ) && $cptch_options['forms']['wp_register']['enable'] ) ) ) { |
| 70 |
|
| 71 |
$result = cptch_register_check(new WP_Error()); |
| 72 |
|
| 73 |
if ($result->get_error_message('captcha_error')) |
| 74 |
echo '<p class="wppb-error">' . esc_html( $result->get_error_message('captcha_error') ) . '</p>'; |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
add_action('wppb_before_register_fields', 'wppb_captcha_register_form_display_error' ); |
| 81 |
} |
| 82 |
|
| 83 |
/* |
| 84 |
* Function that validates captcha value on register form |
| 85 |
* |
| 86 |
*/ |
| 87 |
if( function_exists('cptch_register_check') ) { |
| 88 |
|
| 89 |
function wppb_captcha_register_form_check_value($output_field_errors) { |
| 90 |
|
| 91 |
$cptch_options = get_option('cptch_options'); |
| 92 |
|
| 93 |
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'register' && ( ( !empty( $cptch_options['cptch_register_form'] ) && 1 == $cptch_options['cptch_register_form'] ) || ( !empty( $cptch_options['forms']['wp_register']['enable'] ) && $cptch_options['forms']['wp_register']['enable'] ) ) ) { |
| 94 |
|
| 95 |
$result = cptch_register_check(new WP_Error() ); |
| 96 |
|
| 97 |
if ($result->get_error_message('captcha_error')) |
| 98 |
$output_field_errors[] = $result->get_error_message('captcha_error'); |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
return $output_field_errors; |
| 103 |
} |
| 104 |
|
| 105 |
add_filter('wppb_output_field_errors_filter', 'wppb_captcha_register_form_check_value'); |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
/* |
| 110 |
* Function that ads the Captcha HTML to PB custom recover password form |
| 111 |
* |
| 112 |
*/ |
| 113 |
if ( function_exists('cptch_display_captcha_custom') ) { |
| 114 |
|
| 115 |
function wppb_captcha_add_form_recover_password($output, $username_email = '') { |
| 116 |
|
| 117 |
$cptch_options = get_option('cptch_options'); |
| 118 |
|
| 119 |
if (!empty( $cptch_options['cptch_lost_password_form'] ) && 1 == $cptch_options['cptch_lost_password_form']) { |
| 120 |
$output = str_replace('</ul>', '<li>' . cptch_display_captcha_custom() . '</li>' . '</ul>', $output); |
| 121 |
} |
| 122 |
elseif( !empty( $cptch_options['forms']['wp_lost_password']['enable'] ) && $cptch_options['forms']['wp_lost_password']['enable'] ){ |
| 123 |
$output = str_replace('</ul>', '<li>' . cptch_display_captcha_custom() . '</li>' . '</ul>', $output); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
return $output; |
| 128 |
} |
| 129 |
|
| 130 |
add_filter('wppb_recover_password_generate_password_input', 'wppb_captcha_add_form_recover_password', 10, 2); |
| 131 |
} |
| 132 |
|
| 133 |
/* |
| 134 |
* Function that changes the messageNo from the Recover Password form |
| 135 |
* |
| 136 |
*/ |
| 137 |
if( function_exists('cptch_register_check') ) { |
| 138 |
|
| 139 |
function wppb_captcha_recover_password_message_no($messageNo) { |
| 140 |
|
| 141 |
$cptch_options = get_option('cptch_options'); |
| 142 |
|
| 143 |
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'recover_password' && ( ( !empty( $cptch_options['cptch_lost_password_form'] ) && 1 == $cptch_options['cptch_lost_password_form'] ) || ( !empty( $cptch_options['forms']['wp_lost_password']['enable'] ) && $cptch_options['forms']['wp_lost_password']['enable'] ) ) ) { |
| 144 |
|
| 145 |
$result = cptch_register_check(new WP_Error()); |
| 146 |
|
| 147 |
if ($result->get_error_message('captcha_error') || $result->get_error_message('captcha_error')) |
| 148 |
$messageNo = ''; |
| 149 |
|
| 150 |
} |
| 151 |
|
| 152 |
return $messageNo; |
| 153 |
} |
| 154 |
|
| 155 |
add_filter('wppb_recover_password_message_no', 'wppb_captcha_recover_password_message_no'); |
| 156 |
} |
| 157 |
|
| 158 |
/* |
| 159 |
* Function that adds the captcha error message on Recover Password form |
| 160 |
* |
| 161 |
*/ |
| 162 |
if( function_exists('cptch_register_check') ) { |
| 163 |
|
| 164 |
function wppb_captcha_recover_password_displayed_message1($message) { |
| 165 |
|
| 166 |
$cptch_options = get_option('cptch_options'); |
| 167 |
|
| 168 |
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'recover_password' && ( ( !empty( $cptch_options['cptch_lost_password_form'] ) && 1 == $cptch_options['cptch_lost_password_form'] ) || ( !empty( $cptch_options['forms']['wp_lost_password']['enable'] ) && $cptch_options['forms']['wp_lost_password']['enable'] ) ) ) { |
| 169 |
|
| 170 |
$result = cptch_register_check(new WP_Error()); |
| 171 |
$error_message = ''; |
| 172 |
|
| 173 |
if ($result->get_error_message('captcha_error')) |
| 174 |
$error_message = $result->get_error_message('captcha_error'); |
| 175 |
|
| 176 |
if( empty($error_message) ) |
| 177 |
return $message; |
| 178 |
|
| 179 |
if ( ($message == '<p class="wppb-warning">wppb_captcha_error</p>') || ($message == '<p class="wppb-warning">wppb_recaptcha_error</p>') ) |
| 180 |
$message = '<p class="wppb-warning">' . $error_message . '</p>'; |
| 181 |
else |
| 182 |
$message = $message . '<p class="wppb-warning">' . $error_message . '</p>'; |
| 183 |
|
| 184 |
} |
| 185 |
|
| 186 |
return $message; |
| 187 |
} |
| 188 |
|
| 189 |
add_filter('wppb_recover_password_displayed_message1', 'wppb_captcha_recover_password_displayed_message1'); |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
/* |
| 194 |
* Function that changes the default success message to wppb_captcha_error if the captcha |
| 195 |
* doesn't validate so that we can change the message displayed with the |
| 196 |
* wppb_recover_password_displayed_message1 filter |
| 197 |
* |
| 198 |
*/ |
| 199 |
if( function_exists('cptch_register_check') ) { |
| 200 |
|
| 201 |
function wppb_captcha_recover_password_sent_message_1($message) { |
| 202 |
|
| 203 |
$cptch_options = get_option('cptch_options'); |
| 204 |
|
| 205 |
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'recover_password' && ( ( !empty( $cptch_options['cptch_lost_password_form'] ) && 1 == $cptch_options['cptch_lost_password_form'] ) || ( !empty( $cptch_options['forms']['wp_lost_password']['enable'] ) && $cptch_options['forms']['wp_lost_password']['enable'] ) ) ) { |
| 206 |
|
| 207 |
$result = cptch_register_check( new WP_Error() ); |
| 208 |
|
| 209 |
if ($result->get_error_message('captcha_error') ) |
| 210 |
$message = 'wppb_captcha_error'; |
| 211 |
|
| 212 |
} |
| 213 |
|
| 214 |
return $message; |
| 215 |
} |
| 216 |
|
| 217 |
add_filter('wppb_recover_password_sent_message1', 'wppb_captcha_recover_password_sent_message_1'); |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
/**************************************************** |
| 223 |
* Plugin Name: Easy Digital Downloads |
| 224 |
* Plugin URI: https://wordpress.org/plugins/easy-digital-downloads/ |
| 225 |
****************************************************/ |
| 226 |
|
| 227 |
/* Function that checks if a user is approved before loggin in, when admin approval is on */ |
| 228 |
function wppb_check_edd_login_form( $auth_cookie, $expire, $expiration, $user_id, $scheme ) { |
| 229 |
$wppb_generalSettings = get_option('wppb_general_settings', 'not_found'); |
| 230 |
|
| 231 |
if( $wppb_generalSettings != 'not_found' ) { |
| 232 |
if( wppb_get_admin_approval_option_value() === 'yes' ) { |
| 233 |
if( isset( $_REQUEST['edd_login_nonce'] ) ) { |
| 234 |
if( wp_get_object_terms( $user_id, 'user_status' ) ) { |
| 235 |
if( isset( $_REQUEST['edd_redirect'] ) ) { |
| 236 |
wp_redirect( esc_url_raw( $_REQUEST['edd_redirect'] ) ); |
| 237 |
edd_set_error( 'user_unapproved', __('Your account has to be confirmed by an administrator before you can log in.', 'profile-builder') ); |
| 238 |
edd_get_errors(); |
| 239 |
edd_die(); |
| 240 |
} |
| 241 |
} |
| 242 |
} |
| 243 |
} |
| 244 |
} |
| 245 |
} |
| 246 |
add_action( 'set_auth_cookie', 'wppb_check_edd_login_form', 10, 5 ); |
| 247 |
add_action( 'set_logged_in_cookie', 'wppb_check_edd_login_form', 10, 5 ); |
| 248 |
|
| 249 |
|
| 250 |
/**************************************************** |
| 251 |
* Plugin Name: Page Builder by SiteOrigin && Yoast SEO |
| 252 |
* Plugin URI: https://wordpress.org/plugins/siteorigin-panels/ && https://wordpress.org/plugins/wordpress-seo/ |
| 253 |
* When both plugins are activated SEO generates description tags that execute shortcodes because of the filter on "the_content" added by Page Builder when generating the excerpt |
| 254 |
****************************************************/ |
| 255 |
if( function_exists( 'siteorigin_panels_filter_content' ) ){ |
| 256 |
add_action( 'wpseo_head', 'wppb_remove_siteorigin_panels_content_filter', 8 ); |
| 257 |
function wppb_remove_siteorigin_panels_content_filter() |
| 258 |
{ |
| 259 |
global $post; |
| 260 |
if( !empty( $post->post_content ) ) { |
| 261 |
if (has_shortcode($post->post_content, 'wppb-register') || has_shortcode($post->post_content, 'wppb-edit-profile') || has_shortcode($post->post_content, 'wppb-login') || has_shortcode($post->post_content, 'wppb-list-users')) |
| 262 |
remove_filter('the_content', 'siteorigin_panels_filter_content'); |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
add_filter( 'wpseo_head', 'wppb_add_back_siteorigin_panels_content_filter', 50 ); |
| 267 |
function wppb_add_back_siteorigin_panels_content_filter() |
| 268 |
{ |
| 269 |
global $post; |
| 270 |
if( !empty( $post->post_content ) ) { |
| 271 |
if (has_shortcode($post->post_content, 'wppb-register') || has_shortcode($post->post_content, 'wppb-edit-profile') || has_shortcode($post->post_content, 'wppb-login') || has_shortcode($post->post_content, 'wppb-list-users')) |
| 272 |
add_filter('the_content', 'siteorigin_panels_filter_content'); |
| 273 |
} |
| 274 |
} |
| 275 |
} |
| 276 |
|
| 277 |
/**************************************************** |
| 278 |
* Plugin Name: WPML |
| 279 |
* Compatibility with wp_login_form() that wasn't getting the language code in the site url |
| 280 |
****************************************************/ |
| 281 |
add_filter( 'site_url', 'wppb_wpml_login_form_compatibility', 10, 4 ); |
| 282 |
function wppb_wpml_login_form_compatibility( $url, $path, $scheme, $blog_id ){ |
| 283 |
global $wppb_login_shortcode; |
| 284 |
if( defined( 'ICL_LANGUAGE_CODE' ) && $wppb_login_shortcode ){ |
| 285 |
if( $path == 'wp-login.php' ) { |
| 286 |
if( !empty( $_GET['lang'] ) ) |
| 287 |
return add_query_arg('lang', ICL_LANGUAGE_CODE, $url); |
| 288 |
else{ |
| 289 |
if( function_exists('curl_version') ) { |
| 290 |
/* let's see if the directory structure exists for wp-login.php */ |
| 291 |
$headers = wp_remote_head( trailingslashit( get_home_url() ) . $path, array( 'timeout' => 2 ) ); |
| 292 |
if (!is_wp_error($headers)) { |
| 293 |
if ($headers['response']['code'] == 200) { |
| 294 |
return trailingslashit( get_home_url() ) . $path; |
| 295 |
} |
| 296 |
} |
| 297 |
} |
| 298 |
return add_query_arg('lang', ICL_LANGUAGE_CODE, $url); |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
return $url; |
| 303 |
} |
| 304 |
|
| 305 |
/**************************************************** |
| 306 |
* Plugin Name: ACF |
| 307 |
* Compatibility with Role Editor where ACF includes it's own select 2 and a bit differently then the standard hooks |
| 308 |
****************************************************/ |
| 309 |
add_action( 'admin_enqueue_scripts', 'wppb_acf_and_user_role_select_2_compatibility' ); |
| 310 |
function wppb_acf_and_user_role_select_2_compatibility(){ |
| 311 |
$post_type = get_post_type(); |
| 312 |
if( !empty( $post_type ) && $post_type == 'wppb-roles-editor' ) |
| 313 |
remove_all_actions('acf/input/admin_enqueue_scripts'); |
| 314 |
} |
| 315 |
|
| 316 |
/**************************************************** |
| 317 |
* Theme Enfold |
| 318 |
* Compatibility with Enfold theme that removes the wp.media scripts from the frontend for some reason starting from version 4.3 From what I understand they only allow it on media formats or posts that contain media embeds |
| 319 |
****************************************************/ |
| 320 |
if( ! function_exists( 'av_video_assets_required' ) ){ |
| 321 |
function av_video_assets_required(){ |
| 322 |
return true; |
| 323 |
} |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
/**************************************************** |
| 328 |
* Secupress Compatibility |
| 329 |
* Compatibility with Secupress plugin when activating Move the login and admin pages |
| 330 |
****************************************************/ |
| 331 |
if( isset( $_POST['wppb_login'] ) ) { |
| 332 |
remove_action('login_init', 'secupress_move_login_maybe_deny_login_page', 0); |
| 333 |
remove_action('secure_auth_redirect', 'secupress_move_login_maybe_deny_login_page', 0); |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
/**************************************************** |
| 338 |
* Divi Pagebuilder Compatibility |
| 339 |
* Compatibility with Divi Pagebuilder and content restriction. Basically we try to force a restricted page that was created with the pagebuilder to display as a normal page |
| 340 |
****************************************************/ |
| 341 |
if( function_exists('et_setup_theme') ) { |
| 342 |
add_filter('get_post_metadata', 'wppb_divi_page_builder_compatibility', 100, 4); |
| 343 |
function wppb_divi_page_builder_compatibility( $metadata, $object_id, $meta_key, $single ){ |
| 344 |
if (!is_admin()) { |
| 345 |
if (isset($meta_key) && '_et_pb_use_builder' == $meta_key) { |
| 346 |
if (wppb_content_restriction_filter_content('not_restricted', get_post($object_id)) != 'not_restricted') { |
| 347 |
return 'off'; |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
if (isset($meta_key) && '_wp_page_template' == $meta_key) { |
| 352 |
if (wppb_content_restriction_filter_content('not_restricted', get_post($object_id)) != 'not_restricted') { |
| 353 |
return 'default'; |
| 354 |
} |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 358 |
// Return original if the check does not pass |
| 359 |
return $metadata; |
| 360 |
|
| 361 |
} |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
/**************************************************** |
| 366 |
* Plugin Name: xCRUD |
| 367 |
* Compatibility in terms of preventing jQuery to be loaded twice |
| 368 |
****************************************************/ |
| 369 |
if ( class_exists( 'Xcrud_config' ) ){ |
| 370 |
Xcrud_config::$load_jquery = apply_filters( 'wppb_xcrud_jquery_compatibility', false ); |
| 371 |
} |
| 372 |
|
| 373 |
/**************************************************** |
| 374 |
* Plugin Name: bbPress Messages |
| 375 |
* Plugin URI: https://wordpress.org/plugins/bbp-messages/ |
| 376 |
* This plugin relies on the 'bbp_template_before_user_profile' hook |
| 377 |
****************************************************/ |
| 378 |
if ( function_exists( 'bbp_messages_loaded' ) ){ |
| 379 |
add_action( 'wppb_bbp_template_before_user_profile', 'wppb_bbp_messages_compatibility' ); |
| 380 |
function wppb_bbp_messages_compatibility (){ |
| 381 |
do_action( 'bbp_template_before_user_profile' ); |
| 382 |
} |
| 383 |
} |
| 384 |
|
| 385 |
/**************************************************** |
| 386 |
* Plugin Name: LearnDash LMS |
| 387 |
* This plugin hijacks the 'wp_login_failed' hook not allowing the PB login form to show errors |
| 388 |
****************************************************/ |
| 389 |
if ( class_exists( 'Semper_Fi_Module' ) ){ |
| 390 |
add_action( 'wppb_process_login_start', 'wppb_learndash_compatibility_login_start' ); |
| 391 |
function wppb_learndash_compatibility_login_start (){ |
| 392 |
remove_action( 'wp_login_failed', 'learndash_login_failed', 1 ); |
| 393 |
} |
| 394 |
add_action( 'wppb_process_login_end', 'wppb_learndash_compatibility_login_end' ); |
| 395 |
function wppb_learndash_compatibility_login_end (){ |
| 396 |
add_action( 'wp_login_failed', 'learndash_login_failed', 1, 1 ); |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
|