Opendir and WordPress Path

I wrote a simple function to get the contents in a folder (called templates) in my wordpress plugin, but am having problems getting the path to work (thus the function always dies). My question is: Is there a wordpress function or something that will give me the path to my plugin as required for the … Read more

C# Test if user has write access to a folder

I need to test if a user can write to a folder before actually attempting to do so. I’ve implemented the following method (in C# 2.0) that attempts to retrieve the security permissions for the folder using Directory.GetAccessControl() method. private bool hasWriteAccessToFolder(string folderPath) { try { // Attempt to get a list of security permissions … Read more

Remove ‘wp-content/themes/themename/’ from Image path

I’m currently moving an old website based on some other CMS towards a new server, with WordPress. However, the site ranks good on Google, and I’m have to keep all the link structure, including the ones from images. So, in the old CMS, the links to images were like this: http://www.domain-name.de/images/image1.jpg Right now, they are … Read more

Iterating through directories with Python

I need to iterate through the subdirectories of a given directory and search for files. If I get a file I have to open it and change the content and replace it with my own lines. I tried this: import os rootdir=”C:/Users/sid/Desktop/test” for subdir, dirs, files in os.walk(rootdir): for file in files: f=open(file,’r’) lines=f.readlines() f.close() … Read more

How to reliably open a file in the same directory as the currently running script

I used to open files that were in the same directory as the currently running Python script by simply using a command like: open(“Some file.txt”, “r”) However, I discovered that when the script was run in Windows by double-clicking it, it would try to open the file from the wrong directory. Since then I’ve used … Read more

Could not create directory. /var/www/html/wp-content/plugins/PLUGIN_NAME/

I feel that I have tried every solution online for the past few months with no solution. When I go to install a plugin on WordPress, it will not work and give me the error: Unpacking the package… Installing the plugin… Could not create directory. /var/www/html/wp-content/plugins/PLUGIN_NAME/ Plugin install failed. What annoys me is it used … Read more