Remove absolute directory from function that writes custom css
-
Hi Alek,
I’m using a custom WordPress directory (bedrock) for the plugins and I’m getting and error when trying to update the Archive Calendar css due a problem with the absolute path (file arw-editor.php):
function arcw_write_css($file, $css)
{
global $wpdb;
if ($css) {
if (isMU()) {
$old_blog = $wpdb->blogid;
$blogids = $wpdb->get_results(“SELECT blog_id FROM $wpdb->blogs”);
foreach ($blogids as $blogid) {
$blog_id = $blogid->blog_id;
switch_to_blog($blog_id);$filename = ‘../wp-content/plugins/’ . dirname(plugin_basename(__FILE__)) . ‘/themes/’ . $file . ‘-‘ . $wpdb->blogid . ‘.css’;
$themefile = fopen($filename, “w”) or die(“Unable to open file!”);
fwrite($themefile, $css);
fclose($themefile);
}
switch_to_blog($old_blog);
} else {$filename = ‘../wp-content/plugins/’ . dirname(plugin_basename(__FILE__)) . ‘/themes/’ . $file . ‘.css’;
$themefile = fopen($filename, “w”) or die(“Unable to open file!”);
fwrite($themefile, $css);
fclose($themefile);
}
}
}This is the fix:
function arcw_write_css($file, $css)
{
global $wpdb;
if ($css) {
if (isMU()) {
$old_blog = $wpdb->blogid;
$blogids = $wpdb->get_results(“SELECT blog_id FROM $wpdb->blogs”);
foreach ($blogids as $blogid) {
$blog_id = $blogid->blog_id;
switch_to_blog($blog_id);$filename = plugin_dir_path( __FILE__ ) . ‘/themes/’ . $file . ‘-‘ . $wpdb->blogid . ‘.css’;
$themefile = fopen($filename, “w”) or die(“Unable to open file!”);
fwrite($themefile, $css);
fclose($themefile);
}
switch_to_blog($old_blog);
} else {$filename = plugin_dir_path( __FILE__ ) . ‘/themes/’ . $file . ‘.css’;
$themefile = fopen($filename, “w”) or die(“Unable to open file!”);
fwrite($themefile, $css);
fclose($themefile);
}
}
}Not sure how to report properly this in WordPress or if you have a git repo to do a pull request. Would you mind fixing this in the next version?
Thanks!
The topic ‘Remove absolute directory from function that writes custom css’ is closed to new replies.