PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 1.1.12
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v1.1.12
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / classes / class-cartflows-admin-fields.php

class-cartflows-admin-fields.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 1.1.12, at classes/class-cartflows-admin-fields.php

199 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CARTFLOWS Admin Fields.
4 *
5 * @package CARTFLOWS
6 */
7
8 /**
9 * Class Cartflows_Admin_Fields.
10 */
11 class Cartflows_Admin_Fields {
12
13 /**
14 * Text Field
15 *
16 * @param array $args Args.
17 * @return string
18 */
19 static public function text_field( $args ) {
20
21 $id = $args['id'];
22 $name = $args['name'];
23 $title = $args['title'];
24 $value = $args['value'];
25
26 $output = '<div class="form-field" id="form-field-' . $id . '">';
27 $output .= '<label for="' . $id . '">' . $title . '</label>';
28 $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
29 $output .= '</div>';
30
31 return $output;
32 }
33
34 /**
35 * URL Field
36 *
37 * @param array $args Args.
38 * @return string
39 */
40 static public function url_field( $args ) {
41
42 $id = $args['id'];
43 $name = $args['name'];
44 $title = $args['title'];
45 $value = $args['value'];
46
47 $output = '<div class="form-field">';
48 $output .= '<label for="' . $id . '">' . $title . '</label>';
49 $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
50 $output .= '</div>';
51
52 return $output;
53 }
54
55 /**
56 * Checkbox Field
57 *
58 * @param array $args Args.
59 * @return string
60 */
61 static public function checkobox_field( $args ) {
62
63 $id = $args['id'];
64 $name = $args['name'];
65 $title = $args['title'];
66 $value = $args['value'];
67
68 $output = '<div class="form-field" id="form-field-' . $id . '">';
69 $output .= '<label for="' . $id . '">';
70 $output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
71 $output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
72 $output .= $title;
73 $output .= '</label>';
74 $output .= '</div>';
75
76 return $output;
77 }
78
79 /**
80 * Select Field
81 *
82 * @since 1.1.4
83 *
84 * @param array $args Args.
85 * @return string
86 */
87 static public function select_field( $args ) {
88
89 $id = $args['id'];
90 $name = $args['name'];
91 $title = $args['title'];
92 $description = $args['description'];
93 $value = $args['value'];
94 $options = $args['options'];
95
96 $output = '<div class="form-field" id="form-field-' . $id . '">';
97
98 $output .= '<div class="form-field-label">';
99 $output .= $title;
100 $output .= '</div>';
101
102 $output .= '<div class="form-field-data">';
103 $output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
104 foreach ( $options as $option_value => $option_title ) {
105 $output .= '<option value="' . $option_value . '" ' . selected( $value, $option_value, false ) . '>' . $option_title . '</option>';
106 }
107 $output .= '</select>';
108 $output .= '</div>';
109
110 $output .= '<div class="form-field-desc">';
111 $output .= '<p>';
112 $output .= $description;
113 $output .= '</p>';
114 $output .= '</div>';
115 $output .= '</div>';
116
117 return $output;
118 }
119
120 /**
121 * Checkout Selection Field
122 *
123 * @param array $args Args.
124 * @return string
125 */
126 static public function flow_checkout_selection_field( $args ) {
127
128 $id = $args['id'];
129 $name = $args['name'];
130 $title = $args['title'];
131 $value = $args['value'];
132
133 $checkout_steps = get_posts(
134 array(
135 'posts_per_page' => -1,
136 'post_type' => CARTFLOWS_STEP_POST_TYPE,
137 'post_status' => 'publish',
138 'orderby' => 'ID',
139 'order' => 'ASC',
140 'tax_query' => array(
141 array(
142 'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
143 'field' => 'slug',
144 'terms' => 'checkout',
145 ),
146 ),
147 )
148 );
149
150 $output = '<div class="form-field" id="form-field-' . $id . '">';
151
152 $output .= '<div class="form-field-label">';
153 $output .= '<label for="' . $id . '">';
154 $output .= $title;
155 $output .= '</label>';
156 $output .= '</div>';
157
158 $output .= '<div class="form-field-data">';
159 $output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
160
161 if ( ! empty( $checkout_steps ) ) {
162 $output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
163 } else {
164
165 $output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
166 }
167
168 foreach ( $checkout_steps as $index => $step_data ) {
169
170 $output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
171 }
172
173 $output .= '</select>';
174 $output .= '</div>';
175
176 if ( '' !== $value ) {
177 $output .= '<div class="form-field-actions">';
178 $output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
179 $output .= '<span class="dashicons dashicons-edit"></span>';
180 $output .= '<span class="">Edit</span>';
181 $output .= '</a>';
182 $output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
183 $output .= '<span class="dashicons dashicons-visibility"></span>';
184 $output .= '<span class="">View</span>';
185 $output .= '</a>';
186 $output .= '</div>';
187 }
188
189 $output .= '<div class="form-field-desc">';
190 /* translators: %s: link */
191 $output .= '<p>' . sprintf( __( 'Be sure not to add any product in above selected Global Checkout step. Please read information about how to set up Global Checkout %1$shere%2$s.', 'cartflows' ), '<a href="https://cartflows.com/docs/global-checkout/" target="_blank">', '</a>' ) . '</p>';
192 $output .= '</div>';
193
194 $output .= '</div>';
195
196 return $output;
197 }
198 }
199