Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/themify-.../modules
File: module-signup-form.php
<?php
[0] Fix | Delete
defined('ABSPATH') || exit;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Module Name: Sign Up Form
[4] Fix | Delete
* Description: Displays sign up form
[5] Fix | Delete
*/
[6] Fix | Delete
class TB_Signup_Form_Module extends Themify_Builder_Component_Module {
[7] Fix | Delete
[8] Fix | Delete
public static function init():void {
[9] Fix | Delete
// Sign Up module action for processing sign up form
[10] Fix | Delete
add_action('wp_ajax_nopriv_tb_signup_process', array(__CLASS__, 'signup_process'));
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
[14] Fix | Delete
public static function get_module_name():string {
[15] Fix | Delete
return __('Sign Up Form', 'themify');
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
public static function get_module_icon():string {
[19] Fix | Delete
return 'pencil-alt';
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
public static function get_js_css():array {
[23] Fix | Delete
$_arr = array(
[24] Fix | Delete
'css' => 1
[25] Fix | Delete
);
[26] Fix | Delete
if (!Themify_Builder_Model::is_front_builder_activate()) {
[27] Fix | Delete
$_arr['js'] = 1;
[28] Fix | Delete
}
[29] Fix | Delete
return $_arr;
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Render plain content for static content.
[34] Fix | Delete
*
[35] Fix | Delete
* @param array $module
[36] Fix | Delete
*
[37] Fix | Delete
* @return string
[38] Fix | Delete
*/
[39] Fix | Delete
public static function get_static_content(array $module):string {
[40] Fix | Delete
return sprintf( __( '<a href="%s" target="_blank">Click here to Register</a>', 'themify' ), esc_url( wp_registration_url() ) );
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
public static function signup_enabled() {
[44] Fix | Delete
return get_option( 'users_can_register' );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Actions to perform when sign up via Sign Up module is sent
[49] Fix | Delete
*
[50] Fix | Delete
*/
[51] Fix | Delete
public static function signup_process() {
[52] Fix | Delete
if ( empty( $_POST['tb_post_id'] ) || ! self::signup_enabled() ) {
[53] Fix | Delete
die(-1);
[54] Fix | Delete
}
[55] Fix | Delete
$error = false;
[56] Fix | Delete
$module = self::get_element_settings( $_POST['tb_post_id'], $_POST['tb_element_id'] );
[57] Fix | Delete
if ( empty( $module ) ) {
[58] Fix | Delete
$error = __( 'Error retrieving the module.', 'themify' );
[59] Fix | Delete
} else if ( $module['captcha'] ) {
[60] Fix | Delete
$response =
[61] Fix | Delete
$module['captcha'] === 'recaptcha' && ! empty( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response']
[62] Fix | Delete
: ( $module['captcha'] === 'hcaptcha' && ! empty( $_POST['h-captcha-response'] ) ? $_POST['h-captcha-response'] : null );
[63] Fix | Delete
if ( $response ) {
[64] Fix | Delete
$result = Themify_Builder_Model::validate_captcha( $module['captcha'], $response );
[65] Fix | Delete
if ( is_wp_error( $result ) ) {
[66] Fix | Delete
$error = $result->get_error_message();
[67] Fix | Delete
}
[68] Fix | Delete
} else {
[69] Fix | Delete
$error = __( 'Captcha response missing.', 'themify' );
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
if ( $error === false && self::flood_check() ) {
[74] Fix | Delete
$error = __( 'Please wait, and try again.', 'themify' );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if ( empty( $_POST['user_login'] ) ) {
[78] Fix | Delete
$error = __('Please enter a username', 'themify');
[79] Fix | Delete
} elseif (!validate_username($_POST['user_login'])) {
[80] Fix | Delete
$error = __('Invalid username', 'themify');
[81] Fix | Delete
} elseif ( username_exists($_POST['user_login'] ) ) {
[82] Fix | Delete
$error = __('Username already taken', 'themify');
[83] Fix | Delete
}
[84] Fix | Delete
if ( empty( $_POST['user_email'] ) || ! is_email( $_POST['user_email'] ) ) {
[85] Fix | Delete
$error = __('Invalid email', 'themify');
[86] Fix | Delete
} elseif ( email_exists( $_POST['user_email'] ) ) {
[87] Fix | Delete
$error = __('Email already registered', 'themify');
[88] Fix | Delete
}
[89] Fix | Delete
if ( empty( $_POST['pwd'] ) ) {
[90] Fix | Delete
$error = __('Please enter a password', 'themify');
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
if ( $error === false ) {
[94] Fix | Delete
global $wpdb;
[95] Fix | Delete
$wpdb->query( 'START TRANSACTION' );
[96] Fix | Delete
$first_name = sanitize_text_field( $_POST['first_n'] );
[97] Fix | Delete
$last_name = sanitize_text_field( $_POST['last_n'] );
[98] Fix | Delete
$email = sanitize_email( $_POST['user_email'] );
[99] Fix | Delete
try {
[100] Fix | Delete
$new_user_id = wp_insert_user(array(
[101] Fix | Delete
'user_login' => sanitize_text_field( $_POST['user_login'] ),
[102] Fix | Delete
'user_pass' => sanitize_text_field( $_POST['pwd'] ),
[103] Fix | Delete
'user_email' => $email,
[104] Fix | Delete
'first_name' => $first_name,
[105] Fix | Delete
'last_name' => $last_name,
[106] Fix | Delete
'description' => isset($_POST['bio']) ? sanitize_textarea_field( $_POST['bio'] ) : '',
[107] Fix | Delete
'user_registered' => date('Y-m-d H:i:s'),
[108] Fix | Delete
)
[109] Fix | Delete
);
[110] Fix | Delete
if ( is_wp_error( $new_user_id ) ) {
[111] Fix | Delete
throw new Exception( $new_user_id->get_error_message() );
[112] Fix | Delete
} else {
[113] Fix | Delete
$wpdb->query( 'COMMIT' );
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
catch ( \Throwable $e ) {
[117] Fix | Delete
$wpdb->query( 'ROLLBACK' );
[118] Fix | Delete
$error = __('Problem creating the new user. Please try again.', 'themify');
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
if ( $error === false ) {
[122] Fix | Delete
[123] Fix | Delete
// newsletter subscription
[124] Fix | Delete
if (isset($_POST['optin']) && $_POST['optin'] == '1') {
[125] Fix | Delete
if (!class_exists('Builder_Optin_Service',false)) {
[126] Fix | Delete
include_once( THEMIFY_BUILDER_INCLUDES_DIR . '/optin-services/base.php' );
[127] Fix | Delete
}
[128] Fix | Delete
$optin_instance = Builder_Optin_Service::get_providers($_POST['optin-provider'],true);
[129] Fix | Delete
if ($optin_instance) {
[130] Fix | Delete
// collect the data for optin service
[131] Fix | Delete
$data = array(
[132] Fix | Delete
'user_email' => $email,
[133] Fix | Delete
'fname' => $first_name,
[134] Fix | Delete
'lname' => $last_name,
[135] Fix | Delete
);
[136] Fix | Delete
foreach ($_POST as $key => $value) {
[137] Fix | Delete
if (preg_match('/^optin-/', $key)) {
[138] Fix | Delete
$key = preg_replace('/^optin-/', '', $key);
[139] Fix | Delete
$data[ $key ] = sanitize_text_field( trim( $value ) );
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
$optin_instance::subscribe($data);
[143] Fix | Delete
}
[144] Fix | Delete
unset($optin_instance);
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
$admin_notification = ! isset( $module['e_user'] ) || $module['e_user'] !== false;
[148] Fix | Delete
$user_notification = ! isset( $module['e_user'] ) || $module['e_user'] !== false;
[149] Fix | Delete
if ( $admin_notification || $user_notification ) {
[150] Fix | Delete
$notify = '';
[151] Fix | Delete
if ( $admin_notification && $user_notification ) {
[152] Fix | Delete
$notify = 'both';
[153] Fix | Delete
} elseif ( $user_notification ) {
[154] Fix | Delete
$notify = 'user';
[155] Fix | Delete
}
[156] Fix | Delete
wp_new_user_notification($new_user_id, null, $notify);
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
$_SESSION['tb_signup'] = time();
[160] Fix | Delete
[161] Fix | Delete
wp_send_json_success( [
[162] Fix | Delete
'user_id' => $new_user_id
[163] Fix | Delete
] );
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
wp_send_json_error( $error );
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
/**
[171] Fix | Delete
* Returns true if too many register requests from same IP is detected
[172] Fix | Delete
*
[173] Fix | Delete
* @return bool
[174] Fix | Delete
*/
[175] Fix | Delete
private static function flood_check():bool {
[176] Fix | Delete
if( !session_id() ){
[177] Fix | Delete
session_start();
[178] Fix | Delete
}
[179] Fix | Delete
return ! ( empty( $_SESSION['tb_signup'] ) || ( time() > ( $_SESSION['tb_signup'] + MINUTE_IN_SECONDS ) ) );
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
public static function get_styling_image_fields() : array {
[183] Fix | Delete
return [
[184] Fix | Delete
'b_i' => ''
[185] Fix | Delete
];
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
public static function get_translatable_text_fields( $module ) : array {
[189] Fix | Delete
return [ 'mod_title', 'optin_label', 'l_name', 'l_firstname', 'l_lastname', 'l_username', 'l_email', 'l_password', 'l_submit' ];
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
public static function get_translatable_textarea_fields( $module ) : array {
[193] Fix | Delete
return [ 'msg_success', 'gdpr_label', 'welcome', 'l_bio', 'desc' ];
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
public static function get_translatable_link_fields( $module ) : array {
[197] Fix | Delete
return [ 'redirect_to' ];
[198] Fix | Delete
}
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
TB_Signup_Form_Module::init();
[202] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function