WordPress Debug Log without Deprecated Notices

You turn on WordPress debugging only to find the log full of deprecated notices that make the log difficult to parse. Bummer.

You could spend time going through each deprecated notice and updating the offending piece of code. Or you could ask WordPress to ignore these deprecated notices (at least in the short term) by doing the following;
Weiterlesen „WordPress Debug Log without Deprecated Notices“

How to debug your WordPress plugin

If you are developing a plugin on WordPress, you will need to debug your code as you go.

To enable debugging, go to your wp-config.php file.

Find the line…

define('WP_DEBUG', false);

Replace the line above with the following…

// Turns WordPress debugging on
define('WP_DEBUG', true);

// Tells WordPress to log everything to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);

// Doesn't force the PHP 'display_errors' variable to be on
define('WP_DEBUG_DISPLAY', false);

// Hides errors from being displayed on-screen
@ini_set('display_errors', 0);

Now you all warnings and errors will show up in the /wp-content/debug.log file, including WordPress warnings of deprecated functions.

You can write directly to this log from your plugin using the error_log() function.

Typically…

//output some debug string
error_log( 'this works yo' );

//output some array/object
error_log( print_r( $some_obj_or_array, 1 ) );

Kudos to this post. It has some good plugin development tips, including how to enable debugging on WordPress.

WP Plugins: How to remove a Filter

Do not use remove_filter(). It is possible it will break other hooks which can have unintended consequences. This post gives a really good alternative approach using static variables.

hakre on wordpress

Worth to know for wordpress plugin authors: Making your plugin to safely unregister or remove a hook (filter or action) is not possible with the wordpress plugin API. Why? you might ask yourself. Even the name of the remove_filter() function suggests it and the codex documentation does say so as well.

But: It does not work, because this function does not work as intended. And beyond your own hooks, it has the potential to hinder the blog from working properly as it has the potential to remove other hooks then the specified one.

Does not is not exactly right, it does, but only sometimes. That’s specifically a bummer if you write plugins yourself, because you can not safely rely on it. For example, if running your plugin makes use of PHP 5.2 or greater it works. But it does not if it’s running on PHP 4 or PHP 5 lower…

Ursprünglichen Post anzeigen 1.582 weitere Wörter

Tidy and format your PHP and meet WordPress standards on Coda and TextWrangler

If you are working in a collaborative environment, coding standards are important. When you are reading through code that you haven’t written, it helps if it follows a standard.

As I work with Automattic, the keepers of WordPress.com, I get the opportunity to work on the WordPress Platform. WordPress have their own standards that are sensible without being pedantic and are similar to the PEAR standard. The emphasis of the standard (in my opinion), is to present your code so collaboration is as easy as possible. It would prefer if you wrote code that is easier to read and understand, even if it is a little longer, than some compressed, ubersmart block of code that only you can follow.
Weiterlesen „Tidy and format your PHP and meet WordPress standards on Coda and TextWrangler“

WordPress Polls and Rating Plugin

I am developing ( not from scratch, thanks mdawaffe for the leg up! ) a plugin for polls and ratings on WordPress.org, available here. It basically uses the core code used on WordPress.com with a few extra’s necessary for that platform.

The plugin allows you to create and manage polls and ratings from within your WordPress dashboard. All polls and ratings are fully customizable. I have added the style editor to allow you to create your own custom style for a poll. You can collect unlimited votes and create unlimited polls and ratings. The ratings menu allows you to embed ratings into your pages, comments and posts, including posts on the front page.

I’ve recently added the ‚Top Rated‘ widget that will allow you to place the widget in your sidebar. This widget will show you the top rated posts, pages and comments today, this week and this month.

Fehler
Dieses Video existiert nicht

I have added a template tag so you can now add a rating where you like. Just place the following line into your theme where you want the rating to be displayed.

<?php echo polldaddy_get_rating_html(); ?>

You can also use the Polldaddy shortcodes in a text widget, similar to on WordPress.com, to embed a survey, poll and a rating into the sidebar.
Polls short code

Surveys short code

Ratings short code

More blog posts about these latest updates here and here.