17 posts If you are good at something, never do it for free
  • Has referred 1+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 more
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.
2188 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+10 more
revaxarts says

Always use WordPress core function if they are avaiable!

In your case: wp_remote_get()

17 posts If you are good at something, never do it for free
  • Has referred 1+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 more
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
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 3 years
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.

2188 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+10 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');
17 posts If you are good at something, never do it for free
  • Has referred 1+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 more
brandexponents says

@revaxarts ,

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

954 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Won a Most Wanted contest
+3 more
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.

2188 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+10 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

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

What doesn’t work in ie9?

2188 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+10 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

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by