• Resolved herculesnetwork

    (@herculesnetwork)


    I have a file of autoimport.php

    
        $identif = (string)$numbz;
        $myembed = (string)$feed_item->embed;
        $feed_item->desc .= "{$identif}{$myembed}<br>{$feed_item->desc}";
    $post = array(
            'post_author'     => '1',
            'post_status'     => $_POST['status'],
            'post_type'       => $cpt,
            'post_title'      => (string)$feed_item->title,
            'post_content'    => (string)$feed_item->desc,
            );
        $post_id = wp_insert_post( $post );
        update_post_meta($post_id, 'sponsor',  (string)$_POST['thelink']);
        update_post_meta($post_id, 'contID',  (string)$feed_item->id);
    

    There are two variables that I add in post_content in the publish action, always right with manual posting, but when the plugin uses another file to do the import of the post, to trigger the post, this variable $myembed does not enter at all in post_content. Why does it happen? I make the change in the two files, all right in the manual post. Importmanual.php has a code almost the same as above, with difference that use post_args:

    
    $post_args = array(
              'post_author'     => '1',
              'post_status'     => $status,
              'post_type'       => $tca,
              'post_title'      => (string)$ivd['title'],
              'post_content'    => (string)$ivd['desc'],
            );
    
    $post_id = wp_insert_post( $post_args );
    

    And the names of the variables are other, but I copy and paste, there is no writing error. Include the idea is so correct that the code works and the $identif variable comes together perfectly, what could it be?

    Thanks

Viewing 15 replies - 1 through 15 (of 17 total)
  • Thread Starter herculesnetwork

    (@herculesnetwork)

    see them complete: manual post file and auto post file Within the documents search for: ‘hercules’ and you will see the explanation before the code. Thanks.

    Moderator bcworkz

    (@bcworkz)

    Hello my friend!

    It would be hard to say without understanding the autoimport process. I wasn’t able to access the files you posted because the file sharing site wanted too much personal information to log in. Consider sharing code via pastebin.com, which allows access without login.

    It seems the problem is focused on how $feed_item->embed is assigned a value… or not. The snippets you first posted look OK, so the problem would be earlier in the process. Sorry I wasn’t able to access your files.

    Thread Starter herculesnetwork

    (@herculesnetwork)

    Hi my Friend BCWorkZ 🙂 sorry Sorry for the error of posting the link on wrong platform, direct link only for user premium 4sha…… I learned this one with you! Pastebin !! I did not know this until I created an account instead of guest user, This is going to be very useful for me. 🙂

    https://pastebin.com/s9Xcibd6

    Thanks again 🙂

    Thread Starter herculesnetwork

    (@herculesnetwork)

    This is puzzling me a lot! Because it is a simple concatenation of variables within the variable (string)$feed_item->embed; that goes to post_content,(string)$feed_item->desc, it’s all a lot like the manual import file, which work well with my change.

       I also found, that the only wrong thing that could be happening, is the variable string)$feed_item->embed; is still empty! But the next step of the script is to get the values of this variable that seems empty, and put it in two custom fields later! Or she was doing before the creation of the post! $post = array (… Then it looks like the output is after creation, get the value of the post content, and enter the value with update post! I do not know how to do this 🙁 Now I find it strange the other file / script does not need this.

    Moderator bcworkz

    (@bcworkz)

    FYI, you can update a post with wp_insert_post() by simply providing the post ID as part of the data array, and otherwise only supplying the data that should be updated. Any field not supplied will stay the same. I don’t think that will help though, something else is at play.

    I’m assuming $feed_item->embed is supposed to be the embedded player HTML for the video. My best guess is the embed code is there, but it’s not displaying in the post for some other reason. Have you tried looking at the post’s HTML source when the post is up in your browser? What you could do for testing purposes is run $feed_item->embed through htmlentities() so the embed code is visible as plain text. This would render the embedded player inoperative, but you could easily see if anything is coming through or not, and exactly what it is.
    $myembed = htmlentities( (string)$feed_item->embed );

    Once you’re sure the data is coming through, you can remove the htmlentities() and move on to why the player does not work. It shouldn’t make a difference in operation, but the embed code ought to separated from other content. Once it does work properly it’ll look better.
    $feed_item->desc = "ID: {$identif}<br>\n{$myembed}<br>\n{$feed_item->desc}";

    If there really is no data, then it never existed in the JSON sent to the server, but then it would not be in the other post meta either. If the embed is being saved in post meta, the only logical explanation is it is there in post content, but not displayed — which htmlentities() will correct.

    There is an illogical explanation too. Some other filter code could be stripping out certain HTML from post content, such as video embed code. I can think of no logical reason for this, but it’s possible. Converting to HTML entities will bypass anything like this since the data is no longer functioning embed code. If you see the embed code with htmlentities(), but it disappears from source view without it, then there is some other code stripping certain HTML.

    Thread Starter herculesnetwork

    (@herculesnetwork)

    Okay, Thhhaannnksss I’m going to see this right now, and I have to wait an hour to see if I did what you said, because the cron is fired every hour, lolkkkk I’m going to reduce these cron options. 🙂

    And yes, it is working, embed appears in the post_content, but not in custom_fields, it appears on the site, because it is in the custom field code and that other url_embed seems, they appear on the site, it works even without making any modifications in the plugin, But I need this code, in post_content, Not enough it looks on the site, I need it in post_content, because I do several things in it as it ta in post_content, my power over is much bigger about several things that I need, this guy who Made the plugin, it puts in the custom field, which forces me to use a theme of it, which I have, but I do not like it, I do not use it, and this custom_field has several locks, when embed is in post_content, it is inside Of the wordpress, the content is really mine, not the theme, or the plugin, I am the owner of it.
    And BCWorkZ, when I do manual posting, this embedcode goes straight into post_content, but when I leave cron, that other file runs. It does not fall into the body of the original wordpress fields. I hate buying those products that do not use the original wordpress fields, and make several locks in their custom fields. This very expensive plugin cost me, to block things out of me. But I moved on several things in it, I let it well gift me the way 😉 but this little thing, I have not done yet, that is to make these values ​​not only stay in the custom fields of the plugin and yes in wordpress post_content, imagine if this face discontinues Plugin, and it supports? As it has happened in the past with me, it is always best to use native wordpress fields.

    Thread Starter herculesnetwork

    (@herculesnetwork)

    I made it:

    
    $myembed = htmlentities( (string)$my_item->embed );
            $my_item->desc = "ID: <h2>{$my_item->title}</h2><br>\n{$myembed}<br>\n{$my_item->desc}";
    
     $post = array(
              'post_content' =>  $my_item->desc,
             );
              wp_insert_post($post_id);
    

    Output on website posts:

    ID: <h2>come here inside funny videos</h2><br> <iframe src="//embed.thesitesource.com/?id=1579371&bgcolor=000000" frameborder="0" width="640" height="360" scrolling="no"></iframe><br>

    Obviously with all the strange characters, he got wrapped up in the site / posts rsrsr
    I came very close because the embed was really for the post_content :-), it was in post_content, only that it appeared in the site as a code and not as a player, and still got those crazy codes both in the post_content field and also in the website of course .
    It was twice in the site, one as a player, and just below as a code, but I’m 98% sure that the player that appeared is the player that comes from the custom_field of the plugin. That custom field that I will not even use. Alias every time I paste the embed code in post_content, it is ignored by some condition of an embed already in post_content, still good 🙂
      Where do I change?
    My code exactly like I did: https://pastebin.com/f8jFKmrg
    I’m sorry, I change the names of the variables here, not to use the plugin code. in pastebin is better.

    Thread Starter herculesnetwork

    (@herculesnetwork)

    As this attempt worked out, I sent the embed to the post content(but break the player ), I’m trying now without using htmlentities function, to variable conversion,
    I did not understand ID: there in the code! It looks like a string next to the variables !!
      Now, just missing the embed is with its characters intact for the player to work 🙂

    Moderator bcworkz

    (@bcworkz)

    The fact the iframe shows up in content with htmlentities() is proof that the rest of your code is correct as far as putting the iframe in post_content. Why the iframe fails to display without htmlentities() while part of post_content is a different story. Just like the post meta can be “locked”, post content can be altered by other code hooked into the output. Additionally, the remote site delivering content for the iframe can refuse to send content unless certain, possibly secret, parameters are in place.

    You might try using your browser’s network tool to see what information is sent out when an embedded player does work when placed by the original script from post meta. Are you able to save the embed code in your own post meta where it does not get locked? If so, try outputting your post meta value from the template so post content is not involved.

    If the original code has implemented some sort of security scheme, it could take some effort to circumvent it. Since you have control of your site and the code on it, in theory there should be a way, but it can be very difficult to work out how to do it.

    Thread Starter herculesnetwork

    (@herculesnetwork)

    I got a solution on a page of my index.php in a testing domain, where I just create index.php files and testo my codes, I wrote a solution that the entire embed destroyed by strange symbols, is fixed by symbols written correctly, <> ” & Not those strange codes quot; " srsrsrs

    Only Needed a replace 😉

    Your idea of using the htmlentities to simple test + my idea with replace solves this 🙂

      But this has to be applied in the post_content after it creates the post
    To not post the code with the author’s variables here, it follows:
    https://pastebin.com/X0T8D8qh

    And now how to call the post_content and apply on it?

    Moderator bcworkz

    (@bcworkz)

    Ah! Good plan. It appears the htmlentities() conversion gets past some security implementation. FYI, you can easily undo the conversion with html_entity_decode(). No harm in writing your own, it’s good practice.

    Update the post like this [revised version]:

    $prev = get_post( $post_id );
    $prev->post_content = $post->post_content;
    wp_insert_post( $prev );

    Edited to add:
    Be prepared for disappointment, whatever security that may have blocked it before may prevent it during update. First be sure it’s really missing — look at the HTML source for the iframe tags. The tags could still be there but the source is not delivering. That’s a different issue.

    If the iframe is completely gone, we can try inserting it through SQL methods instead of WP functions.

    • This reply was modified 7 years ago by bcworkz. Reason: revised update code
    Thread Starter herculesnetwork

    (@herculesnetwork)

    Sorry but I did not understand, I’m going to change the post to revised? where this?

    I did not know where/how to put this:

    
    $prev = get_post( $post_id );
    $prev->post_content = $post->post_content;
    wp_insert_post( $prev );
    

    I tried this in the last pastebin code:

    
    $prev = get_post( $post_id );
    $prev->post_content = $post->post_content;
    $prev->post_content = str_replace($myembeddirty, $myembedcleaner, $prev->post_content);  
    wp_insert_post( $prev );
              //hercules
    //        $post = array(
       //     'post_content' =>  $post_content,
          //  );
           // wp_insert_post($post_id);
            // hercules closed
    

    I can not change the condition of the variable $ myembed
    Because it is thanks to the feature of the htmlentities () function that the value of var $ myembed enters the post_content
    If I change the data format with html_entity_decode () the values will not be entered
    In post_content, either using html_entity_decode () or rewrite by replace, it must be after that excerpt:

    
     $post = array(
                'post_author'     => '1',
                'post_status'     => $_POST['status'],
                'post_type'       => $cpt,
                'post_title'      => (string) $plugitem->titlepost,
                'post_content'    => (string) $plugitem->description
                );
            $post_id = wp_insert_post( $post );
    

    I tried to rewrite before:

    HERE

    
    $post = array(
                'post_author'     => '1',
                'post_status'     => $_POS.....
    

    If I do rewrite before that, embed does not go into post_title
    I have to leave the formation of htmlentities () if I use the html_entity_decode () function.
    To bring back the clean embed formation, they do not enter the post_content, it would be the same as
    Do rewrite, only in a more practical and better way. But it would not work anyway before that. So I do not know if I did it right, I did this code above and I’m waiting for cron to trigger the action again.

    https://pastebin.com/KdXS4FR2

    Thread Starter herculesnetwork

    (@herculesnetwork)

    My best try:
    https://pastebin.com/2u2Wb1vQ

    :-$

    Thread Starter herculesnetwork

    (@herculesnetwork)

    I had an idea, if the plugin, make insertion of the post, only with the strange characters, we could get the post_content in a plugin out of that plugin, get the post ready, in the puplish auto, also we did several plugin firing action on I’m not sure if it will work, but I’m not sure if it will work. So would not it be better to make plugin form? Get the post_content and apply rewrite in the $ post_content variable?

    Editing: I think I just got it, we got srsr .. wait two more shots of import to confirm, I applied the rewrire in an old plugin of ours, that you helped a lot, to him get the $ data
    And apply actions of $ data [post_content], we concatenate variables in it and everything else … so I added more this action, this plugin of ours already has so many actions that you would not believe srsr

    Thaaaaanksss AGAaaaaaaaaIN!!! 🙂 😀

    Thread Starter herculesnetwork

    (@herculesnetwork)

    Yes my friend, we have finally achieved, With action inserted in our old and own external plugin, just triggered another import in another domain and everything is playing perfectly: D
       A big container full of thanks to you again 😀

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Why the value of a variable is not entering post_content on just one occasion??’ is closed to new replies.