Forum Replies Created

Viewing 15 posts - 1 through 15 (of 113 total)
  • Author
    Posts
  • in reply to: File/Media Field #9324
    Marcus
    Member

    Just 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

    in reply to: File/Media Field #9323
    Marcus
    Member

    Nevermind! 🙂

    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

    in reply to: File/Media Field #9322
    Marcus
    Member

    Also, 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

    in reply to: Embedding fields in a field… #7067
    Marcus
    Member

    Actually 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

    in reply to: Widgets not showing #4104
    Marcus
    Member

    Yeah, 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

    in reply to: Widgets not showing #4102
    Marcus
    Member

    I’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

    in reply to: Piklist Checker Woes. #3369
    Marcus
    Member

    Found 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

    in reply to: Piklist error on older wordpress install… #3324
    Marcus
    Member

    Fixed
    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

    in reply to: Disable dragging on add-more fields #2945
    Marcus
    Member

    Found 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

    in reply to: Disable dragging on add-more fields #2944
    Marcus
    Member

    Just 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

    in reply to: Nested groups problem #2855
    Marcus
    Member

    Hey 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

    in reply to: Woocommerce #2444
    Marcus
    Member

    Hey 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

    in reply to: Woocommerce #2438
    Marcus
    Member

    This 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

    in reply to: Kevin, Steve, how much damage am I doing? :-) #2425
    Marcus
    Member

    You 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

    in reply to: Kevin, Steve, how much damage am I doing? :-) #2421
    Marcus
    Member

    Vim, 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. LOL

    Marcus

Viewing 15 posts - 1 through 15 (of 113 total)