The most common deprecated code issue is with roles and capabilities. Roles (user levels 1-10) were the permissions method used during the WordPress 1.x generation, and was deprecated way back with WordPress 2.0. For whatever reason, people continued to define admin as "8" instead of with a capability like "activate_plugins". There was probably some outdated "master guru" guide out there, written by some self-proclaimed "expert" (a hack, at best), which everybody then followed; it's a common problem with WordPress developers (and wanna-be developers).
Roles vs Capabilities WordPress Error:
In the WordPress debugging mode, the error shows up as:
Code:
Notice: has_cap was called with an argument that is deprecated since version 2.0!
Usage of user levels by plugins and themes is deprecated.
Use roles and capabilities instead.
in X:\...\wp-includes\functions.php on line 2722
Find Deprecated Code on Linux Server or OS X:
The quickest way to find these outdated lines of code is by running a grep on your server. If you're a Linux admin familiar with SSH usage, you probably already know how to use grep commands. If you're on a Mac, realize that OS X is essentially the same as using Linux (as OS X is based on Unix Darwin). Open the Terminal, and search the folder the same as you would do in SSH on Linux server.
Code:
grep -HnR "add_[a-zA-Z].*_page.*, [0-9]*," /folder/where/files/are/
Find Deprecated Code on Windows Server or local desktop:
If you're not an experienced Linux admin, or do not have shell access to your Linux server (a common issue on shared hosting), then you can FTP and download a local desktop copy of your website code. Edit it, then re-upload the fixed code.
On a Windows desktop (or Windows Server), you can use the freeware grepWin utility.
Once grepWin is installed
-- note that Windows reboot may be required -- right-click on the plugin's folder, and search for:
Code:
add_[a-zA-Z].*_page.*, [0-9]*,
Example of searching with grepWin:
Closings Thought / Notes
This is much easier than manually scanning thousands of lines of code. grep/grepWin is useful for locating pretty much any piece of code anywhere in the file system. And it's a tool that is available on Windows, Mac, or Linux -- both desktops and servers. Use it.
Slightly off-topic side note: the Role Scoper plugin can help with defining additional capabilities, or changing existing ones.
Downloads:
How / Where to Download the Files? You'll find the attached file downloads at the bottom of this top post. Files are provided for the convenience of our members. To get download access, simply join the forum as either a Free Member or Premium Member. We don't send spam or sell your email addresses. If you're not sure what to do with .zip or .rar files, see this help post. |