Support » Plugin: My Custom CSS PHP & ADS » Update permission problem

  • Resolved netsolution

    (@netsolution)


    Hi

    I have a problem with the recent versions / updates of MyCustom CSS

    Everytime I update the file “my_style.css” gets deleted.

    And because the webserver has no write permissions in the plugins folder, and your plugin is not using WordPress inbuilt ftp to write the file, I have to manually create a my_style.css file with permission 666 so that your plugin can write the styles to the file again.

    Do you have a solution for that?

    Best would be if you could use ftp to write the file if there is no direct access possible to write.

    Thanks

    https://wordpress.org/plugins/my-custom-css/

Viewing 15 replies - 1 through 15 (of 31 total)
  • Thread Starter netsolution

    (@netsolution)

    I think looking at

    https://codex.wordpress.org/Filesystem_API

    could solve this, esp. “The WP Filesystem API Methodology” where tests are described to see if direct file writing permission is available or not.

    Because when using the correct file writing methods from WP then if it can not write directly to file it should try FTP to write (and I have all FTP credentials in wp-config.php).

    What do you think?

    Thread Starter netsolution

    (@netsolution)

    I think you should use

    $wp_filesystem->put_contents()

    Anonymous User 357386

    (@anonymized-357386)

    ok, i’ve make some change in makecss()

    function makecss()
    {
    	// make my_style.css and write write css code!
    	$mycustomcss = mycustomcss();
    	global $wp_filesystem;
    	if (empty($wp_filesystem))
    	{
    		require_once (ABSPATH . '/wp-admin/includes/file.php');
    		WP_Filesystem();
    	}
    	$makecss = $wp_filesystem->put_contents(css_path(), "/********* Do not edit this file *********/\n/*\nMy Custom CSS - Maked by Salvatore Noschese\na.k.a. DarkWolf - http://www://darkwolf.it/\n*/\n\n".mycustomcss(), 0644);
    	return $makecss;
    }

    if i send u track version, can u test?

    Thread Starter netsolution

    (@netsolution)

    Hi

    I tested it with your function, does not seem to work.

    Can you have a look at this:

    http://ottopress.com/2011/tutorial-using-the-wp_filesystem/

    And also maybe it would be possible to inject the custom css code from the db into wordpress when the .css file is not there?

    Anonymous User 357386

    (@anonymized-357386)

    as u can see, i’ve used wp_filesystem.

    Thread Starter netsolution

    (@netsolution)

    the error when I open the page is:

    Warning: mkdir(): Permission denied in /home/xyz/public_html/wp-content/plugins/my-custom-css/my-custom-css.php on line 31

    so maybe also mkdir($dirpath, 0755, true); has to be replaced by a wp function?

    Anonymous User 357386

    (@anonymized-357386)

    can u post line 31 code block?

    Thread Starter netsolution

    (@netsolution)

    or maybe the backups should be placed in the uploads folder because that will always have write permission.

    Thread Starter netsolution

    (@netsolution)

    // Fix no backup folder
    $dirpath = plugin_dir_path(__FILE__).’_backup/’;
    if (!is_dir($dirpath))
    {
    mkdir($dirpath, 0755, true);
    }

    ===

    Line 31 is: mkdir($dirpath, 0755, true);

    Thread Starter netsolution

    (@netsolution)

    Anonymous User 357386

    (@anonymized-357386)

    Anonymous User 357386

    (@anonymized-357386)

    I’ve test in local web server, and make more test.
    A new info for me: WordPress delete plugin folder on upgrade. So, plugin try to re-create immediately thanks to some code fix, but isn’t a good way to work and isn’t compatible with backup feature.
    Cause of it, i’ve rewrite to save style and backup i,side Content folder, and now, obviously, isn’t plus delete on upgrade and also backup list is maintained.
    I’ve test more, and now release.
    Sorry for this issue…
    I hope now all can work fine (and best) 🙂

    Thread Starter netsolution

    (@netsolution)

    Hi

    Thanks for the update.

    But as stated above I think you should use the /wp-content/uploads/ folder for the css file and backups.

    Because with my server configuration (apache running as wwwrun and not the owner of the webfiles) your script can not write to /wp-content/

    Warning: filemtime(): stat failed for /home/xyz/public_html/wp-content/my_custom_css/my_style.css in /home/xyz/public_html/wp-content/plugins/my-custom-css/my-custom-css.php on line 199

    So that means it still does not work for me.

    But I think it would work if you write to /wp-content/uploads/ because WP has write permission for that directory

    Thanks

    Thread Starter netsolution

    (@netsolution)

    To be more precise:

    the folders

    /wp-content/my_custom_css

    and

    /wp-content/my_custom_css/bkk

    have been created, but there are no files in them, even when I click “save” on the my css settings page many times.

    Anonymous User 357386

    (@anonymized-357386)

    Can u check your actual permission folder in this folder?
    I’ve used wp* method… Now permission well be set correctly :/

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Update permission problem’ is closed to new replies.