Make a plugin file writable

Hello. I have a plugin called mmenu. This plugin creates a mobile menu. This plugin requires for some of its files to writable in order to work properly. I can’t seem to figure out how to fix it since the plugin checks wp-content/plugins/mmenu. I have already changed the file permission on web/app/plugins/mmenu but it is still does not work.

Does anyone encountered this write permissions issue on Bedrock?

Bedrock sites disallow file modifications on WordPress level in the default configuration (that applies to production system):


You can add a new config/environments/production.php file and allow file modifications:
Config::define('DISALLOW_FILE_MODS', false);

I followed your suggestion but the plugin is still not working. The errors are these:

Should I change the path of the plugin?

So according to these error messages the ownership and/or permissions of the wp-content/plugins/immenu/ (and its subfolders) are indeed incorrect.

I checked out the source code of the plugin and noticed that it hardcodes the path to the plugins directory, which is different for Bedrock sites.

mmenu/php/mmenu_backend.php:starting with 1324

	/**
	 * Check if the needed files are writable.
	 */
	protected function checkWritable() {
		$dir = dirname( dirname( __FILE__ ) ) . '/';
		$str = 'wp-content/plugins/mmenu/';
		$err = array();

		foreach(
			array(
				'css/mmenu.css',
				'css/mmenu-preview.css',
				'js/mmenu.js',
				'js/mmenu-preview.js'
			) as $file
		) {
			if ( !is_writable( $dir . $file ) ) {
				$err[] = '<p>' . sprintf( __( 'The file <strong>%s</strong> is not writable, you need to chmod its permissions to at least 664.', 'mmenu' ), $str . $file ) . '</p>';
			}
		}

So what will be the correct directory for the plugins? I don’t mind modifying the plugin’s source code as long as it works.

So you would set the variable $str in function checkWritable using the plugin_dir_path function.

$str = plugin_dir_path('mmenu') . '/';

should be sufficient - not the most elegant approach but requires only minimal changes.

By the way: Judging from the code this is the only place where this path is used - and it is only used to generate an error message in the backend.
So when something doesn’t work on the frontend, there are still other hardcoded paths lingering around.

Thanks for the help. Yes. you are right. That function only checks the permission. The menu still does not work. I continue digging and check what the problem really is.

Check out the developer console, it should log what CSS/JS files fail to load in frontend.

This topic was automatically closed after 42 days. New replies are no longer allowed.