PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
← All changes | includes/actions/methods/abstract-modifier.php +6 -56 trunk → 3.6.6 View file →
@@ -5,9 +5,8 @@
5 5 use Jet_Form_Builder\Classes\Arrayable\Array_Tools;
6 6 use Jet_Form_Builder\Classes\Arrayable\Collection;
7 7 use Jet_Form_Builder\Classes\Tools;
8 8 use Jet_Form_Builder\Exceptions\Silence_Exception;
9 -use JFB_Modules\Media_Cleanup\Module as Media_Cleanup;
10 9
11 10 // If this file is called directly, abort.
12 11 if ( ! defined( 'WPINC' ) ) {
13 12 die;
@@ -16,16 +15,8 @@
16 15 abstract class Abstract_Modifier {
17 16
18 17 public $source_arr = array();
19 18 public $fields_map = array();
20 -
21 - /**
22 - * Targets (meta keys, property ids) of locked Media fields that no other submitted field writes to.
23 - * Anything else aimed at them, e.g. a Default Field value, must be discarded too.
24 - *
25 - * @var string[]
26 - */
27 - public $locked_targets = array();
28 19 protected $request = array();
29 20
30 21 /** @var Object_Properties_Collection */
31 22 public $properties;
@@ -55,25 +46,12 @@
55 46 * @param Abstract_Modifier $this
56 47 */
57 48 do_action( 'jet-form-builder/modifier/before-run', $this );
58 49
59 - // Media fields the current user may not change: see strip_locked_fields().
60 - $locked_fields = $this->strip_locked_fields();
61 -
62 - $written_targets = array();
63 -
64 50 foreach ( $this->request as $key => $value ) {
65 - $written_targets[] = $this->get_field_key( $key );
66 51 $this->attach_item( $key, $value );
67 52 }
68 53
69 - $this->locked_targets = array_values(
70 - array_diff(
71 - array_map( array( $this, 'get_field_key' ), array_keys( $locked_fields ) ),
72 - $written_targets
73 - )
74 - );
75 -
76 54 $this->attach_properties();
77 55 $this->do_action();
78 56
79 57 /** @var Base_Object_Property $property */
@@ -208,17 +186,16 @@
208 186 $fields_map = array_filter( $fields_map );
209 187
210 188 if ( ! $revert ) {
211 189 $this->fields_map = $fields_map;
212 - } else {
213 - $this->fields_map = array_combine(
214 - array_values( $fields_map ),
215 - array_keys( $fields_map )
216 - );
190 +
191 + return $this;
217 192 }
218 193
219 - // The request may have been set before the map (see set_request()).
220 - $this->strip_locked_fields();
194 + $this->fields_map = array_combine(
195 + array_values( $fields_map ),
196 + array_keys( $fields_map )
197 + );
221 198
222 199 return $this;
223 200 }
224 201
@@ -224,36 +201,9 @@
224 201
225 202 public function set_request( $request ): Abstract_Modifier {
226 203 $this->request = array_merge( $this->request, $request );
227 204
228 - // Done here too, not only in run() (and in set_fields_map(), for the opposite setter order):
229 - // modifiers set properties that read raw request
230 - // values (see Base_Object_Property::set_related()) while they are still preparing.
231 - $this->strip_locked_fields();
232 -
233 205 return $this;
234 - }
235 -
236 - /**
237 - * Removes Media fields the current user has no "user access" capability for from the request.
238 - *
239 - * File_Uploader only checks that capability when a file is uploaded, so a submission without
240 - * a file would otherwise still write the submitted value (an attachment ID or URL) into
241 - * whatever property the field is mapped to. Dropping the field from the request itself
242 - * covers every property (post meta, thumbnail, content, ID, user fields, ...) and every
243 - * way of reading it, leaves the stored value untouched (never emptied, so media cleanup
244 - * can't treat it as a removal) and doesn't affect other fields mapped to the same target.
245 - *
246 - * @return array Locked field names as keys.
247 - */
248 - private function strip_locked_fields(): array {
249 - $locked_fields = array_flip( Media_Cleanup::get_locked_media_field_names( $this ) );
250 -
251 - if ( ! empty( $locked_fields ) ) {
252 - $this->request = array_diff_key( $this->request, $locked_fields );
253 - }
254 -
255 - return $locked_fields;
256 206 }
257 207
258 208 /**
259 209 * Get current request array.