WordPress and its changes

Today I thought about representing data and rules from Dungeons & Dragons source books as simple and plain XML files. Why that, you probably ask. Well, I’m not quite sure myself. At first I noticed some problems during our Friday DnD sessions. For almost every silly thing, we had to consider the source books and browse through the pages. This is probably due to the large amount of books we take into account while playing.

So wouldn’t it be nice to have a database or something similar, where for example all feats would be listed with their descriptions, requirements and where they are to be found in the source books and so forth. Of course these informations should be kept in a database for things like sorting and grouping. Nevertheless there has to be the possibility to have things exchangeable. Therefore I decided to collect all (hopefully) this data and write it down in XML. Later on you (or I) just have to write an importing/exporting tool to have read or write access to the database.

In the course of these considerations I wanted to make sure, that I still have installed the syntax-highlighting plugin for posting some XML code. Therefore I opened my Plugins page and I appallingly recognized, that there was no plugin listing at all, but just the text displayPluginsAsList() For some reason my ExecPHP Plugin refused to work properly. Withing the last few days I updated my WordPress version to fix some bugs. Suddenly I thought that the upgrade could be the reason for this misbehavior. After taking a look and providing the PHP file with some debug outputs, I found the error.

The old code used the function the_author() to get all data for the current author. This is necessary for the security check, which makes sure, that the current authors level is high enough to post some PHP code. Therefore the parameter ‚login‘ was passed.

$phpexec_userdata = get_userdatabylogin(the_author('login',false));
if($phpexec_userdata->user_level >= php_exec_getuserlevel()){
	$phpexec_doeval = true;
}

But in the new WordPress version, the function the_author with parameters is deprecated. Instead of returning the authors data, only the display_name is retrieved. To make ExecPHP work again, you have to correct only one line in the source PHP:

$phpexec_userdata = get_userdatabylogin(get_the_author_login());
if($phpexec_userdata->user_level >= php_exec_getuserlevel()){
	$phpexec_doeval = true;
}

By simply replacing the_author('login',false) with get_the_author_login() you’ll correct the error. Now upload your PHP file in your plugins folder and everything should work as desired.

Kommentar verfassen

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.