/home/vianto5/cititower.mx/wp-content/plugins/wpforms/src/Pro/Forms/Fields/Repeater
NameSizeModeActions
Builder.php170590644editdlrm
Field.php54570644editdlrm
Frontend.php199950644editdlrm
Helpers.php93600644editdlrm
Notifications.php88740644editdlrm
Process.php177320644editdlrm
Edit: /home/vianto5/cititower.mx/wp-content/plugins/wpforms/src/Pro/Forms/Fields/Repeater/Builder.php (17059B)
layout_hooks(); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); add_filter( 'wpforms_builder_strings', [ $this, 'get_localized_strings' ], 10, 2 ); add_action( 'wpforms_builder_print_footer_scripts', [ $this, 'field_preview_display_rows_buttons_template' ] ); } /** * Enqueue assets. * * @since 1.8.9 */ public function enqueue_assets(): void { $min = wpforms_get_min_suffix(); wp_enqueue_script( 'wpforms-builder-field-repeater', WPFORMS_PLUGIN_URL . "assets/pro/js/admin/builder/fields/repeater{$min}.js", [ 'wpforms-builder', 'wpforms-builder-field-layout' ], WPFORMS_VERSION, true ); } /** * Pass localized strings to builder. * * @since 1.8.9 * * @param array|mixed $strings All strings that will be passed to builder. * @param WP_Post $form Form object. * * @return array */ public function get_localized_strings( $strings, $form ): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed $strings = (array) $strings; $form_data = wpforms_decode( $form->post_content ?? '' ); $strings['repeater'] = [ 'size_notice_text' => esc_html__( 'Field size cannot be changed when used in a repeater.', 'wpforms' ), 'size_notice_tooltip' => esc_html__( 'When a field is placed inside a column, the field size always equals the column width.', 'wpforms' ), 'not_allowed_fields' => $this->field_obj->get_not_allowed_fields(), 'rows_limit_max' => Field::ROWS_LIMIT_MAX, 'not_allowed' => esc_html__( 'Not Allowed', 'wpforms' ), /* translators: %s - Field name. */ 'not_allowed_alert_text' => esc_html__( 'The %s field can’t be placed inside a Repeater field.', 'wpforms' ), 'move_to_rows_rejected_alert' => esc_html__( 'Only one field is allowed in each column when the Display option is set to Rows.', 'wpforms' ), 'multi_select_to_rows_rejected_alert' => esc_html__( 'These fields cannot be dragged here.', 'wpforms' ), 'cant_switch_to_rows_alert' => esc_html__( 'You can\'t change Display to Rows because only one field per column is allowed.', 'wpforms' ), 'cl_notice_text' => esc_html__( 'Conditional Logic cannot be enabled when the field is inside a Repeater.', 'wpforms' ), 'cl_notice_text_grp' => esc_html__( 'Conditional Logic has been disabled because this field has been placed inside a Repeater.', 'wpforms' ), 'calculation_notice_text' => esc_html__( 'Calculation cannot be enabled when the field is inside a Repeater.', 'wpforms' ), 'calculation_notice_text_grp' => esc_html__( 'Calculation has been disabled because this field has been placed inside a Repeater.', 'wpforms' ), 'calculation_notice_tooltip' => esc_html__( 'When a field is placed inside a Repeater field, Calculation is disabled.', 'wpforms' ), 'delete_confirm' => esc_html__( 'Are you sure you want to delete the Repeater field? Deleting this field will also delete the fields inside it.', 'wpforms' ), 'enabled_cf_alert_text' => esc_html__( 'Conversational Forms cannot be enabled because your form contains a Repeater field.', 'wpforms' ), 'field_add_cf_alert_text' => esc_html__( 'The Repeater field cannot be used when Conversational Forms is enabled.', 'wpforms' ), 'addons_requirements' => [ 'wpforms-form-abandonment' => RequirementsAlerts::is_inside_repeater_allowed( 'wpforms-form-abandonment' ), 'wpforms-save-resume' => RequirementsAlerts::is_inside_repeater_allowed( 'wpforms-save-resume' ), 'wpforms-geolocation' => RequirementsAlerts::is_inside_repeater_allowed( 'wpforms-geolocation' ), 'wpforms-signatures' => RequirementsAlerts::is_inside_repeater_allowed( 'wpforms-signatures' ), 'wpforms-lead-forms' => RequirementsAlerts::is_inside_repeater_allowed( 'wpforms-lead-forms' ), 'wpforms-google-sheets' => RequirementsAlerts::is_inside_repeater_allowed( 'wpforms-google-sheets' ), ], 'addons_requirements_alert_text' => [ 'wpforms-form-abandonment' => RequirementsAlerts::get_repeater_alert_text( 'Form Abandonment' ), 'wpforms-save-resume' => RequirementsAlerts::get_repeater_alert_text( 'Save and Resume' ), 'wpforms-lead-forms' => esc_html__( 'Lead Forms cannot be enabled because your form contains a Repeater field.', 'wpforms' ), 'wpforms-google-sheets' => RequirementsAlerts::get_repeater_alert_text( 'Google Sheets' ), ], 'is_google_sheets_has_connection' => ! empty( $form_data['providers']['google-sheets'] ), 'addons_requirements_alert' => [ 'wpforms-geolocation' => RequirementsAlerts::get_repeater_alert( 'Geolocation', 'wpforms-geolocation' ), 'wpforms-signatures' => RequirementsAlerts::get_repeater_alert( 'Signatures', 'wpforms-signatures' ), 'wpforms-lead-forms' => esc_html__( 'The Repeater field cannot be used when Lead Forms is enabled.', 'wpforms' ), ], 'fields_mapping' => [ 'title' => esc_html__( 'Are you sure you want to move this field?', 'wpforms' ), 'and' => esc_html__( 'and', 'wpforms' ), /* translators: %s - Addon name. */ 'content' => esc_html__( 'It\'s currently mapped to %s, which will be reset if you add this field to a repeater.', 'wpforms' ), ], ]; return $strings; } /** * Field options panel. * * @since 1.8.9 * * @param array $field Field settings. */ public function field_options( $field ) { $this->field_option_columns_json( $field ); // Basic options open markup. $this->field_obj->field_option( 'basic-options', $field, [ 'markup' => 'open', ] ); $this->field_obj->field_option( 'label', $field, [ 'tooltip' => esc_html__( 'Enter text for the repeater field label. Repeater labels are more like headings and can be hidden in the Advanced Settings.', 'wpforms' ), ] ); $this->field_option_display_selector( $field ); $this->field_option_preset_selector( $field ); $this->field_option_button_type( $field ); $this->field_option_button_labels( $field ); $this->field_option_limit( $field ); // Basic options close markup. $this->field_obj->field_option( 'basic-options', $field, [ 'markup' => 'close', ] ); // Advanced options open markup. $this->field_obj->field_option( 'advanced-options', $field, [ 'markup' => 'open', ] ); $this->field_options_advanced( $field ); // Advanced options close markup. $this->field_obj->field_option( 'advanced-options', $field, [ 'markup' => 'close', ] ); } /** * The Advanced field options. * * @since 1.8.9 * * @param array $field Field settings. */ private function field_options_advanced( $field ): void { // Size. $this->field_obj->field_option( 'size', $field, [ 'class' => $field['preset'] !== '100' ? 'wpforms-disabled' : '', ] ); // Description. $this->field_obj->field_option( 'description', $field ); // Hide label. $this->field_obj->field_option( 'label_hide', $field ); } /** * The `Display` field option. * * @since 1.8.9 * * @param array $field Field settings. * * @noinspection HtmlUnknownAttribute */ private function field_option_display_selector( $field ): void { $this->field_obj->field_element( 'label', $field, [ 'slug' => 'display', 'value' => esc_html__( 'Display', 'wpforms' ), 'tooltip' => esc_html__( 'Choose whether you want your fields to be repeated as single rows or as a block of fields.', 'wpforms' ), ] ); $inputs = ''; foreach ( Field::DISPLAY_VALUES as $value ) { $inputs .= sprintf( '', (int) $field['id'], esc_attr( $value ), $field['display'] === $value ? 'checked' : '' ); } $this->field_obj->field_element( 'row', $field, [ 'slug' => 'display', 'content' => $inputs, ] ); } /** * The Button Type field option. * * @since 1.8.9 * * @param array $field Field settings. */ private function field_option_button_type( $field ): void { $output = $this->field_obj->field_element( 'label', $field, [ 'slug' => 'button_type', 'value' => esc_html__( 'Button Type', 'wpforms' ), 'tooltip' => esc_html__( 'Select the type of buttons to use for the repeater field.', 'wpforms' ), ], false ); $output .= $this->field_obj->field_element( 'select', $field, [ 'slug' => 'button_type', 'value' => $field['button_type'] ?? 'buttons_with_icons', 'options' => [ 'buttons_with_icons' => esc_html__( 'Buttons with icons', 'wpforms' ), 'buttons' => esc_html__( 'Buttons', 'wpforms' ), 'icons_with_text' => esc_html__( 'Icons with text', 'wpforms' ), 'icons' => esc_html__( 'Icons', 'wpforms' ), 'plain_text' => esc_html__( 'Plain text', 'wpforms' ), ], ], false ); $this->field_obj->field_element( 'row', $field, [ 'slug' => 'button-type', 'content' => $output, 'class' => $field['display'] === 'rows' ? 'wpforms-hidden' : '', ] ); } /** * The Button Labels field options. * * @since 1.8.9 * * @param array $field Field settings. */ private function field_option_button_labels( $field ): void { printf( '
', $field['display'] === 'rows' ? 'wpforms-hidden' : '', (int) $field['id'] ); $this->field_obj->field_element( 'label', $field, [ 'slug' => 'button_labels', 'value' => esc_html__( 'Button Labels', 'wpforms' ), 'tooltip' => esc_html__( 'Enter text for the repeater field buttons.', 'wpforms' ), ] ); echo '
'; echo '
'; printf( '', absint( $field['id'] ), esc_attr( $field['button_add_label'] ?? $this->field_obj->defaults['button_add_label'] ) ); printf( '', (int) $field['id'], esc_html__( 'Add Label', 'wpforms' ) ); echo '
'; echo '
'; printf( '', (int) $field['id'], esc_attr( $field['button_remove_label'] ?? $this->field_obj->defaults['button_remove_label'] ) ); printf( '', absint( $field['id'] ), esc_html__( 'Add Label', 'wpforms' ) ); echo '
'; echo '
'; echo '
'; } /** * The Limit rows field options. * * @since 1.8.9 * * @param array $field Field settings. */ private function field_option_limit( $field ): void { printf( '
', (int) $field['id'] ); $this->field_obj->field_element( 'label', $field, [ 'slug' => 'rows_limit', 'value' => esc_html__( 'Limit', 'wpforms' ), 'tooltip' => esc_html__( 'Set the minimum and maximum number of times the field can be repeated.', 'wpforms' ), ] ); echo '
'; echo '
'; printf( '', absint( $field['id'] ), esc_attr( $field['rows_limit_min'] ?? $this->field_obj->defaults['rows_limit_min'] ), Field::ROWS_LIMIT_MAX // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); printf( '', (int) $field['id'], esc_html__( 'Minimum', 'wpforms' ) ); echo '
'; echo '
'; printf( '', (int) $field['id'], esc_attr( $field['rows_limit_max'] ?? $this->field_obj->defaults['rows_limit_max'] ), Field::ROWS_LIMIT_MAX // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); printf( '', absint( $field['id'] ), esc_html__( 'Maximum', 'wpforms' ) ); echo '
'; echo '
'; echo '
'; } /** * Output the Repeater field preview columns wrapped by columns' container. * * @since 1.8.9 * * @param string $columns_html Columns HTML. * @param string $columns_class Columns container CSS class. * @param array $field Field settings. */ protected function field_preview_columns_wrap( $columns_html, $columns_class, $field ) { $display = $field['display'] ?? $this->field_obj->defaults['display']; $row_buttons_class = $display === 'rows' ? '' : 'wpforms-hidden'; printf( '
%2$s%3$s
%4$s ', esc_attr( $columns_class ), $columns_html, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $this->get_field_preview_display_rows_buttons( $row_buttons_class ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $this->get_field_preview_display_blocks_buttons( $field ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); } /** * Get the Display rows buttons. * * @since 1.8.9 * * @param string $class_name CSS class name. * * @return string */ private function get_field_preview_display_rows_buttons( string $class_name = '' ): string { return sprintf( '
', esc_attr( $class_name ) ); } /** * Get the Display blocks buttons. * * @since 1.8.9 * * @param array $field Field settings. * * @return string */ private function get_field_preview_display_blocks_buttons( $field ): string { $display = $field['display'] ?? $this->field_obj->defaults['display']; $button_type = $field['button_type'] ?? $this->field_obj->defaults['button_type']; $class_name = $display === 'blocks' ? '' : 'wpforms-hidden'; return sprintf( '
', esc_attr( $class_name ), esc_attr( $button_type ), esc_html( $field['button_add_label'] ?? $this->field_obj->defaults['button_add_label'] ), esc_html( $field['button_remove_label'] ?? $this->field_obj->defaults['button_remove_label'] ) ); } /** * Output template of the Display rows buttons. * * @since 1.8.9 */ public function field_preview_display_rows_buttons_template() { ?>