Viewing 24 reply threads
  • Author
    Posts
    • #6369
      wdrescher
      Member

      I am not sure if this is a Piklist issue but I figured I would explain it and see if I have any help or suggestions as I am really stuck.

      I used FeedWordpress to pull an RSS feed item in and place it in a metabox inside the post. I am using a theme called “Musik” that uses Piklist and East Digital Downloads to allow music files to be bought and played in a mp3 player.

      Right now FeedWordpress sends the mp3 url to the correct field called “preview mp3” and then it publishes the post. When I go to the post it doesn’t find any mp3 url. If I hit update on the post it fixes it and the mp3 can be previewed.

      It seems that the field is not saving when it is published and only when it is updated.

      I am wondering if this is an issue with how the theme dev wrote the piklist field in or not. Any help would be much appreciated!

    • #6370
      wdrescher
      Member
      <script>
          var api = 'https://api.soundcloud.com/resolve.json?url=',
              clientid = '&client_id=<?php echo get_theme_mod( "soundcloud-clientid")?>';
          jQuery(document).ready(function(){
            var el = jQuery('._post_meta_soundcloud_trackurl');
            el.parent().append('<a class="button get_sc_id" style="margin-top:25px">Get</a>');
      
            jQuery(document).on('click', '.get_sc_id', function(){
              var url = el.val(),
                  _url = api+url+clientid,
                  that = jQuery(this);
              if(that.hasClass('disabled')) return;
              that.addClass('disabled');
              if(url == '') return;
              jQuery.ajax({
                url: _url,
                method: "GET"
              }).done(function( obj ) {
                jQuery('._post_meta_soundcloud_trackid').val(obj.id);
                that.removeClass('disabled');
              }).fail(function( jqXHR, textStatus ) {
                that.removeClass('disabled');
                alert( "Request failed: " + textStatus );
              });
            })
          });
        </script>
      
      <?php
      /*
      Title: Music Fields
      Description: this is the description
      Post Type: download
      Order: 1
      Collapse: false
      */
        piklist('field', array(
          'type' => 'select'
          ,'field' => 'music_type'
          ,'label' => esc_html__('Type','musik')
          ,'description' => esc_html__('Default is single, select bundle when this is a bundle product.','musik')
          ,'choices' => array(
            'single' => 'Single'
            ,'bundle' => 'Bundle'
          )
          ,'value' => 'single'
          ,'on_post_status' => array(
              'value' => 'lock'
            )
        ));
      
        piklist('field', array(
          'type' => 'select'
          ,'field' => 'preview_type'
          ,'label' => esc_html__('Preview','musik')
          ,'choices' => array(
            'local' => 'Local'
            ,'remote' => 'Remote'
          )
          ,'conditions' => array(
            array(
              'field' => 'music_type'
              ,'value' => 'single'
            )
          )
          ,'on_post_status' => array(
              'value' => 'lock'
            )
        ));
      
        piklist('field', array(
          'type' => 'file'
          ,'field' => 'preview'
          ,'scope' => 'post_meta'
          ,'label' => esc_html__('Preview file','musik')
          ,'description' => esc_html__('Preview audio file, you can add mp3, ogg, mp4 file(s).','musik')
          ,'conditions' => array(
            array(
              'field' => 'preview_type'
              ,'value' => 'local'
            ),
            array(
              'field' => 'music_type'
              ,'value' => 'single'
            )
          )
          ,'on_post_status' => array(
              'value' => 'lock'
            )
        ));
      
        piklist('field', array(
          'type' => 'group'
          ,'field' => 'preview_url'
          ,'label' => esc_html__('Preview file','musik')
          ,'add_more' => true
          ,'fields' => array(
            array(
              'type' => 'select'
              ,'field' => 'preview_media_type'
              ,'label' => esc_html__('Format','musik')
              ,'columns' => 2
              ,'choices' => array(
                'mp3' => 'mp3'
                ,'m4a' => 'mp4'
                ,'m4v' => 'm4v'
                ,'oga' => 'ogg'
                ,'webma' => 'webm'
              )
            )
            ,array(
              'type' => 'text'
              ,'field' => 'preview_media_url'
              ,'label' =>  esc_html__('URL','musik')
              ,'columns' => 10
            )
          )
          ,'conditions' => array(
            array(
              'field' => 'preview_type'
              ,'value' => 'remote'
            ),
            array(
              'field' => 'music_type'
              ,'value' => 'single'
            )
          )
          ,'on_post_status' => array(
            'value' => 'lock'
          )
        ));
      
        piklist('field', array(
          'type' => 'group'
          ,'label' => 'Soundcloud'
          ,'description' => esc_html__('Input the soundcloud url and click the get button','musik')
          ,'fields' => array(
            array(
              'type' => 'text'
              ,'field' => 'soundcloud_trackid'
              ,'label' => 'trackid'
              ,'columns' => 3
            )
            ,array(
              'type' => 'text'
              ,'field' => 'soundcloud_trackurl'
              ,'label' => 'url'
              ,'columns' => 7
            )
          )
        ));
      
        piklist('field', array(
          'type' => 'text'
          ,'field' => 'year'
          ,'label' => esc_html__('Publish year','musik')
          ,'attributes' => array(
            'class' => 'regular-text'
            ,'placeholder' => '2015'
          )
        ));
        piklist('field', array(
          'type' => 'text'
          ,'field' => 'time'
          ,'label' => esc_html__('Duration','musik')
          ,'attributes' => array(
            'class' => 'regular-text'
            ,'placeholder' => '00:00'
          )
        ));
        piklist('field', array(
          'type' => 'text'
          ,'field' => 'itunes'
          ,'label' => esc_html__('iTunes','musik')
          ,'attributes' => array(
            'class' => 'regular-text'
            ,'placeholder' => 'http://'
          )
        ));
        piklist('field', array(
          'type' => 'text'
          ,'field' => 'googleplay'
          ,'label' => esc_html__('Google Play','musik')
          ,'attributes' => array(
            'class' => 'regular-text'
            ,'placeholder' => 'http://'
          )
        ));
      
        piklist('field', array(
          'type' => 'group'
          ,'field' => 'links'
          ,'label' => esc_html__('Links','musik')
          ,'add_more' => true
          ,'fields' => array(
            array(
              'type' => 'text'
              ,'field' => 'link_text'
              ,'label' =>  esc_html__('Text','musik')
              ,'columns' => 4
            )
            ,array(
              'type' => 'text'
              ,'field' => 'link_url'
              ,'label' =>  esc_html__('URL','musik')
              ,'columns' => 8
              ,'attributes' => array(
                'class' => 'regular-text'
                ,'placeholder' => 'http://'
              )
            )
          )
          ,'on_post_status' => array(
            'value' => 'lock'
          )
        ));
      
        piklist('field', array(
          'type' => 'checkbox'
          ,'field' => 'hide_play'
          ,'label' => esc_html__('Hide play btn','musik')
          ,'choices' => array(
            'first' => ''
          )
          ,'on_post_status' => array(
            'value' => 'lock'
          )
        ));
      
        piklist('field', array(
          'type' => 'checkbox'
          ,'field' => 'download'
          ,'label' => esc_html__('Allow download music','musik')
          ,'description' => esc_html__('Download the preview file','musik')
          ,'choices' => array(
            'first' => ''
          )
          ,'on_post_status' => array(
            'value' => 'lock'
          )
        ));
      
        piklist('field', array(
          'type' => 'text'
          ,'field' => 'plays'
          ,'label' => esc_html__('Play count','musik')
          ,'attributes' => array(
            'class' => 'regular-text'
          )
          ,'capability' => 'administrator'
        ));
        
      ?>
      
    • #6371
      Steve
      Keymaster

      @wdrescher– Welcome to the Piklist community!

      You have preview_media_url set as a field within the group field preview_url. This is going to be very hard to set automatically.

      Suggest you either break up the group field into individual fields, or remove the line ,'field' => 'preview_url' which will do the same thing.

      Also, you can probably remove this in all your fields:

      ,'on_post_status' => array(
            'value' => 'lock'
          )
    • #6372
      wdrescher
      Member

      Steve thanks for the help on this. I removed ,'field' => 'preview_url' and replaced the original file inside the theme and it did not fix the issue.

      By the way I really do appreciate the support so far, I am at a dead end and you have been awesome in response.

      Website: http://www.optinondemand.com.php56-29.ord1-1.websitetestlink.com/

    • #6373
      Steve
      Keymaster

      What field are you trying to save the data to?

    • #6374
      wdrescher
      Member

      preview_media_url is what I use right now and the RSS Syndication plugin throws the url in there perfectly, just seems like it doesn’t stick until I hit update on the post.

    • #6375
      Steve
      Keymaster

      Before updating the post, if you look in the database, is the field filled in?

    • #6376
      wdrescher
      Member

      Yup it shows up in the database

    • #6377
      Steve
      Keymaster

      Does the value/format in the database change once you update the post?

    • #6378
      wdrescher
      Member

      Well now I feel embarrassed and happy all at once haha!

      It changed from:

      https://audioboom.com/boos/4481292-13-take-a-lovely-journey-to-westeros.mp3?source=rss&stitched=1

      to

      https://audioboom.com/boos/4481292-13-take-a-lovely-journey-to-westeros.mp3?source=rss&stitched=1

      audio/mpeg

      -So what it looks like it’s doing is adding audio/mpeg below that line with a space. I am going to try to replicate that using feedwordpress and send that to the field and see if that works. You might of just helped me over my roadblock.

    • #6379
      wdrescher
      Member

      Alright obviously if I add a “space audio/mpeg” to the end of the url that FeedWordpress sends it puts it in the field AND in the database. I only would like it to send to the database. Is there a way to append audio/mpeg to the field that it will send a couple return lines and audio/mpeg to the database? I did run a test by adding a couple return lines and then audio/mpeg inside ones that weren’t updated yet and then saved the database and it worked so I believe I am very close.

      Maybe it already does add audio/mpeg to the field and is only getting triggered upon update?

    • #6380
      Steve
      Keymaster

      You’ll have to play with it but it looks like you’re close.

    • #6383
      wdrescher
      Member

      I have tried a few things in FeedWordpress to send some line break to the PikList field and the database doesn’t render these as new lines, just renders it as code.

      Is there a way to make the output of Piklist append a couple return lines then my audio/mpeg text in to the database?

    • #6384
      Steve
      Keymaster

      So, just to be clear:

      -When FeedWP automatically saves it to the db, it’s just the FILE.
      -When you press save in the post, “audio/mpeg” gets appended to the file.

      Is that correct?

    • #6385
      Steve
      Keymaster

      Also, try removing your custom JS and see if that fixes it.

    • #6386
      wdrescher
      Member

      Alright so I noticed when looking in the DB there’s preview_media_url and enclosure below it. I was clicking on enclosure by accident and that is where I was seeing that it was appending audio/mpeg to the end of the preview media url.

      Now I found something that does change in the DB after publish. At the very end of the DB once published it adds another meta value with the same key name but does it in I believe a serialized way.

      I added some pictures of what I mean from the first preview media url to what the update adds in…

      Attachments:
      You must be logged in to view attached files.
    • #6389
      Steve
      Keymaster

      This is happening because preview_url is a GROUP field, and everything is saving WITHIN a group. Make these individual fields and everything should work fine.

    • #6390
      wdrescher
      Member

      I see so when I detach that from the group it will then correctly add the field like the screenshots I sent.

      I will have to figure out how to do that since I never touched Piklist until this project and this is another devs theme. Is it as easy as grabbing that field info and putting it after said group?

      Music.php file for reference: https://drive.google.com/file/d/0B6gTiZfhhWDDRlBPbTJmc25LZzQ/view?usp=sharing

    • #6391
      Steve
      Keymaster

      Do you need to convert old data, in those fields, or not worry about it?

      • #6392
        wdrescher
        Member

        No I have been trashing all the posts and resyndicating the feed to publish them again so they are all fresh everytime so not worried about old post meta.

      • #6393
        Steve
        Keymaster

        preview_url is a repeater field (add_more). Do you want to have multiple files per post?

    • #6394
      wdrescher
      Member

      Nope just one remote file url – essentially that field is used by the themes music player to play an mp3 (podcast) from that field

    • #6400
      Steve
      Keymaster

      Change them to this. You may have to play with the conditions, or you can remove them:

      piklist('field', array(
      	'type' => 'select'
      	,'field' => 'preview_media_type'
      	,'label' => __('Format','musik')
      	,'columns' => 2
      	,'choices' => array(
      		'mp3' => 'mp3'
      		,'m4a' => 'mp4'
      		,'m4v' => 'm4v'
      		,'oga' => 'ogg'
      		,'webma' => 'webm'
      	)
      	,'conditions' => array(
      		array(
      			'field' => 'preview_type'
      			,'value' => 'remote'
      		),
      		array(
      			'field' => 'music_type'
      			,'value' => 'single'
      		)
      	)
      ));
      
      
      
      	piklist('field', array(
      		'type' => 'text'
      		,'field' => 'preview_media_url'
      		,'label' =>  __('URL','musik')
      		,'columns' => 10
      		,'conditions' => array(
      			array(
      				'field' => 'preview_type'
      				,'value' => 'remote'
      			),
      			array(
      				'field' => 'music_type'
      				,'value' => 'single'
      			)
      		)
      	));
      
    • #6401
      wdrescher
      Member

      So I swapped the code out with that section and then noticed the published databases look the same and nothing could play. Then I updated one of the posts and watch as it added another post meta field but this time just did the url without that structure it had before. It must need that structure to read the url because it doesn’t work even if you update the post now.

    • #6403
      Steve
      Keymaster

      If it added another post meta field please check your form to see if you have two fields saving data to the same key. That would cause errors.

    • #6404
      wdrescher
      Member

      I am sorry with my phrasing – it added an entry to the database like it normally does when I hit update but this time not in the same style that the theme needs.

      Before code change: preview_media_url a:2:{s:18:"preview_media_type";a:1:{i:0;s:3:"mp3";}s:17:"preview_media_url";a:1:{i:0;s:97:"https://audioboom.com/boos/4481292-13-take-a-lovely-journey-to-westeros.mp3?source=rss&stitched=1";}}

      After code change: preview_media_url https://audioboom.com/boos/4450141-12-all-aboard-the-e3-hypetrain.mp3?source=rss&stitched=1

    • #6405
      wdrescher
      Member

      FYI

      I just tried making FeedWordpress schedule all posts as drafts. I then set up a draft to publish scheduler plugin to grab all drafts and schedule them from that post type thinking maybe it will save anything in that field correctly.

      This did not work like I was expecting and instead it only worked when hitting update like usual. I wanted to rule out FeedWordpress as the culprit, that means FeedWordpress sent the info to the fields and marked it as draft correctly just the fields never saved in that format in my previous post.

      The theme author got back to me and said this:

      There are two preview types. local media and remote url. the local media(preview field) is a ID of the media from Media Library.

      and remote url(preview_url field) is a json data eg.
      a:2:{i:0;a:2:{s:18:”preview_media_type”;s:3:”mp3″;s:17:”preview_media_url”;s:52:”http://www.jplayer.org/audio/mp3/Miaow-02-Hidden.mp3&#8243;;}i:1;a:2:{s:18:”preview_media_type”;s:3:”oga”;s:17:”preview_media_url”;s:52:”http://www.jplayer.org/audio/ogg/Miaow-02-Hidden.ogg&#8221;;}}
      Use the Feedwordpress can not save the data as json format.

Viewing 24 reply threads
  • You must be logged in to reply to this topic.