How to write txt file?

How does these functions relate to writing file? Do you want to write to file in general or modify functions to accomplish that? Simple approach – do it with PHP, for example with file_put_contents(). However between different hosting configurations this is not always reliable. Actually workflows in WP make real effort to not write any … Read more

how get number of twitter followers in wordpress

You would replace this: $dataOrig = file_get_contents(‘http://twitter.com/users/show/’.$twitter_user); if (is_wp_error($dataOrig)) { return ‘Error!!!’; }else{ $profile = new SimpleXMLElement ( $dataOrig ); $countOrig = $profile->followers_count; $count = strval ( $countOrig ); } With this: $dataOrig = wp_remote_get(‘http://twitter.com/users/show/’.$twitter_user); if (is_wp_error($dataOrig)) { return ‘Error!!!’; } else { $profile = new SimpleXMLElement ( $dataOrig[‘body’] ); $countOrig = $profile->followers_count; $count = … Read more

Wrapping add_query_arg with esc_url not working

And the strange part: both codes echo the same string for $url!!! No, they don’t. Look at the page source. esc_url() is encoding the & control character. You can’t do that and expect the HTTP request to work correctly. Use esc_url_raw() instead. Note the description in the Codex concerning that function: The esc_url_raw() function is … Read more

How to rewrite this file_get_contents() snippet using wp_remote_get()

So take this code: $bizt_a = json_decode(file_get_contents(“https://karteritesed.hu/biztositok.json”)); Separate it out so that we do 1 thing per line ( if you pass it straight into json_decode what happens if the request fails and that site is down? json_decode isn’t expecting an error message! It’s going to turn around and ask “What’s this?!” ) $json = … Read more