7 posts
  • India
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Exclusive Author
  • Bought between 10 and 49 items
brandexponents says

Hey guys,

I have been working on a wordpress theme for a couple of months, that I am planning to release in a week (hopefully). I have been running my theme through the theme check plugin and I see warnings for using PHP file functions (get and put) and cURL (which i use for my twitter widget).

How seriously are they issues considered by the theme reviewers, because I think cURL is good way to access remote servers and I have to use file ops to generate my dynamic CSS . Using the WP Filesystem would make it really convoluted at this point in time. I could use the HTTP API ’s as an alternative to cURL, but WP Filesystem is sure to complicate my work.

I would like have some advise passed on by experienced theme developers and the staff here at themeforest. I have an item in the mojo themes marketplace that has been quite successful and these warnings were ignored.
2001 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
+3 more
revaxarts says

Always use WordPress core function if they are avaiable!

In your case: wp_remote_get()

7 posts
  • India
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Exclusive Author
  • Bought between 10 and 49 items
brandexponents says

Thanks I will change that function. But what about file_put_contents(). The themecheck plugin throws warnings for the use of this function ?

15 posts
  • Exclusive Author
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
o2themes says

file_put_contents() might not work for your customers it depends on their hosting configuration. if you really want to store your data in a file you have to use the Filesystem API which is more complex but recommended by wordpress. or you can use the Transients API which is more reliable in this case.

2001 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
+3 more
revaxarts says

+1

Use the Transients API for dynamic styles and cache them. Here’s the function I’m using in my plugin:
function form_css() {
    header( 'Content-Type: text/css' );
    header( 'Expires: Thu, 31 Dec 2050 23:59:59 GMT' );
    header( 'Pragma: cache' );

    if ( false === ( $css = get_transient( 'mymail_form_css' ) ) ) {
        // generate your CSS here
        set_transient( 'mymail_form_css', $css );
    }

    echo $css;
    die();
}
add two action hooks:
add_action('wp_ajax_my_css', 'form_css');
add_action('wp_ajax_nopriv_my_css', 'form_css');
and enqueue the style:
wp_register_style('my-css', admin_url('admin-ajax.php?action=my_css'));
wp_enqueue_style('my-css');
7 posts
  • India
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Exclusive Author
  • Bought between 10 and 49 items
brandexponents says

@revaxarts ,

WOW Thank you so much, worked like a charm :)

900 posts
  • Sold between 1 000 and 5 000 dollars
  • Most Wanted Bounty Winner
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Microlancer Beta Tester
  • Serbia
  • Exclusive Author
aleluja says

Always use WordPress core function if they are avaiable! In your case: wp_remote_get()
for some strange reason, on free hosting sites this gets you redirected (to their landing/404 page)

Btw, I have some issues with both cURL and file_get_contents(). After updating the file it should read it reads nothing for like 15 minutes. It doesn’t return NULL nor FALSE , just pretends it’s an empty file. I suppose it’s something with the buffer/server session but can’t find a solution.

2001 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
+3 more
revaxarts says

@revaxarts , WOW Thank you so much, worked like a charm :)

Seems like this version doesn’t work on IE9 (works on IE7 +8). I’m searching for a solution to this

1040 posts
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Exclusive Author
  • Microlancer Beta Tester
  • United States
fillerspace says

What doesn’t work in ie9?

2001 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
+3 more
revaxarts says

I don’t know why but IE9 always tries to download the file if Content-type = text/css. With text/html I can view it in the browser but the styles doesn’t get applied to the page

by
by
by
by
by
by