Hi guys! A few things (in kind of a reverse order) below:
pisandelli, sadly right now I can agree with you. I’ve been “away” for quite a long time. This plugin is a side-project for me and unfortunately I didn’t have much resources for it, specifically the forum. The small amount of time I have, I’m using for version 2, which is going to be quite stable(r), more powerfull and better written.
I’m 2/3 ready with the docs for version 1 (stuff is actually happening behind the scenes at ultimate-fields.com), but I’m focusing my time on the next version. Anyway, in the next couple of months I’ll try to be consistent here, so don’t lose hope :] Now with the actual answers:
Datastores
Ultimate Fields works with several data-stores to save the values in the database. Without going too deep, those datastores are objects that connect fields with the database. Each container uses a different datastore and the values are saved in a different place:
- The Options Page container uses a datastore that saves the data as WordPress options (in the wp_options) table.
- The Post Meta Box container uses a datastore that saves the values in the post meta (wp_postmeta) table
When the values are saved in those tables, the normal WP APIs like get_option() and get_post_meta() can be used too.
The uf() and get_uf() functions do two things:
- The main purpose is to mask get_option and get_post_meta to make it seem easier.
- The second/secondary purpose of these functions is to pre-process the values that are in the database.. For example, the image field only saves the ID of the image and that’s what you would get if you use get_option(). get_uf() retrieves that ID and after that retrieves the image from the media library.
So, there are three functions:
- uf()
- get_uf()
- get_uf_repeater()
All of them accept the same arguments, which are:
- key: That’s the key of the repeater. In both of your cases (slider and parallax) that’s right.
- type: This parameter can receive several types of values.
Possible values/value combinations for the type variable:
- Nothing: In that case the function will try to retrieve the values that are associated with the current post/page/post type.
- Post ID (intereger): In this case, no matter the post type, the function will try to retrieve the data for the post with the given ID.
- Option key (string): Tries to retrieve the value of a field that is displayed in an options page.
- [Other Type]_[ID for the other type]: This would work like term_23 in the premium version, but is not really something that matters here.
With all of the above said, now to the particular problems:
et3rnal, just add ‘options’ as the second parameter of get_uf_repeater, so it would become:
<?php
foreach( get_uf_repeater('slider', 'option') as $document_files ): extract( $document_files )
?>
<div class="testing">
<?php echo $image_side ?>
<?php echo $the_image ?>
</div>
<?php
endforeach;
?>
pisandelli, the fix is the same as the one above. What you observed though is something different:
When you changed the type of the container to Post Meta and saved the page, the values got saved for that page. After you changed the type to Options Page again, the values were not deleted. That’s because the data from the plugin is only being deleted when it’s associated to a post and the post itself gets deleted. So when you tried accessing the value from the post meta, the value was still there and being displayed. If you try the same with another page, the problem will not persist.
The conclusion is that the only messed up thing in your database is a single row in the wp_postmeta database, which compared to other plugins is basically nothing ??
As for this part:
And I forgot to add something during these tests and the plugin broke my whole site… front and backend
One of the things I don’t like in the current version is the lack of if statements here and there and that shows here. Please create a thread with the particular error so we can try to fix it. In the meantime, rename the folder of the plugin so it will get deactivated and at least the other part of the site will work.
Best regards,
Rado