can any WordPress developer help on this

wordpress

#1

Hi,

when i am checking WordPress theme code on theme check plugin https://wordpress.org/plugins/theme-check/

i am getting below warning so can any one please help me on this, I am having no clue about this :frowning:

Thanks


#2

The warning message explains what should be done:

File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.

The larger issue here I believe is that whatever functionality you’re trying to bake into your theme is most likely plugin territory.


#3

If you are trying to write to files (to create some dynamic CSS, or to save to a file some configuration or perhaps to export something to a file), especially on shared hosting, the functions fopen, fwrite, fclose shouldn’t be used, for security reasons.

Instead, as the message states, you should use WP_Filesystem, here is an easy tutorial explaining how to use it: http://ottopress.com/2011/tutorial-using-the-wp_filesystem/


#4

I am putting Mailchimp subscription newsletter option in theme and not able to find the compatible methods for fclose, curl_init and curl_exec in WP_Filesystem system.

do i have to use plugin for this and no easy option to resolve it?


#5

i am not able to find the compatible methods for fclose, curl_init and curl_exec in WP_Filesystem system.
do you know the methods for these in WP_filesystem


#6

Mailchimp subscription is better suited for a plugin. Here’s one:

Themes […] handle the overall design and layout of a website while plugins offer the ability to add new features to the WordPress installation.

See: Does My Functionality Belong in a WordPress Plugin or Theme?


#7

Thanks, I truly appreciate your help.