Adding columns to core tables

Two Problems Problem #1 – You shouldn’t ever change the default schema that ships with WordPress. This schema might change in the future (entire tables could be dropped and re-built in an update). Problem #2 – You shouldn’t really be creating new tables in the first place. If you create a new table with your … Read more

Loading Modernizr (or other JavaScript libraries) for use in a plugin

wp_enqueue_script() utilizes the WP_Scripts class, which extends the WP_Dependencies class. If you checkout that class, you will see a bunch of arrays at the top. So you could actually loop through list of queued scripts like so: global $wp_scripts; // If inside a function foreach($wp_scripts->queue as $script) { // Do some tomfoolery here… 😉 } … Read more

How to pull user/author profile data in a plugin?

If you’re trying to get user data for the displayed profile, you can do it like so: $thisauthor = get_userdata(intval($author)); That’ll return an object filled with everything you need. For instance, if you need the user ID, you can call it like so: $thisauthor->ID I use this extensively on the profiles on my site: http://androidandme.com/user/clark … Read more

Plugin uninstall function is not working

register_deactivation_hook() is launched when a plugin is deactivated. For plugin uninstall, there is register_uninstall_hook(). WordPress plugins can also have a file called uninstall.php that is ran whenever the plugin is uninstalled. To prevent the uninstall.php file from being triggered directly, the state of a constant called WP_UNINSTALL_PLUGIN should be checked before launching the codes for … Read more

Silently register plugin pages

The mighty Codex holds the answers: If you’re running into the »You do not have sufficient permissions to access this page.« message in a wp_die() screen, then you’ve hooked too early. The hook you should use is admin_menu. $parent_slug: Use NULL or set to options.php if you want to create a page that doesn’t appear … Read more

Can’t find where to modify attrbitutes

If you can’t edit your header.php, or would prefer not to, most decent WordPress themes should have (and certainly any that pass theme review to be in the official repository) <html <?php language_attributes();?> > in the opening html tag in the header.php template. There is a filter in the language_attributes() function that allows plugins/child themes … Read more

wordpress is adding a second backslash when I use addslashes

In your code json_encode() function causes to add second backslash on the following line. $data = json_encode($item_data); Add the following code in place of above code so it will replace double backslashes with single backslash in data returned by json_encode function. $data = str_replace(“\\\'”,”\\'”,json_encode($item_data )); Visit following links for more information on json_encode function. json_encode … Read more