• Resolved marisoplete

    (@marisoplete)


    Hi there!!

    Congrats for your plugin. Is amazing, πŸ™‚

    I am writting because it seems I have problems with file permissions and I am getting this message from WP Optimize:

    “The request to write the file failed. Your WP install might not have permission to write inside the wp-content folder. Please try to add the following lines manually:”

    <?php
    
    if (!defined('ABSPATH')) die('No direct access allowed');
    
    // WP-Optimize advanced-cache.php (written by version: 3.0.13) (do not change this line, it is used for correctness checks)
    
    if (!defined('WPO_ADVANCED_CACHE')) define('WPO_ADVANCED_CACHE', true);
    
    if (is_admin()) { return; }
    
    $possible_plugin_locations = array(
    	defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR.'/wp-optimize/cache' : false,
    	defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR.'/plugins/wp-optimize/cache' : false,
    	dirname(__FILE__).'/plugins/wp-optimize/cache',
    	'/data/mywebsite.com/public/wp-content/plugins/wp-optimize/cache',
    );
    
    $plugin_location = false;
    
    foreach ($possible_plugin_locations as $possible_location) {
    	if (false !== $possible_location && @file_exists($possible_location.'/file-based-page-cache.php')) {
    		$plugin_location = $possible_location;
    		break;
    	}
    }
    
    if (!defined('WPO_CACHE_DIR')) define('WPO_CACHE_DIR', WP_CONTENT_DIR.'/wpo-cache');
    if (!defined('WPO_CACHE_CONFIG_DIR')) define('WPO_CACHE_CONFIG_DIR', WPO_CACHE_DIR.'/config');
    if (!defined('WPO_CACHE_FILES_DIR')) define('WPO_CACHE_FILES_DIR', WP_CONTENT_DIR.'/cache/wpo-cache');
    if (false !== $plugin_location) {
    	if (!defined('WPO_CACHE_EXT_DIR')) define('WPO_CACHE_EXT_DIR', $plugin_location.'/extensions');
    } else {
    	if (!defined('WPO_CACHE_EXT_DIR')) define('WPO_CACHE_EXT_DIR', '/data/mywebsite.com/public/wp-content/plugins/wp-optimize/cache/extensions');
    }
    
    if (!@file_exists(WPO_CACHE_CONFIG_DIR . '/config-mywebsite.com.php')) { return; }
    
    $GLOBALS['wpo_cache_config'] = json_decode(file_get_contents(WPO_CACHE_CONFIG_DIR . '/config-mywebsite.com.php'), true);
    
    if (empty($GLOBALS['wpo_cache_config']) || empty($GLOBALS['wpo_cache_config']['enable_page_caching'])) { return; }
    
    if (false !== $plugin_location) { include_once($plugin_location.'/file-based-page-cache.php'); }

    The problem is that I don’t know where to place this code. I’ve tried to place it in my wp-config.php but teh website breaks down.

    Please, advice.

    Kind regards,
    Marijose

    • This topic was modified 4 years, 4 months ago by marisoplete.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Marijose,

    This should go in wp-content/advanced-cache.php. If the file doesn’t exist, you should created it.

    Kind regards,
    Marc.

    PS. We’ll make that message clearer in the next release.

    Thread Starter marisoplete

    (@marisoplete)

    Hi!

    Thank you! I’m going to try this and I’ll tell you how it went.

    Regards,
    Marijose

    Hi there,
    I’m having the same problem. I use WordPress as my host. Where do I find the wp-content/advanced-cache.php file?

    Hi @themysticcat

    I use WordPress as my host.

    Do you mean wordpress.com?

    wp-content is a core folder where the plugins, themes and uploads are stored. You need FTP or similar to access it.

    Marc.

    Thanks Marc! I’m unable to get FTP since I have a chromebook :/ I can get access to the htaccess file, could I do something from there?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘File permissions & placing code issue’ is closed to new replies.