Forum Replies Created
-
AuthorPosts
-
MarcusMemberJust wanted to update the above code.
As I didn’t deal with the arrays properly, the code should read as follows:add_filter('piklist_part_process', function($part) { global $post; if ( $post && 'page' === $post->post_type ) { if ( 'meta-boxes' === $part['folder'] && 'products-metabox.php' === $part['part']) { $pm = get_post_meta($post->ID,'mae_products',false); $pm = $pm[0]; if (count($pm)>0) { foreach ($pm AS $k1=>$v1) { $pm1 = $v1; $tmpm = $pm1['mae_media']; $tmpm = array_values($tmpm); $pm[$k1][0]['mae_media']=$tmpm; $tmpf = $pm1['filedownloads']; $tmpf = array_values($tmpf); $pm[$k1][0]['filedownloads']=$tmpf; } update_post_meta( $post->ID, 'mae_products', $pm ); } } } return $part; });That should work properly.
Marcus
MarcusMemberNevermind! 🙂
I decided to play around with the filters and found an easy solution:
I use the filter ‘piklist_part_process’
Check if its a page thats being edited (thats where my metabox is)
Check which metabox is beind edited. (in this case products-metabox.php)
Then load the postmeta. Run through it (via foreach) find the arrays that hold the media groups, and reset the array keys.Couldn’t have been easier!
add_filter('piklist_part_process', function($part) { global $post; if ( $post && 'page' === $post->post_type ) { if ( 'meta-boxes' === $part['folder'] && 'products-metabox.php' === $part['part']) { $pm = get_post_meta($post->ID,'mae_products',false); if (count($pm)>0) { foreach ($pm AS $k1=>$v1) { $pm1 = $v1[0]; $tmpm = $pm1['mae_media']; $tmpm = array_values($tmpm); $pm[$k1][0]['mae_media']=$tmpm; $tmpf = $pm1['filedownloads']; $tmpf = array_values($tmpf); $pm[$k1][0]['filedownloads']=$tmpf; } update_post_meta( $post->ID, 'mae_products', $pm[0] ); } } } return $part; });It simply resets the array values for the media portions of that metabox thats being processed.
Problem solved. 🙂Thanks for making an incredibly powerful product, can’t believe the stuff I can do.
Marcus
MarcusMemberAlso, would there be a way for me to use one of the filters just before or after it indexes the array to make sure the array is set back to 0?
Pre-thanks
Miss you guys. 🙂
Marcus
MarcusMemberActually its more of a question on what allows it. 🙂
Since it links to a fields array, I thought it might be interesting to know if you could apply it several times, and if other fields could use it.
More curious than anything.
Marcus
MarcusMemberYeah, that should work. You’ve got the two pieces you need. widgetname.php and widgetname-form.php
Have you checked to see that in no other plugin directories you have a duplicate?
If in your theme you have piklist/parts/widgets/example.php and in one of your plugin folders you have /parts/widgets/example.php this will cause problems.Or try and give your -form file a header. Such as:
<?php
/*
Width: 500
*/
?>Just trying some ideas.
Marcus
MarcusMemberI’ve had similar problems in the past. Could you please post the header for the widget box?
Just the meta code at the top where you instantiate the widget.Thanks
Marcus
MarcusMemberFound it, solved it.
It’s a BUG with windows and localhost installs.
The __FILE__ var, doesn’t match the paths that wordpress generates when getting the list of plugins, so I changed the following in the piklist checker code from:if(is_admin()) { include_once('piklist-checker/class-piklist-checker.php'); if (!piklist_checker::check(__FILE__)) { return; } }To:
if(is_admin()) { include_once('piklist-checker/class-piklist-checker.php'); $local=(strstr(__FILE__,'\\'))?str_replace('\\', '/',__FILE__):__FILE__; if (!piklist_checker::check($local)) { return; } }Bam!:
Fixed
MarcusMemberFixed
by removing the third variable $update from the save_post function and reducing the filter call to 2, instead of 3 parameters at the head of the file.Yaay, It’s working on an old archaic system. LOL
Marcus
MarcusMemberFound a quick solution/workaround in the meantime. (From a previous post of Jason’s)
Added this to my attributes section of my piklist field:
'onfocus' => 'javascript: jQuery(this).parents(".ui-sortable:first").sortable("disable");'Works like a charm.
Thanks Jason.
Marcus
MarcusMemberJust wondering if there was ever an answer to this one, I’m also looking for some way to turn off dragging for add-mores. (long scrolling drop downs do not scroll properly if draggable is allowed)
AS searching for drag, draggable and dragging, sortable, garners nothing in the piklist folder. 🙂P.S. Does sortable do anything currently? Just wondering, as setting it to false, or true, doesn’t seem to change anything.
Thanks guys.
Marcus
MarcusMemberHey cosmocanuck.
Other than surrounding your first fields array within another array (as FIELDS arrays, need two)
I can’t see a thing wrong with your code, however I took it and tested it and sure enough, only the inside group is add-moreing. 🙂Don’t quite know whats wrong.
Marcus
MarcusMemberHey Jason. Thats awesome.
I always wondered how the two would play with each other, but like so many things, it works right out of the box.
Can I ask, did Woocommerce require anything to be added to the meta_keys, like prepending ‘wc_’ to everything?
Thanks Jason.
Marcus
MarcusMemberThis would be a great test case.
Why don’t you try it?All you need to do is set the type to product or whatever is your default woocommerce product cpt type, and tell us how it goes. 🙂
Marcus
MarcusMemberYou know what Jason, if I was still on ubuntu I’d be using vim again.
The speed was always amazing.On windows however I find sublime runs about the same. (maybe a tiny bit slower to do what I need)
But thats the price I paid moving back to winblows.Marcus
MarcusMemberVim, thats for oldtimers. <g>
Just kidding. I’m an old vim user, but I use Sublime Text 3 now.
I love the interface, and how easy it is to add my own tools to it.
It’s also got a great community. It has increased my productivity dramatically, but on this last process of 1221 variables, I couldn’t create a macro to fix, only a macro to find. LOLMarcus
-
AuthorPosts