PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.7.31.4
Pods – Custom Content Types and Fields v2.7.31.4
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / ui / admin / form-settings.php
pods / ui / admin Last commit date
upgrade 3 days ago widgets 3 days ago components-admin.php 3 days ago field-option.php 3 days ago form-settings.php 3 days ago form.php 3 days ago help.php 3 days ago postbox-header.php 3 days ago settings-reset.php 3 days ago settings-settings.php 3 days ago settings-tools.php 3 days ago settings.php 3 days ago setup-add.php 3 days ago setup-edit-field-fluid.php 3 days ago setup-edit-field.php 3 days ago setup-edit.php 3 days ago shortcode.php 3 days ago view.php 3 days ago
form-settings.php
200 lines
1 <?php
2 wp_enqueue_script( 'pods' );
3 wp_enqueue_style( 'pods-form' );
4
5 if ( empty( $fields ) || ! is_array( $fields ) ) {
6 $fields = $obj->pod->fields;
7 }
8
9 if ( ! isset( $duplicate ) ) {
10 $duplicate = false;
11 } else {
12 $duplicate = (boolean) $duplicate;
13 }
14
15 // unset fields
16 foreach ( $fields as $k => $field ) {
17 if ( in_array( $field['name'], array( 'created', 'modified' ), true ) ) {
18 unset( $fields[ $k ] );
19 } elseif ( false === PodsForm::permission( $field['type'], $field['name'], $field['options'], $fields, $pod, $pod->id() ) ) {
20 if ( pods_v_sanitized( 'hidden', $field['options'], false ) ) {
21 $fields[ $k ]['type'] = 'hidden';
22 } else {
23 unset( $fields[ $k ] );
24 }
25 } elseif ( ! pods_has_permissions( $field['options'] ) && pods_v_sanitized( 'hidden', $field['options'], false ) ) {
26 $fields[ $k ]['type'] = 'hidden';
27 }
28 }
29
30 $submittable_fields = $fields;
31
32 foreach ( $submittable_fields as $k => $field ) {
33 if ( pods_v_sanitized( 'readonly', $field, false ) ) {
34 unset( $submittable_fields[ $k ] );
35 }
36 }
37
38 if ( ! isset( $thank_you_alt ) ) {
39 $thank_you_alt = $thank_you;
40 }
41
42 $uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] );
43 $field_hash = wp_create_nonce( 'pods_fields_' . implode( ',', array_keys( $submittable_fields ) ) );
44
45 $uid = pods_session_id();
46
47 if ( is_user_logged_in() ) {
48 $uid = 'user_' . get_current_user_id();
49 }
50
51 $nonce = wp_create_nonce( 'pods_form_' . $pod->pod . '_' . $uid . '_' . ( $duplicate ? 0 : $pod->id() ) . '_' . $uri_hash . '_' . $field_hash );
52
53 if ( isset( $_POST['_pods_nonce'] ) ) {
54 $action = __( 'saved', 'pods' );
55
56 try {
57 $params = pods_unslash( (array) $_POST );
58 $id = $pod->api->process_form( $params, $pod, $submittable_fields, $thank_you );
59
60 $message = sprintf( __( '<strong>Success!</strong> %1$s %2$s successfully.', 'pods' ), $obj->item, $action );
61 $error = sprintf( __( '<strong>Error:</strong> %1$s %2$s successfully.', 'pods' ), $obj->item, $action );
62
63 if ( 0 < $id ) {
64 echo $obj->message( $message );
65 } else {
66 echo $obj->error( $error );
67 }
68 } catch ( Exception $e ) {
69 echo $obj->error( $e->getMessage() );
70 }
71 } elseif ( isset( $_GET['do'] ) ) {
72 $action = __( 'saved', 'pods' );
73
74 $message = sprintf( __( '<strong>Success!</strong> %1$s %2$s successfully.', 'pods' ), $obj->item, $action );
75 $error = sprintf( __( '<strong>Error:</strong> %1$s not %2$s.', 'pods' ), $obj->item, $action );
76
77 if ( 0 < $pod->id() ) {
78 echo $obj->message( $message );
79 } else {
80 echo $obj->error( $error );
81 }
82 }//end if
83
84 if ( ! isset( $label ) ) {
85 $label = __( 'Save', 'pods' );
86 }
87
88 $do = 'save';
89 ?>
90
91 <form action="" method="post" class="pods-submittable pods-form pods-form-pod-<?php echo esc_attr( $pod->pod ); ?>">
92 <div class="pods-submittable-fields">
93 <?php echo PodsForm::field( 'action', 'pods_admin', 'hidden' ); ?>
94 <?php echo PodsForm::field( 'method', 'process_form', 'hidden' ); ?>
95 <?php echo PodsForm::field( 'do', $do, 'hidden' ); ?>
96 <?php echo PodsForm::field( '_pods_nonce', $nonce, 'hidden' ); ?>
97 <?php echo PodsForm::field( '_pods_pod', $pod->pod, 'hidden' ); ?>
98 <?php echo PodsForm::field( '_pods_id', $pod->id(), 'hidden' ); ?>
99 <?php echo PodsForm::field( '_pods_uri', $uri_hash, 'hidden' ); ?>
100 <?php echo PodsForm::field( '_pods_form', implode( ',', array_keys( $submittable_fields ) ), 'hidden' ); ?>
101 <?php echo PodsForm::field( '_pods_location', $_SERVER['REQUEST_URI'], 'hidden' ); ?>
102
103 <?php
104 foreach ( $fields as $field ) {
105 if ( 'hidden' !== $field['type'] ) {
106 continue;
107 }
108
109 echo PodsForm::field(
110 'pods_field_' . $field['name'], $pod->field(
111 array(
112 'name' => $field['name'],
113 'in_form' => true,
114 )
115 ), 'hidden'
116 );
117 }
118 ?>
119 <table class="form-table pods-manage-field">
120 <?php
121 $depends_on = false;
122
123 foreach ( $fields
124
125 as $field ) {
126 if ( 'hidden' === $field['type'] ) {
127 continue;
128 }
129
130 $dep_options = PodsForm::dependencies( $field );
131 $dep_classes = $dep_options['classes'];
132 $dep_data = $dep_options['data'];
133
134 if ( ( ! empty( $depends_on ) || ! empty( $dep_classes ) ) && $depends_on != $dep_classes ) {
135 if ( ! empty( $depends_on ) ) {
136 ?>
137 </tbody>
138 <?php
139 }
140
141 if ( ! empty( $dep_classes ) ) {
142 ?>
143 <tbody class="pods-field-option-container <?php echo esc_attr( $dep_classes ); ?>" <?php PodsForm::data( $dep_data ); ?>>
144 <?php
145 }
146 }
147 ?>
148 <tr valign="top" class="pods-field-option pods-field <?php echo esc_attr( 'pods-form-ui-row-type-' . $field['type'] . ' pods-form-ui-row-name-' . PodsForm::clean( $field['name'], true ) ); ?>">
149 <th>
150 <?php echo PodsForm::label( 'pods_field_' . $field['name'], $field['label'], $field['help'], $field ); ?>
151 </th>
152 <td>
153 <?php
154 echo PodsForm::field(
155 'pods_field_' . $field['name'], $pod->field(
156 array(
157 'name' => $field['name'],
158 'in_form' => true,
159 )
160 ), $field['type'], $field, $pod, $pod->id()
161 );
162 ?>
163 <?php echo PodsForm::comment( 'pods_field_' . $field['name'], $field['description'], $field ); ?>
164 </td>
165 </tr>
166 <?php
167 if ( false !== $depends_on || ! empty( $dep_classes ) ) {
168 $depends_on = $dep_classes;
169 }
170 }//end foreach
171
172 if ( ! empty( $depends_on ) ) {
173 ?>
174 </tbody>
175 <?php
176 }
177 ?>
178 </table>
179
180 <p class="submit">
181 <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_attr( $obj->label['edit'] ); ?>">
182 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
183 </p>
184 </div>
185 </form>
186
187 <script type="text/javascript">
188 jQuery( function ( $ ) {
189 $( document ).Pods( 'validate' );
190 $( document ).Pods( 'submit' );
191 $( document ).Pods( 'dependency' );
192 $( document ).Pods( 'confirm' );
193 $( document ).Pods( 'exit_confirm' );
194 } );
195
196 var pods_admin_submit_callback = function ( id ) {
197 document.location = '<?php echo pods_slash( pods_query_arg( array( 'do' => $do ) ) ); ?>';
198 }
199 </script>
200