';
$item_description = wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_description_translation', $field['description'] );
$heading = '
'.wppb_icl_t('plugin profile-builder-pro', 'custom_field_'.$field['id'].'_title_translation', $field['field-title']).'
'.$item_description.'';
$output .= apply_filters( 'wppb_blog_details_heading', $heading );
?> .wppb-blog-details-fields {display:none;} ';
}
$create_new_site_checkbox = '
';
$output .= apply_filters( 'wppb_blog_details_checkbox', $create_new_site_checkbox );
$output .= '';
// Site URL
$item_description = __( 'Your site url will look like this:
', 'profile-builder' );
if ( is_subdomain_install() ) {
global $current_site;
$subdomain_base = apply_filters( 'wppb_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
$domain = '"http://'. esc_attr( '.' ) . $subdomain_base;
} else {
$domain = '"' . esc_url( home_url( '/' ) ) . esc_attr( '' ) . '"';
}
$blog_url_input_value = '';
$blog_url_input_value = ( isset( $request_data['wppb_blog_url'] ) ? trim( $request_data['wppb_blog_url'] ) : $blog_url_input_value );
$error_mark = '*';
$extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location );
$error_class = '';
$is_error = wppb_check_individual_blog_fields( 'wppb_blog_url', $request_data, $form_location );
if ($is_error != '') {
$error_mark = '';
$error_class = ' wppb-field-error';
}
$output .= '
-
';
$output .= ''. $item_description . $domain . '';
$output .= $is_error .'
';
// Site title
$blog_title_input_value = '';
$blog_title_input_value = ( isset( $request_data['wppb_blog_title'] ) ? trim( $request_data['wppb_blog_title'] ) : $blog_title_input_value );
$error_mark = '*';
$extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location );
$error_class = '';
$is_error = wppb_check_individual_blog_fields( 'wppb_blog_title', $request_data, $form_location );
if ($is_error != '') {
$error_mark = '';
$error_class = ' wppb-field-error';
}
$output .= '
-
' .
$is_error . '
';
// Privacy
$blog_privacy_input_value = 'Yes';
$blog_privacy_input_value = ( isset( $request_data['wppb_blog_privacy'] ) ? trim( $request_data['wppb_blog_privacy'] ) : $blog_privacy_input_value );
$error_mark = '*';
$radio_values = array( 'Yes', 'No' );
$error_class = '';
$is_error = wppb_check_individual_blog_fields( 'wppb_blog_privacy', $request_data, $form_location );
if ($is_error != '') {
$error_mark = '';
$error_class = ' wppb-field-error';
}
$output .= '
-
';
$output .= '
';
foreach( $radio_values as $key => $value){
$output .= '- '. trim( $radio_values[$key] ) .'
';
}
$output .= '
' . $is_error . ' ';
// end wppb-blog-details-fields
$output .= '
';
$output .= '';
return apply_filters( 'wppb_blog_details_output', $output, $form_location, $field, $user_id, $field_check_errors, $request_data );
}
add_filter( 'wppb_output_form_field_default-blog-details', 'wppb_blog_details_handler', 10, 6 );
/* handle field save */
function wppb_create_blog_on_registration( $field, $user_id, $request_data, $form_location ){
if( $form_location == 'register' && $field['field'] == 'Default - Blog Details' && isset( $request_data['wppb_create_new_site_checkbox'] ) && $request_data['wppb_create_new_site_checkbox'] == 'yes' ) {
$blog_url = $request_data['wppb_blog_url'];
$blog_title = $request_data['wppb_blog_title'];
$usermeta['public'] = ( isset( $request_data['wppb_blog_privacy'] ) && 'Yes' == $request_data['wppb_blog_privacy'] ) ? true : false;
$blog_details = wpmu_validate_blog_signup( $blog_url, $blog_title );
if ( empty($blog_details['errors']->errors['blogname']) && empty($blog_details['errors']->errors['blog_title'])) {
wpmu_create_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $user_id, $usermeta );
}
}
}
add_action( 'wppb_save_form_field', 'wppb_create_blog_on_registration', 10, 4 );
/* handle field validation */
function wppb_check_blog_details_values( $message, $field, $request_data, $form_location ){
if ( isset( $request_data['wppb_create_new_site_checkbox'] ) && $request_data['wppb_create_new_site_checkbox'] == 'yes' ){
$blog_fields_array = wppb_blog_details_fields_array();
foreach ( $blog_fields_array as $blog_field ){
if( ( isset( $request_data[$blog_field] ) && ( trim( $request_data[$blog_field] ) == '' ) ) || !isset( $request_data[$blog_field] ) ){
return wppb_required_field_error($blog_field);
}
}
}
return $message;
}
add_filter( 'wppb_check_form_field_default-blog-details', 'wppb_check_blog_details_values', 10, 4 );
/* Add blog details information to wp_signups table (when Email Confirmation is active) */
function wppb_add_blog_details_to_signup_table( $meta, $global_request, $role ){
if ( isset( $global_request['wppb_create_new_site_checkbox'] ) && $global_request['wppb_create_new_site_checkbox'] == 'yes' ) {
$blog_details_fields_array = wppb_blog_details_fields_array();
foreach ($blog_details_fields_array as $blog_field) {
$meta[$blog_field] = $global_request[$blog_field];
}
}
return $meta;
}
add_filter( 'wppb_add_to_user_signup_form_meta', 'wppb_add_blog_details_to_signup_table',10, 3 );
function wppb_blog_details_fields_array(){
return array(
'wppb_blog_title',
'wppb_blog_url',
'wppb_blog_privacy',
'wppb_create_new_site_checkbox'
);
}
function wppb_check_individual_blog_fields( $field_key, $request_data, $form_location ){
if ( isset( $request_data['wppb_create_new_site_checkbox'] ) && $request_data['wppb_create_new_site_checkbox'] == 'yes' ) {
if ( $field_key == 'wppb_blog_privacy' && ( ! isset( $request_data[$field_key] ) || ( isset( $request_data[$field_key] ) && ( trim( $request_data[$field_key] ) == '' ) ) ) ) {
return '' . wppb_required_field_error($field_key) . '';
}
$wp_error = wpmu_validate_blog_signup($request_data['wppb_blog_url'], $request_data['wppb_blog_title']);
if ( $field_key == 'wppb_blog_url' && !empty($wp_error['errors']->errors['blogname'])){
return '' . $wp_error['errors']->errors['blogname'][0] . '';
}
if ( $field_key == 'wppb_blog_title' && !empty($wp_error['errors']->errors['blog_title'])){
return '' . $wp_error['errors']->errors['blog_title'][0] . '';
}
}
return '';
}