Fixing Problems

Even though we start simply, potentially, a number of things could go wrong. If you're having problems, delete what you have and start over and follow our previous directions carefully. If you still have problems, this section covers some common issues and gives you solutions that you can try to fix them.

White screen of nothingness

A common problem when doing plugin development is making a change and finding that every attempt to load the site in your browser window results in a blank white screen. A code error is breaking WordPress when it tries to run your plugin code.

A quick way to fix this is to rename your /wp-content/plugins/example-do-nothing plugin directory on your Web server to something like /wp-content/plugins/old.example-do-nothing. This causes automatic deactivation of the plugin because WordPress won't be able to locate it.

Before changing the name back, go to the Plugins page in your Dashboard. A message at the top of the page states The plugin example-do-nothing/init.php has been deactivated due to an error: Plugin file does not exist.

This confirms that WordPress fully deactivated the broken plugin; you should be able to load your Web site successfully without seeing the dreaded white screen of nothingness. After this, you can change the filename back, fix your problem, and try again. If the plugin is still broken, WordPress prevents the plugin from activating and gives you details about the error.

Unexpected output error

When you activate a plugin in your Dashboard and see an error message on the Plugins page about unexpected output, it means that you have code or text within the main plugin PHP file that is outside of a <?php ?> code block. We cover PHP programming in Book II, Chapter 3 and explain that every PHP function must start with a command that tells your Web server to initiate (or start) PHP. If your plugin file is missing the <?php line, an error about unexpected output occurs and WordPress doesn't activate your plugin.

If your plugin activates, have some fun and try to create this error so you will know it when you see it. Intentionally create the error by following these steps:

  1. Connect to your Web server via FTP.
  2. Browse to the /wp-content/plugins/example-do-nothing directory.
  3. Open the init.php file in your text editor.
  4. Remove the <?php line from the top of the init.php file.
  5. Save the init.php file.
  6. Upload the file to the /wp-content/plugins/example-do-nothing directory.

When you try to activate the Example: Do Nothing plugin, the following message displays at the top of the Plugins page: /* Plugin Name: Example: Do Nothing Description: This plugin does nothing. It is an example of how to create a valid WordPress plugin. */.

WordPress also displays an error message on the Plugins page (see Figure 5-2), directly beneath the Plugins header: The plugin generated 138 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

All this fuss because of a missing <?php line.

Figure 5-2: Unexpected output error message displayed on the Plugins page.

image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.216.174