Forum Replies Created
-
AuthorPosts
-
January 18, 2018 at 4:57 am in reply to: File upload field saves ID instead of URL when reordering #8687
riotxoaParticipant0.10 Beta 2 continues repeating the same issue.
This is the wp_postmeta table content at start point (JSON export):
{"meta_id":"277612","post_id":"17832","meta_key":"section02_images","meta_value":"http:\/\/localhost:8080\/wordpress\/wp-content\/uploads\/2017\/12\/ZTE-BLADE-A6-LITE-front.jpg"}, {"meta_id":"277613","post_id":"17832","meta_key":"section02_images","meta_value":"http:\/\/localhost:8080\/wordpress\/wp-content\/uploads\/2017\/12\/ZTE-BLADE-A6-LITE-back.jpg"}, {"meta_id":"277614","post_id":"17832","meta_key":"section02_images","meta_value":"http:\/\/localhost:8080\/wordpress\/wp-content\/uploads\/2017\/12\/ZTE-BLADE-A6-LITE.jpg"}, {"meta_id":"277615","post_id":"17832","meta_key":"section02_images","meta_value":"http:\/\/localhost:8080\/wordpress\/wp-content\/uploads\/2017\/12\/ZTE-BLADE-A6-LITE-lateral.jpg"}An after reorder images doing drag’n drop:
{"meta_id":"277612","post_id":"17832","meta_key":"section02_images","meta_value":"16700"}, {"meta_id":"277613","post_id":"17832","meta_key":"section02_images","meta_value":"16699"}, {"meta_id":"277614","post_id":"17832","meta_key":"section02_images","meta_value":"16698"}, {"meta_id":"277615","post_id":"17832","meta_key":"section02_images","meta_value":"16697"}Thank you,
Ricardo
riotxoaParticipantMy last suggestion, and I’m not sure that it will work:
– Try replacing $data[‘data’][‘hide_for_template’] to $data[‘data’][‘hidefortemplate’] (remove ‘_’ characters from array slug).
– Try replacing $data[‘role’] = ‘no-role’; to return; (return void).Let me know if it works.
riotxoaParticipantI’ve found that the code in the updated tutorial works if you use $data[‘data’][‘hide_for_template’] instead of $data[‘hide_for_template’] in my_hide_for_template function.
In general, the code works using $data[‘data’][‘whatever’] structure instead of $data[‘whatever’] in that function (my_hide_for_template).
riotxoaParticipantI have the same problem with both filters, and I think I’ve found the solution (or the real problem):
- As Steve says, you must use ‘piklist_part_data’ and ‘piklist_part_add’ filters.
- In ‘function my_custom_comment_block’ the key or slug of $data can’t contain chars as ‘_’. I don’t know why, but try using $data[‘hidefortemplate’] or $data[‘HideForTemplate’] instead of $data[‘hide_for_template’] as shown in the sample code.
- When ‘piklist_part_add’ filter is applied, the callback’s first parameter ($data) is sent empty (array()). This call is done in piklist/includes/class-piklist.php file (line 693), and there you can see the call:
array_merge(apply_filters(‘piklist_part_add’, array(), $folder), self::$processed_parts[$folder][‘parts’]);
The second parameter (array()) should be $data variable. If you change it manually (NOT RECOMMENDED, I’ve done it only for TESTING!!) it works
Please, tell me if this diagnostic is correct and when you would publish an update with this correction or the real one (I suppose i could be wrong, I really don’t know Piklist as deep as a Piklist developer).
Thank you!
-
AuthorPosts