Exemplo n.º 1
0
function wppb_multiple_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Select (Multiple)') {
        $item_title = apply_filters('wppb_' . $form_location . '_multiple_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $item_option_labels = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_option_labels_translation', $field['labels']);
        $select_labels = explode(',', $item_option_labels);
        $select_values = explode(',', $field['options']);
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? array_map('trim', explode(',', get_user_meta($user_id, $field['meta-name'], true))) : array_map('trim', explode(',', $field['default-options']));
        } else {
            $input_value = isset($field['default-options']) ? array_map('trim', explode(',', $field['default-options'])) : array();
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? array_map('trim', $request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<select name="' . $field['meta-name'] . '[]" id="' . $field['meta-name'] . '" size="' . (count($select_values) > 10 ? count($select_values) / 2 : count($select_values)) . '" class="custom_field_multiple_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" multiple="multiple" ' . $extra_attr . '>';
            foreach ($select_values as $key => $value) {
                $output .= '<option value="' . trim($value) . '" class="custom_field_multiple_select_option" name="' . trim($value) . '_' . $field['id'] . '" id="' . trim($value) . '_' . $field['id'] . '"';
                if (in_array(trim($value), $input_value)) {
                    $output .= ' selected';
                }
                $output .= '>' . (!isset($select_labels[$key]) || !$select_labels[$key] ? trim($select_values[$key]) : trim($select_labels[$key])) . '</option>';
            }
            $output .= '
				</select>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<select name="' . $field['meta-name'] . '[]" class="custom_field_multiple_select" id="' . $field['meta-name'] . '" multiple="multiple" ' . $extra_attr . '>';
            foreach ($select_values as $key => $value) {
                $output .= '<option value="' . trim($value) . '" size="' . (count($select_values) > 10 ? count($select_values) / 2 : count($select_values)) . '" class="custom_field_multiple_select_option" id="' . trim($value) . '_' . $field['id'] . '"';
                if (in_array(trim($value), $input_value)) {
                    $output .= ' selected';
                }
                $output .= '>' . (!isset($select_labels[$key]) || !$select_labels[$key] ? trim($select_values[$key]) : trim($select_labels[$key])) . '</option>';
            }
            $output .= '</select>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_multiple_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 2
0
function wppb_checkbox_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Checkbox') {
        $item_title = apply_filters('wppb_' . $form_location . '_checkbox_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $item_option_labels = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_option_labels_translation', $field['labels']);
        $checkbox_labels = explode(',', $item_option_labels);
        $checkbox_values = explode(',', $field['options']);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? array_map('trim', explode(',', stripslashes(get_user_meta($user_id, $field['meta-name'], true)))) : array_map('trim', explode(',', $field['default-options']));
        } else {
            $input_value = !empty($field['default-options']) ? array_map('trim', explode(',', $field['default-options'])) : array();
        }
        if ($form_location == 'register' && isset($request_data[wppb_handle_meta_name($field['meta-name'])]) && !empty($request_data[wppb_handle_meta_name($field['meta-name'])])) {
            $input_value = $request_data[wppb_handle_meta_name($field['meta-name'])];
        }
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>';
            $output .= '<ul class="wppb-checkboxes">';
            foreach ($checkbox_values as $key => $value) {
                $output .= '<li><input value="' . esc_attr(trim($value)) . '" class="custom_field_checkbox" name="' . $field['meta-name'] . '[]" id="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" type="checkbox" ' . $extra_attr . ' ';
                if (in_array(trim($value), $input_value)) {
                    $output .= ' checked';
                }
                $output .= ' /><label for="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" class="wppb-rc-value">' . (!isset($checkbox_labels[$key]) || !$checkbox_labels[$key] ? trim($checkbox_values[$key]) : trim($checkbox_labels[$key])) . '</label></li>';
            }
            $output .= '</ul>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>';
            foreach ($checkbox_values as $key => $value) {
                $output .= '<li><input value="' . esc_attr(trim($value)) . '" class="custom_field_checkbox ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" name="' . $field['meta-name'] . '[]" id="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" type="checkbox"';
                if (in_array(trim($value), $input_value)) {
                    $output .= ' checked';
                }
                $output .= ' /><label for="' . Wordpress_Creation_Kit_PB::wck_generate_slug(trim($value)) . '_' . $field['id'] . '" class="wppb-rc-value">' . (!isset($checkbox_labels[$key]) || !$checkbox_labels[$key] ? trim($checkbox_values[$key]) : trim($checkbox_labels[$key])) . '</label></li>';
            }
            $output .= '
						<span class="wppb-description-delimiter">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_checkbox_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
function wppb_timezone_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Select (Timezone)') {
        $item_title = apply_filters('wppb_' . $form_location . '_timezone_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $timezone_array = wppb_timezone_select_options($form_location);
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? stripslashes(get_user_meta($user_id, $field['meta-name'], true)) : $field['default-option-timezone'];
        } else {
            $input_value = !empty($field['default-option-timezone']) ? trim($field['default-option-timezone']) : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_timezone_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>';
            foreach ($timezone_array as $timezone) {
                $output .= '<option value="' . $timezone . '"';
                if ($input_value === $timezone) {
                    $output .= ' selected';
                }
                $output .= '>' . $timezone . '</option>';
            }
            $output .= '
				</select>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<select name="' . $field['meta-name'] . '" class="custom_field_timezone_select" id="' . $field['meta-name'] . '" ' . $extra_attr . '>';
            foreach ($timezone_array as $timezone) {
                $output .= '<option value="' . $timezone . '"';
                if ($input_value === $timezone) {
                    $output .= ' selected';
                }
                $output .= '>' . $timezone . '</option>';
            }
            $output .= '</select>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_timezone_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 4
0
function wppb_colorpicker_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Colorpicker') {
        wp_enqueue_style('wp-color-picker');
        wp_enqueue_style('profile-builder-colorpicker', WPPB_PLUGIN_URL . 'front-end/extra-fields/colorpicker/colorpicker-style.css', false, PROFILE_BUILDER_VERSION);
        wp_enqueue_script('iris', admin_url('js/iris.min.js'), array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), false, 1);
        wp_enqueue_script('wp-color-picker', admin_url('js/color-picker.min.js'), array('iris'), false, 1);
        wp_enqueue_script('wppb-colorpicker-script', WPPB_PLUGIN_URL . 'front-end/extra-fields/colorpicker/script-colorpicker.js', array('wp-color-picker'), PROFILE_BUILDER_VERSION, true);
        if (!is_admin()) {
            $is_frontend = array('isFrontend' => 1);
        } else {
            $is_frontend = array('isFrontend' => 0);
        }
        wp_localize_script('wppb-colorpicker-script', 'wppb_colorpicker_data', $is_frontend);
        $item_title = apply_filters('wppb_' . $form_location . '_colorpicker_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $field['default-value'] = apply_filters('wppb_colorpicker_default_color_' . $field['meta-name'], '');
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value'];
        } else {
            $input_value = !empty($field['default-value']) ? trim($field['default-value']) : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<input name="' . $field['meta-name'] . '" class="custom_field_colorpicker ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" type="text" value="' . esc_attr(wp_unslash($input_value)) . '" data-default-color="' . $field['default-value'] . '" ' . $extra_attr . ' />
				<span class="wppb-description-delimiter">' . $item_description . '</span>';
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<input size="45" id="' . $field['meta-name'] . '" class="custom_field_colorpicker" name="' . $field['meta-name'] . '" type="text" value="' . esc_attr($input_value) . ' " ' . $extra_attr . '/>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_colorpicker_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 5
0
function wppb_wysiwyg_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'WYSIWYG') {
        $item_title = apply_filters('wppb_' . $form_location . '_wysiwyg_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-content'];
        } else {
            $input_value = isset($field['default-content']) ? trim($field['default-content']) : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>';
            ob_start();
            wp_editor(stripcslashes($input_value), $field['meta-name'], array('textarea_rows' => $field['row-count'], 'textarea_name' => $field['meta-name'], 'editor_class' => 'custom_field_wysiwyg'));
            $out1 = ob_get_clean();
            $output .= $out1;
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>';
            ob_start();
            wp_editor($input_value, $field['meta-name'], array('textarea_rows' => $field['row-count'], 'textarea_name' => $field['meta-name'], 'editor_class' => 'custom_field_wysiwyg'));
            $out1 = ob_get_clean();
            $output .= $out1;
            $output .= '<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_wysiwyg_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 6
0
function wppb_phone_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Phone') {
        wp_enqueue_script('wppb-jquery-inputmask', WPPB_PLUGIN_URL . 'front-end/extra-fields/phone/jquery.inputmask.bundle.min.js', array('jquery'), PROFILE_BUILDER_VERSION, true);
        wp_enqueue_script('wppb-phone-script', WPPB_PLUGIN_URL . 'front-end/extra-fields/phone/script-phone.js', array('wppb-jquery-inputmask'), PROFILE_BUILDER_VERSION, true);
        $phone_data = json_encode(array('phone_data' => wppb_make_phone_number_format($field, $request_data)));
        $item_title = apply_filters('wppb_' . $form_location . '_phone_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value'];
        } else {
            $input_value = isset($field['default-value']) ? trim($field['default-value']) : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        $phone_format_description = __('Required phone number format: ', 'profile-builder') . $field['phone-format'] . '<br>';
        $phone_format_description = apply_filters('wppb_phone_format_description', $phone_format_description);
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<input data-phone-format="' . esc_attr($phone_data) . '" class="extra_field_phone ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>';
            if (!empty($field['phone-format']) || !empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . (!empty($field['phone-format']) ? $phone_format_description : '') . (!empty($item_description) ? $item_description : '') . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<input data-phone-format="' . esc_attr($phone_data) . '" class="custom_field_phone" size="45" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr($input_value) . '" ' . $extra_attr . '/>
							<span class="description">' . (!empty($field['phone-format']) ? $phone_format_description : '') . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_phone_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
function wppb_hidden_input_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Input (Hidden)') {
        $item_title = apply_filters('wppb_' . $form_location . '_hidden_input_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value'];
        } else {
            $input_value = isset($field['default-value']) ? trim($field['default-value']) : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        if (apply_filters('wppb_display_capability_level', current_user_can('manage_options'))) {
            $input_type = 'text';
            $hidden_start = $hidden_end = '';
        } else {
            $input_type = 'hidden';
            $hidden_start = '<!--';
            $hidden_end = '-->';
        }
        if ($form_location != 'back_end') {
            $output = $hidden_start . '
				<label for="' . $field['meta-name'] . '">' . $item_title . '</label>' . $hidden_end . '
				<input class="extra_field_hidden_input" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70) . '" type="' . $input_type . '" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>
				' . $hidden_start . '<span class="wppb-description-delimiter">' . $item_description . '</span>' . $hidden_end;
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = $hidden_start . '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>' . $hidden_end . '
							<input class="custom_field_hidden_input" size="45" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70) . '" type="' . $input_type . '" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>
							' . $hidden_start . '<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>' . $hidden_end;
        }
        return apply_filters('wppb_' . $form_location . '_hidden_input_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 8
0
function wppb_input_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Input') {
        $item_title = apply_filters('wppb_' . $form_location . '_input_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : $field['default-value'];
        } else {
            $input_value = isset($field['default-value']) ? trim($field['default-value']) : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<input class="extra_field_input ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr(wp_unslash($input_value)) . '" ' . $extra_attr . '/>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<input class="custom_field_input" size="45" name="' . $field['meta-name'] . '" maxlength="' . apply_filters('wppb_maximum_character_length', 70, $field) . '" type="text" id="' . $field['meta-name'] . '" value="' . esc_attr($input_value) . '" ' . $extra_attr . '/>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_input_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
function wppb_country_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Select (Country)') {
        $item_title = apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $country_array = wppb_country_select_options($form_location);
        $old_country_array = array("Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia, Plurinational State of", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cabo Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote dIvoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic of", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic Peoples Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao Peoples Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, the former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestine, State of", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Barthelemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela, Bolivarian Republic of", "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe");
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            // change current user country meta_value with country ISO code
            $user_country_option = wppb_user_meta_exists($user_id, $field['meta-name']);
            if ($user_country_option != null) {
                if (in_array($user_country_option->meta_value, $old_country_array)) {
                    $country_iso = array_search($user_country_option->meta_value, $country_array);
                    update_user_meta($user_id, $field['meta-name'], $country_iso);
                }
            }
            $input_value = $user_country_option != null ? $country_array[stripslashes(get_user_meta($user_id, $field['meta-name'], true))] : $country_array[$field['default-option-country']];
        } else {
            $input_value = !empty($field['default-option-country']) ? $country_array[trim($field['default-option-country'])] : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? $country_array[trim($request_data[wppb_handle_meta_name($field['meta-name'])])] : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_country_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>';
            foreach ($country_array as $iso => $country) {
                $output .= '<option value="' . $iso . '"';
                if ($input_value === $country) {
                    $output .= ' selected';
                }
                $output .= '>' . $country . '</option>';
            }
            $output .= '
				</select>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<select name="' . $field['meta-name'] . '" class="custom_field_country_select" id="' . $field['meta-name'] . '" ' . $extra_attr . '>';
            foreach ($country_array as $iso => $country) {
                $output .= '<option value="' . $iso . '"';
                if ($input_value === $country) {
                    $output .= ' selected';
                }
                $output .= '>' . $country . '</option>';
            }
            $output .= '</select>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 10
0
function wppb_avatar_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Avatar') {
        /* media upload add here, this should be added just once even if called multiple times */
        wp_enqueue_media();
        /* propper way to dequeue. add to functions file in theme or custom plugin
            function wppb_dequeue_script() {
               wp_script_is( 'wppb-upload-script', 'enqueued' ); //true
               wp_dequeue_script( 'wppb-upload-script' );
           }
           add_action( 'get_footer', 'wppb_dequeue_script' );
            */
        wp_enqueue_script('wppb-upload-script', WPPB_PLUGIN_URL . 'front-end/extra-fields/upload/upload.js', array('jquery'), PROFILE_BUILDER_VERSION, true);
        wp_enqueue_style('profile-builder-upload-css', WPPB_PLUGIN_URL . 'front-end/extra-fields/upload/upload.css', false, PROFILE_BUILDER_VERSION);
        $item_title = apply_filters('wppb_' . $form_location . '_avatar_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        if ($form_location != 'register') {
            if (empty($request_data[wppb_handle_meta_name($field['meta-name'])])) {
                $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? get_user_meta($user_id, $field['meta-name'], true) : '';
            } else {
                $input_value = $request_data[wppb_handle_meta_name($field['meta-name'])];
            }
            if (!empty($input_value) && !is_numeric($input_value)) {
                /* we have a file url and we need to change it into an attachment */
                // Check the type of file. We'll use this as the 'post_mime_type'.
                $wp_upload_dir = wp_upload_dir();
                $file_path = str_replace($wp_upload_dir['baseurl'], $wp_upload_dir["basedir"], $input_value);
                //on windows os we might have \ instead of / so change them
                $file_path = str_replace("\\", "/", $file_path);
                $file_type = wp_check_filetype(basename($input_value), null);
                $attachment = array('guid' => $input_value, 'post_mime_type' => $file_type['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($input_value)), 'post_content' => '', 'post_status' => 'inherit');
                // Insert the attachment.
                $input_value = wp_insert_attachment($attachment, $input_value, 0);
                if (!empty($input_value)) {
                    // Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
                    require_once ABSPATH . 'wp-admin/includes/image.php';
                    // Generate the metadata for the attachment, and update the database record.
                    $attach_data = wp_generate_attachment_metadata($input_value, $file_path);
                    wp_update_attachment_metadata($input_value, $attach_data);
                    /* save the new attachment instead of the url */
                    update_user_meta($user_id, $field['meta-name'], $input_value);
                }
            }
        } else {
            $input_value = !empty($_POST[$field['meta-name']]) ? $_POST[$field['meta-name']] : '';
        }
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>';
            $output .= wppb_make_upload_button($field, $input_value);
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>';
            $output .= wppb_make_upload_button($field, $input_value);
            $output .= '<br/><span class="wppb-description-delimiter">' . $item_description;
            $output .= '
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_avatar_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 11
0
function wppb_country_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Select (Country)') {
        $item_title = apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $country_array = wppb_country_select_options($form_location);
        $old_country_array = array(__('Afghanistan', 'profile-builder'), __('Aland Islands', 'profile-builder'), __('Albania', 'profile-builder'), __('Algeria', 'profile-builder'), __('American Samoa', 'profile-builder'), __('Andorra', 'profile-builder'), __('Angola', 'profile-builder'), __('Anguilla', 'profile-builder'), __('Antarctica', 'profile-builder'), __('Antigua and Barbuda', 'profile-builder'), __('Argentina', 'profile-builder'), __('Armenia', 'profile-builder'), __('Aruba', 'profile-builder'), __('Australia', 'profile-builder'), __('Austria', 'profile-builder'), __('Azerbaijan', 'profile-builder'), __('Bahamas', 'profile-builder'), __('Bahrain', 'profile-builder'), __('Bangladesh', 'profile-builder'), __('Barbados', 'profile-builder'), __('Belarus', 'profile-builder'), __('Belgium', 'profile-builder'), __('Belize', 'profile-builder'), __('Benin', 'profile-builder'), __('Bermuda', 'profile-builder'), __('Bhutan', 'profile-builder'), __('Bolivia, __( Plurinational State of', 'profile-builder'), __('Bonaire, __( Sint Eustatius and Saba', 'profile-builder'), __('Bosnia and Herzegovina', 'profile-builder'), __('Botswana', 'profile-builder'), __('Bouvet Island', 'profile-builder'), __('Brazil', 'profile-builder'), __('British Indian Ocean Territory', 'profile-builder'), __('Brunei Darussalam', 'profile-builder'), __('Bulgaria', 'profile-builder'), __('Burkina Faso', 'profile-builder'), __('Burundi', 'profile-builder'), __('Cambodia', 'profile-builder'), __('Cameroon', 'profile-builder'), __('Canada', 'profile-builder'), __('Cabo Verde', 'profile-builder'), __('Cayman Islands', 'profile-builder'), __('Central African Republic', 'profile-builder'), __('Chad', 'profile-builder'), __('Chile', 'profile-builder'), __('China', 'profile-builder'), __('Christmas Island', 'profile-builder'), __('Cocos (Keeling) Islands', 'profile-builder'), __('Colombia', 'profile-builder'), __('Comoros', 'profile-builder'), __('Congo', 'profile-builder'), __('Congo, __( the Democratic Republic of the', 'profile-builder'), __('Cook Islands', 'profile-builder'), __('Costa Rica', 'profile-builder'), __('Cote dIvoire', 'profile-builder'), __('Croatia', 'profile-builder'), __('Cuba', 'profile-builder'), __('Curacao', 'profile-builder'), __('Cyprus', 'profile-builder'), __('Czech Republic', 'profile-builder'), __('Denmark', 'profile-builder'), __('Djibouti', 'profile-builder'), __('Dominica', 'profile-builder'), __('Dominican Republic', 'profile-builder'), __('Ecuador', 'profile-builder'), __('Egypt', 'profile-builder'), __('El Salvador', 'profile-builder'), __('Equatorial Guinea', 'profile-builder'), __('Eritrea', 'profile-builder'), __('Estonia', 'profile-builder'), __('Ethiopia', 'profile-builder'), __('Falkland Islands (Malvinas)', 'profile-builder'), __('Faroe Islands', 'profile-builder'), __('Fiji', 'profile-builder'), __('Finland', 'profile-builder'), __('France', 'profile-builder'), __('French Guiana', 'profile-builder'), __('French Polynesia', 'profile-builder'), __('French Southern Territories', 'profile-builder'), __('Gabon', 'profile-builder'), __('Gambia', 'profile-builder'), __('Georgia', 'profile-builder'), __('Germany', 'profile-builder'), __('Ghana', 'profile-builder'), __('Gibraltar', 'profile-builder'), __('Greece', 'profile-builder'), __('Greenland', 'profile-builder'), __('Grenada', 'profile-builder'), __('Guadeloupe', 'profile-builder'), __('Guam', 'profile-builder'), __('Guatemala', 'profile-builder'), __('Guernsey', 'profile-builder'), __('Guinea', 'profile-builder'), __('Guinea-Bissau', 'profile-builder'), __('Guyana', 'profile-builder'), __('Haiti', 'profile-builder'), __('Heard Island and McDonald Islands', 'profile-builder'), __('Holy See (Vatican City State)', 'profile-builder'), __('Honduras', 'profile-builder'), __('Hong Kong', 'profile-builder'), __('Hungary', 'profile-builder'), __('Iceland', 'profile-builder'), __('India', 'profile-builder'), __('Indonesia', 'profile-builder'), __('Iran, __( Islamic Republic of', 'profile-builder'), __('Iraq', 'profile-builder'), __('Ireland', 'profile-builder'), __('Isle of Man', 'profile-builder'), __('Israel', 'profile-builder'), __('Italy', 'profile-builder'), __('Jamaica', 'profile-builder'), __('Japan', 'profile-builder'), __('Jersey', 'profile-builder'), __('Jordan', 'profile-builder'), __('Kazakhstan', 'profile-builder'), __('Kenya', 'profile-builder'), __('Kiribati', 'profile-builder'), __('Korea, __( Democratic Peoples Republic of', 'profile-builder'), __('Korea, __( Republic of', 'profile-builder'), __('Kuwait', 'profile-builder'), __('Kyrgyzstan', 'profile-builder'), __('Lao Peoples Democratic Republic', 'profile-builder'), __('Latvia', 'profile-builder'), __('Lebanon', 'profile-builder'), __('Lesotho', 'profile-builder'), __('Liberia', 'profile-builder'), __('Libya', 'profile-builder'), __('Liechtenstein', 'profile-builder'), __('Lithuania', 'profile-builder'), __('Luxembourg', 'profile-builder'), __('Macao', 'profile-builder'), __('Macedonia, __( the former Yugoslav Republic of', 'profile-builder'), __('Madagascar', 'profile-builder'), __('Malawi', 'profile-builder'), __('Malaysia', 'profile-builder'), __('Maldives', 'profile-builder'), __('Mali', 'profile-builder'), __('Malta', 'profile-builder'), __('Marshall Islands', 'profile-builder'), __('Martinique', 'profile-builder'), __('Mauritania', 'profile-builder'), __('Mauritius', 'profile-builder'), __('Mayotte', 'profile-builder'), __('Mexico', 'profile-builder'), __('Micronesia, __( Federated States of', 'profile-builder'), __('Moldova, __( Republic of', 'profile-builder'), __('Monaco', 'profile-builder'), __('Mongolia', 'profile-builder'), __('Montenegro', 'profile-builder'), __('Montserrat', 'profile-builder'), __('Morocco', 'profile-builder'), __('Mozambique', 'profile-builder'), __('Myanmar', 'profile-builder'), __('Namibia', 'profile-builder'), __('Nauru', 'profile-builder'), __('Nepal', 'profile-builder'), __('Netherlands', 'profile-builder'), __('New Caledonia', 'profile-builder'), __('New Zealand', 'profile-builder'), __('Nicaragua', 'profile-builder'), __('Niger', 'profile-builder'), __('Nigeria', 'profile-builder'), __('Niue', 'profile-builder'), __('Norfolk Island', 'profile-builder'), __('Northern Mariana Islands', 'profile-builder'), __('Norway', 'profile-builder'), __('Oman', 'profile-builder'), __('Pakistan', 'profile-builder'), __('Palau', 'profile-builder'), __('Palestine, __( State of', 'profile-builder'), __('Panama', 'profile-builder'), __('Papua New Guinea', 'profile-builder'), __('Paraguay', 'profile-builder'), __('Peru', 'profile-builder'), __('Philippines', 'profile-builder'), __('Pitcairn', 'profile-builder'), __('Poland', 'profile-builder'), __('Portugal', 'profile-builder'), __('Puerto Rico', 'profile-builder'), __('Qatar', 'profile-builder'), __('Reunion', 'profile-builder'), __('Romania', 'profile-builder'), __('Russian Federation', 'profile-builder'), __('Rwanda', 'profile-builder'), __('Saint Barthelemy', 'profile-builder'), __('Saint Helena, __( Ascension and Tristan da Cunha', 'profile-builder'), __('Saint Kitts and Nevis', 'profile-builder'), __('Saint Lucia', 'profile-builder'), __('Saint Martin (French part)', 'profile-builder'), __('Saint Pierre and Miquelon', 'profile-builder'), __('Saint Vincent and the Grenadines', 'profile-builder'), __('Samoa', 'profile-builder'), __('San Marino', 'profile-builder'), __('Sao Tome and Principe', 'profile-builder'), __('Saudi Arabia', 'profile-builder'), __('Senegal', 'profile-builder'), __('Serbia', 'profile-builder'), __('Seychelles', 'profile-builder'), __('Sierra Leone', 'profile-builder'), __('Singapore', 'profile-builder'), __('Sint Maarten (Dutch part)', 'profile-builder'), __('Slovakia', 'profile-builder'), __('Slovenia', 'profile-builder'), __('Solomon Islands', 'profile-builder'), __('Somalia', 'profile-builder'), __('South Africa', 'profile-builder'), __('South Georgia and the South Sandwich Islands', 'profile-builder'), __('South Sudan', 'profile-builder'), __('Spain', 'profile-builder'), __('Sri Lanka', 'profile-builder'), __('Sudan', 'profile-builder'), __('Suriname', 'profile-builder'), __('Svalbard and Jan Mayen', 'profile-builder'), __('Swaziland', 'profile-builder'), __('Sweden', 'profile-builder'), __('Switzerland', 'profile-builder'), __('Syrian Arab Republic', 'profile-builder'), __('Taiwan, __( Province of China', 'profile-builder'), __('Tajikistan', 'profile-builder'), __('Tanzania, __( United Republic of', 'profile-builder'), __('Thailand', 'profile-builder'), __('Timor-Leste', 'profile-builder'), __('Togo', 'profile-builder'), __('Tokelau', 'profile-builder'), __('Tonga', 'profile-builder'), __('Trinidad and Tobago', 'profile-builder'), __('Tunisia', 'profile-builder'), __('Turkey', 'profile-builder'), __('Turkmenistan', 'profile-builder'), __('Turks and Caicos Islands', 'profile-builder'), __('Tuvalu', 'profile-builder'), __('Uganda', 'profile-builder'), __('Ukraine', 'profile-builder'), __('United Arab Emirates', 'profile-builder'), __('United Kingdom', 'profile-builder'), __('United States', 'profile-builder'), __('United States Minor Outlying Islands', 'profile-builder'), __('Uruguay', 'profile-builder'), __('Uzbekistan', 'profile-builder'), __('Vanuatu', 'profile-builder'), __('Venezuela, __( Bolivarian Republic of', 'profile-builder'), __('Viet Nam', 'profile-builder'), __('Virgin Islands, __( British', 'profile-builder'), __('Virgin Islands, __( U.S.', 'profile-builder'), __('Wallis and Futuna', 'profile-builder'), __('Western Sahara', 'profile-builder'), __('Yemen', 'profile-builder'), __('Zambia', 'profile-builder'), __('Zimbabwe', 'profile-builder'));
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            // change current user country meta_value with country ISO code
            $user_country_option = wppb_user_meta_exists($user_id, $field['meta-name']);
            if ($user_country_option != null) {
                if (in_array($user_country_option->meta_value, $old_country_array)) {
                    $country_iso = array_search($user_country_option->meta_value, $country_array);
                    update_user_meta($user_id, $field['meta-name'], $country_iso);
                }
            }
            $input_value = $user_country_option != null ? $country_array[stripslashes(get_user_meta($user_id, $field['meta-name'], true))] : $country_array[$field['default-option-country']];
        } else {
            $input_value = !empty($field['default-option-country']) ? $country_array[trim($field['default-option-country'])] : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? $country_array[trim($request_data[wppb_handle_meta_name($field['meta-name'])])] : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_country_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>';
            $extra_select_option = apply_filters('wppb_extra_select_option', '', $field, $item_title);
            if (!empty($extra_select_option)) {
                $output .= $extra_select_option;
                $country_array = array_filter($country_array);
            }
            foreach ($country_array as $iso => $country) {
                $output .= '<option value="' . $iso . '"';
                if ($input_value === $country) {
                    $output .= ' selected';
                }
                $output .= '>' . $country . '</option>';
            }
            $output .= '
				</select>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<select name="' . $field['meta-name'] . '" class="custom_field_country_select" id="' . $field['meta-name'] . '" ' . $extra_attr . '>';
            foreach ($country_array as $iso => $country) {
                $output .= '<option value="' . $iso . '"';
                if ($input_value === $country) {
                    $output .= ' selected';
                }
                $output .= '>' . $country . '</option>';
            }
            $output .= '</select>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_country_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 12
0
function wppb_select2_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Select2') {
        wp_enqueue_script('wppb_select2', WPPBSL2_PLUGIN_URL . 'assets/js/select2_init.js', array('jquery'));
        wp_enqueue_script('wppb_sl2_lib_js', WPPBSL2_PLUGIN_URL . 'assets/select2-lib/dist/js/select2.min.js', array('jquery'));
        wp_enqueue_style('wppb_sl2_lib_css', WPPBSL2_PLUGIN_URL . 'assets/select2-lib/dist/css/select2.min.css');
        wp_enqueue_style('wppb_sl2_css', WPPBSL2_PLUGIN_URL . 'assets/css/style-front-end.css');
        $item_title = apply_filters('wppb_' . $form_location . '_select2_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $item_option_labels = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_option_labels_translation', $field['labels']);
        $select2_labels = explode(',', $item_option_labels);
        $select2_values = explode(',', $field['options']);
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? stripslashes(get_user_meta($user_id, $field['meta-name'], true)) : $field['default-option'];
        } else {
            $input_value = !empty($field['default-option']) ? trim($field['default-option']) : '';
        }
        $input_value = isset($request_data[wppb_sl2_handle_meta_name($field['meta-name'])]) ? stripslashes(trim($request_data[wppb_sl2_handle_meta_name($field['meta-name'])])) : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_select2" ' . $extra_attr . '>';
            foreach ($select2_values as $key => $value) {
                $output .= '<option value="' . esc_attr(trim($value)) . '" class="custom_field_select2_option ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ';
                if ($input_value === trim($value)) {
                    $output .= ' selected';
                }
                $output .= '>' . (!isset($select2_labels[$key]) || !$select2_labels[$key] ? trim($select2_values[$key]) : trim($select2_labels[$key])) . '</option>';
            }
            $output .= '
				</select>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $item_title = $field['required'] == 'Yes' ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title;
            $output = '
				<table class="form-table wppb-select2">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<select name="' . $field['meta-name'] . '" class="custom_field_select2" id="' . $field['meta-name'] . '" ' . $extra_attr . '>';
            foreach ($select2_values as $key => $value) {
                $output .= '<option value="' . esc_attr(trim($value)) . '" class="custom_field_select2_option" ';
                if ($input_value === trim($value)) {
                    $output .= ' selected';
                }
                $output .= '>' . (!isset($select2_labels[$key]) || !$select2_labels[$key] ? trim($select2_values[$key]) : trim($select2_labels[$key])) . '</option>';
            }
            $output .= '</select>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_select2_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 13
0
function wppb_timepicker_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Timepicker') {
        $item_title = apply_filters('wppb_' . $form_location . '_timepicker_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? stripslashes(get_user_meta($user_id, $field['meta-name'], true)) : '';
        } else {
            $input_value = '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) && !empty($request_data[wppb_handle_meta_name($field['meta-name'])]['hours']) && !empty($request_data[wppb_handle_meta_name($field['meta-name'])]['minutes']) ? $request_data[wppb_handle_meta_name($field['meta-name'])] : $input_value;
        // Get the hour and minutes saved for the field
        $value_hours = '';
        $value_minutes = '';
        if (is_array($input_value)) {
            $value_hours = $input_value['hours'];
            $value_minutes = $input_value['minutes'];
        } elseif (!empty($input_value)) {
            $time = explode(':', $input_value);
            $value_hours = $time[0];
            $value_minutes = $time[1];
        }
        // Set hours for time
        $hours = array();
        for ($i = 0; $i <= 23; $i++) {
            array_push($hours, strlen($i) == 1 ? '0' . $i : $i);
        }
        // Set minutes
        $minutes = array();
        for ($i = 0; $i <= 59; $i++) {
            array_push($minutes, strlen($i) == 1 ? '0' . $i : $i);
        }
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            // Label
            $output = '
				<label for="' . $field['meta-name'] . '-hour">' . $item_title . $error_mark . '</label>';
            // Add hour select
            $output .= '<select name="' . $field['meta-name'] . '[hours]" id="' . $field['meta-name'] . '-hour" class="custom_field_timepicker_hours ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>';
            foreach ($hours as $hour) {
                $output .= '<option value="' . $hour . '"';
                if ($value_hours == $hour) {
                    $output .= ' selected';
                }
                if ($field['time-format'] == '12') {
                    if ($hour > 12) {
                        $hour -= 12;
                        $hour = (strlen($hour) == 1 ? '0' . $hour : $hour) . ' pm';
                    } elseif ($hour == 12) {
                        $hour .= ' pm';
                    } elseif ($hour == '00') {
                        $hour = '12 am';
                    } else {
                        $hour .= ' am';
                    }
                }
                $output .= '>' . $hour . '</option>';
            }
            $output .= '</select>';
            // Add divider
            $output .= '<span class="wppb-timepicker-separator">:</span>';
            // Add minutes select
            $output .= '<select name="' . $field['meta-name'] . '[minutes]" id="' . $field['meta-name'] . '-minutes" class="custom_field_timepicker_minutes ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>';
            foreach ($minutes as $minute) {
                $output .= '<option value="' . $minute . '"';
                if ($value_minutes == $minute) {
                    $output .= ' selected';
                }
                $output .= '>' . $minute . '</option>';
            }
            $output .= '</select>';
            // Add description
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>';
            // Add hours select
            $output .= '<select name="' . $field['meta-name'] . '[hours]" class="custom_field_timepicker_hours" id="' . $field['meta-name'] . '-minutes" ' . $extra_attr . '>';
            foreach ($hours as $hour) {
                $output .= '<option value="' . $hour . '"';
                if ($value_hours == $hour) {
                    $output .= ' selected';
                }
                if ($field['time-format'] == '12') {
                    if ($hour > 12) {
                        $hour -= 12;
                        $hour = (strlen($hour) == 1 ? '0' . $hour : $hour) . ' pm';
                    } elseif ($hour == 12) {
                        $hour .= ' pm';
                    } elseif ($hour == '00') {
                        $hour = '12 am';
                    } else {
                        $hour .= ' am';
                    }
                }
                $output .= '>' . $hour . '</option>';
            }
            $output .= '</select>';
            // Add divider
            $output .= '<span class="wppb-timepicker-separator">:</span>';
            // Add minutes select
            $output .= '<select name="' . $field['meta-name'] . '[minutes]" class="custom_field_timepicker_minutes" id="' . $field['meta-name'] . '-minutes" ' . $extra_attr . '>';
            foreach ($minutes as $minute) {
                $output .= '<option value="' . $minute . '"';
                if ($value_minutes == $minute) {
                    $output .= ' selected';
                }
                $output .= '>' . $minute . '</option>';
            }
            $output .= '</select>';
            $output .= '<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_currency_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}
Exemplo n.º 14
0
function wppb_currency_select_handler($output, $form_location, $field, $user_id, $field_check_errors, $request_data)
{
    if ($field['field'] == 'Select (Currency)') {
        $item_title = apply_filters('wppb_' . $form_location . '_currency_select_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title']));
        $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']);
        $currencies = wppb_get_currencies($form_location);
        array_unshift($currencies, '');
        $extra_attr = apply_filters('wppb_extra_attribute', '', $field);
        if ($form_location != 'register') {
            $input_value = wppb_user_meta_exists($user_id, $field['meta-name']) != null ? stripslashes(get_user_meta($user_id, $field['meta-name'], true)) : $field['default-option-currency'];
        } else {
            $input_value = !empty($field['default-option-currency']) ? trim($field['default-option-currency']) : '';
        }
        $input_value = isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? trim($request_data[wppb_handle_meta_name($field['meta-name'])]) : $input_value;
        if ($form_location != 'back_end') {
            $error_mark = $field['required'] == 'Yes' ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : '';
            if (array_key_exists($field['id'], $field_check_errors)) {
                $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>';
            }
            $output = '
				<label for="' . $field['meta-name'] . '">' . $item_title . $error_mark . '</label>
				<select name="' . $field['meta-name'] . '" id="' . $field['meta-name'] . '" class="custom_field_currency_select ' . apply_filters('wppb_fields_extra_css_class', '', $field) . '" ' . $extra_attr . '>';
            $extra_select_option = apply_filters('wppb_extra_select_option', '', $field, $item_title);
            if (!empty($extra_select_option)) {
                $output .= $extra_select_option;
                $currencies = array_filter($currencies);
            }
            // Check to see if the currency symbol should be displayed or not
            $show_currency_symbol = !empty($field['show-currency-symbol']) && $field['show-currency-symbol'] == 'Yes' ? true : false;
            foreach ($currencies as $iso => $currency_name) {
                $output .= '<option value="' . (empty($iso) ? '' : $iso) . '"';
                if ($input_value === $iso) {
                    $output .= ' selected';
                }
                if ($show_currency_symbol) {
                    $currency_symbol = wppb_get_currency_symbol($iso);
                }
                $currency_name = !empty($currency_symbol) ? $currency_name . ' (' . $currency_symbol . ')' : $currency_name;
                $output .= '>' . $currency_name . '</option>';
            }
            $output .= '
				</select>';
            if (!empty($item_description)) {
                $output .= '<span class="wppb-description-delimiter">' . $item_description . '</span>';
            }
        } else {
            $output = '
				<table class="form-table">
					<tr>
						<th><label for="' . $field['meta-name'] . '">' . $item_title . '</label></th>
						<td>
							<select name="' . $field['meta-name'] . '" class="custom_field_currency_select" id="' . $field['meta-name'] . '" ' . $extra_attr . '>';
            // Check to see if the currency symbol should be displayed or not
            $show_currency_symbol = !empty($field['show-currency-symbol']) && $field['show-currency-symbol'] == 'Yes' ? true : false;
            foreach ($currencies as $iso => $currency_name) {
                $output .= '<option value="' . $iso . '"';
                if ($input_value === $iso) {
                    $output .= ' selected';
                }
                if ($show_currency_symbol) {
                    $currency_symbol = wppb_get_currency_symbol($iso);
                }
                $currency_name = !empty($currency_symbol) ? $currency_name . ' (' . $currency_symbol . ')' : $currency_name;
                $output .= '>' . $currency_name . '</option>';
            }
            $output .= '</select>
							<span class="description">' . $item_description . '</span>
						</td>
					</tr>
				</table>';
        }
        return apply_filters('wppb_' . $form_location . '_currency_select_custom_field_' . $field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value);
    }
}