| @@ -1,127 +1,126 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Column Field Class | |
| 5 | - */ | |
| 6 | -class WeForms_Form_Field_Column extends WeForms_Field_Contract { | |
| 7 | - | |
| 8 | - public function __construct() { | |
| 9 | - $this->name = __( 'Columns', 'weforms' ); | |
| 10 | - $this->input_type = 'column_field'; | |
| 11 | - $this->icon = 'columns'; | |
| 12 | - } | |
| 13 | - | |
| 14 | - /** | |
| 15 | - * Render the Column field | |
| 16 | - * | |
| 17 | - * @param array $field_settings | |
| 18 | - * @param int $form_id | |
| 19 | - * @param string $type | |
| 20 | - * @param int $post_id | |
| 21 | - * | |
| 22 | - * @return void | |
| 23 | - */ | |
| 24 | - public function render( $field_settings, $form_id, $type = 'post', $post_id = null ) { | |
| 25 | - $use_theme_css = isset( $form_settings['use_theme_css'] ) ? $form_settings['use_theme_css'] : 'wpuf-style'; | |
| 26 | - $i = 1; | |
| 27 | - $columns = $field_settings['columns']; | |
| 28 | - $columns_size = $field_settings['inner_columns_size']; | |
| 29 | - $column_space = $field_settings['column_space']; | |
| 30 | - $inner_fields = $field_settings['inner_fields']; | |
| 31 | - $atts = []; ?> | |
| 32 | - <li class="wpuf-el"> | |
| 33 | - <div class="wpuf-field-columns <?php echo 'has-columns-' . esc_attr( $columns ); ?>" data-style="<?php echo esc_attr( $use_theme_css ); ?>"> | |
| 34 | - <div class="wpuf-column-field-inner-columns"> | |
| 35 | - <div class="wpuf-column"> | |
| 36 | - <?php while ( $i <= $columns ) { ?> | |
| 37 | - <div class="<?php echo 'column-' . esc_attr( $i ) . ' items-of-column-' . esc_attr( $columns ); ?> wpuf-column-inner-fields"> | |
| 38 | - <ul class="wpuf-column-fields"> | |
| 39 | - <?php weforms()->fields->render_fields( $inner_fields['column-' . $i], $form_id, $atts, $type, $post_id ); ?> | |
| 40 | - </ul> | |
| 41 | - </div> | |
| 42 | - | |
| 43 | - <?php $i++; ?> | |
| 44 | - <?php } ?> | |
| 45 | - </div> | |
| 46 | - </div> | |
| 47 | - </div> | |
| 48 | - </li> | |
| 49 | - <?php | |
| 50 | - } | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * It's a full width block | |
| 54 | - * | |
| 55 | - * @return bool | |
| 56 | - */ | |
| 57 | - public function is_full_width() { | |
| 58 | - return true; | |
| 59 | - } | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * Get field options setting | |
| 63 | - * | |
| 64 | - * @return array | |
| 65 | - */ | |
| 66 | - public function get_options_settings() { | |
| 67 | - $options = [ | |
| 68 | - [ | |
| 69 | - 'name' => 'columns', | |
| 70 | - 'title' => __( 'Number of Columns', 'weforms' ), | |
| 71 | - 'type' => 'range', | |
| 72 | - 'section' => 'basic', | |
| 73 | - 'priority' => 10, | |
| 74 | - 'help_text' => __( 'Title of the section', 'weforms' ), | |
| 75 | - ], | |
| 76 | - [ | |
| 77 | - 'name' => 'column_space', | |
| 78 | - 'title' => __( 'Space Between Columns', 'weforms' ), | |
| 79 | - 'type' => 'text', | |
| 80 | - 'section' => 'basic', | |
| 81 | - 'priority' => 11, | |
| 82 | - 'help_text' => __( 'Add padding space between columns. e.g: 10', 'weforms' ), | |
| 83 | - ], | |
| 84 | - [ | |
| 85 | - 'name' => 'css', | |
| 86 | - 'title' => __( 'CSS Class Name', 'weforms' ), | |
| 87 | - 'type' => 'text', | |
| 88 | - 'section' => 'advanced', | |
| 89 | - 'priority' => 22, | |
| 90 | - 'help_text' => __( 'Provide a container class name for this field. Available classes: wpuf-col-half, wpuf-col-half-last, wpuf-col-one-third, wpuf-col-one-third-last', 'weforms' ), | |
| 91 | - ], | |
| 92 | - ]; | |
| 93 | - | |
| 94 | - return apply_filters( 'wpuf_text_field_option_settings', $options ); | |
| 95 | - } | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * Get the field props | |
| 99 | - * | |
| 100 | - * @return array | |
| 101 | - */ | |
| 102 | - public function get_field_props() { | |
| 103 | - $props = [ | |
| 104 | - 'input_type' => 'column_field', | |
| 105 | - 'template' => $this->get_type(), | |
| 106 | - 'id' => 0, | |
| 107 | - 'is_new' => true, | |
| 108 | - 'is_meta' => 'no', | |
| 109 | - 'columns' => 3, | |
| 110 | - 'min_column' => 1, | |
| 111 | - 'max_column' => 3, | |
| 112 | - 'column_space' => '5', | |
| 113 | - 'inner_fields' => [ | |
| 114 | - 'column-1' => [], | |
| 115 | - 'column-2' => [], | |
| 116 | - 'column-3' => [], | |
| 117 | - ], | |
| 118 | - 'inner_columns_size' => [ | |
| 119 | - 'column-1' => '33.33%', | |
| 120 | - 'column-2' => '33.33%', | |
| 121 | - 'column-3' => '33.33%', | |
| 122 | - ], | |
| 123 | - ]; | |
| 124 | - | |
| 125 | - return $props; | |
| 126 | - } | |
| 127 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Column Field Class | |
| 5 | + */ | |
| 6 | +class WeForms_Form_Field_Column extends WeForms_Field_Contract { | |
| 7 | + | |
| 8 | + public function __construct() { | |
| 9 | + $this->name = __( 'Columns', 'weforms' ); | |
| 10 | + $this->input_type = 'column_field'; | |
| 11 | + $this->icon = 'columns'; | |
| 12 | + } | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Render the Column field | |
| 16 | + * | |
| 17 | + * @param array $field_settings | |
| 18 | + * @param int $form_id | |
| 19 | + * @param string $type | |
| 20 | + * @param int $post_id | |
| 21 | + * | |
| 22 | + * @return void | |
| 23 | + */ | |
| 24 | + public function render( $field_settings, $form_id, $type = 'post', $post_id = null ) { | |
| 25 | + $i = 1; | |
| 26 | + $columns = $field_settings['columns']; | |
| 27 | + $columns_size = $field_settings['inner_columns_size']; | |
| 28 | + $column_space = $field_settings['column_space']; | |
| 29 | + $inner_fields = $field_settings['inner_fields']; | |
| 30 | + $atts = []; ?> | |
| 31 | + <li class="wpuf-el"> | |
| 32 | + <div class="wpuf-field-columns <?php echo 'has-columns-' . esc_attr( $columns ); ?>"> | |
| 33 | + <div class="wpuf-column-field-inner-columns"> | |
| 34 | + <div class="wpuf-column"> | |
| 35 | + <?php while ( $i <= $columns ) { ?> | |
| 36 | + <div class="<?php echo 'column-' . esc_attr( $i ); ?> <?php echo 'items-of-column-' . esc_attr( $columns ); ?> wpuf-column-inner-fields" style="width: <?php echo esc_attr( $columns_size['column-'.$i] ); ?>; padding-right: <?php echo esc_attr( $column_space ) . 'px'; ?>"> | |
| 37 | + <ul class="wpuf-column-fields"> | |
| 38 | + <?php weforms()->fields->render_fields( $inner_fields['column-' . $i], $form_id, $atts, $type, $post_id ); ?> | |
| 39 | + </ul> | |
| 40 | + </div> | |
| 41 | + | |
| 42 | + <?php $i++; ?> | |
| 43 | + <?php } ?> | |
| 44 | + </div> | |
| 45 | + </div> | |
| 46 | + </div> | |
| 47 | + </li> | |
| 48 | + <?php | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * It's a full width block | |
| 53 | + * | |
| 54 | + * @return bool | |
| 55 | + */ | |
| 56 | + public function is_full_width() { | |
| 57 | + return true; | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Get field options setting | |
| 62 | + * | |
| 63 | + * @return array | |
| 64 | + */ | |
| 65 | + public function get_options_settings() { | |
| 66 | + $options = [ | |
| 67 | + [ | |
| 68 | + 'name' => 'columns', | |
| 69 | + 'title' => __( 'Number of Columns', 'weforms' ), | |
| 70 | + 'type' => 'range', | |
| 71 | + 'section' => 'basic', | |
| 72 | + 'priority' => 10, | |
| 73 | + 'help_text' => __( 'Title of the section', 'weforms' ), | |
| 74 | + ], | |
| 75 | + [ | |
| 76 | + 'name' => 'column_space', | |
| 77 | + 'title' => __( 'Space Between Columns', 'weforms' ), | |
| 78 | + 'type' => 'text', | |
| 79 | + 'section' => 'basic', | |
| 80 | + 'priority' => 11, | |
| 81 | + 'help_text' => __( 'Add padding space between columns. e.g: 10', 'weforms' ), | |
| 82 | + ], | |
| 83 | + [ | |
| 84 | + 'name' => 'css', | |
| 85 | + 'title' => __( 'CSS Class Name', 'weforms' ), | |
| 86 | + 'type' => 'text', | |
| 87 | + 'section' => 'advanced', | |
| 88 | + 'priority' => 22, | |
| 89 | + 'help_text' => __( 'Provide a container class name for this field. Available classes: wpuf-col-half, wpuf-col-half-last, wpuf-col-one-third, wpuf-col-one-third-last', 'weforms' ), | |
| 90 | + ], | |
| 91 | + ]; | |
| 92 | + | |
| 93 | + return apply_filters( 'wpuf_text_field_option_settings', $options ); | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * Get the field props | |
| 98 | + * | |
| 99 | + * @return array | |
| 100 | + */ | |
| 101 | + public function get_field_props() { | |
| 102 | + $props = [ | |
| 103 | + 'input_type' => 'column_field', | |
| 104 | + 'template' => $this->get_type(), | |
| 105 | + 'id' => 0, | |
| 106 | + 'is_new' => true, | |
| 107 | + 'is_meta' => 'no', | |
| 108 | + 'columns' => 3, | |
| 109 | + 'min_column' => 1, | |
| 110 | + 'max_column' => 3, | |
| 111 | + 'column_space' => '5', | |
| 112 | + 'inner_fields' => [ | |
| 113 | + 'column-1' => [], | |
| 114 | + 'column-2' => [], | |
| 115 | + 'column-3' => [], | |
| 116 | + ], | |
| 117 | + 'inner_columns_size' => [ | |
| 118 | + 'column-1' => '33.33%', | |
| 119 | + 'column-2' => '33.33%', | |
| 120 | + 'column-3' => '33.33%', | |
| 121 | + ], | |
| 122 | + ]; | |
| 123 | + | |
| 124 | + return $props; | |
| 125 | + } | |
| 126 | +} | |