jigoshop/jigoshop — pull request #708 by megawebmaster (2012-10-19 17:43:42+00:00)
Title: Dev

I've added some "magic" to create ability for plugin creators to fetch and add own hidden fields to other forms.

It's **simple** to use:

```php
$fields = array();
// Add some non-transferable fields
$fields['post_type'] = $_GET['post_type']; // You must process the field value.
// Get other fields
$fields = apply_filters('jigoshop_get_hidden_fields', $fields);
```

You can add attributes for other plugins too:

```php
// Set own fields to be ommited for templates!
$ownAttributes = array('my_attr_1');
// Add filter with our fields
add_filter('jigoshop_get_hidden_fields', function($fields) use ($ownAttributes) {
if(isset($_GET['my_attr_1']){
$fields['my_attr_1'] = $_GET['my_attr_1']; // Remember to ensure it is safe by yourself!
}
return $fields;
});
```

And just simply display them in templates:

```php
$value): ?>

```

I thought also about some action or function to display hidden fields, but I decided not to add any of that, because I think the more developer can do the better.