<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WP Engineer &#187; WordPress Plugins</title>
	<atom:link href="http://wpengineer.com/category/wordpress-plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Mon, 21 May 2012 22:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Register Settings on WordPress Multisite</title>
		<link>http://wpengineer.com/2324/register-settings-on-wordpress-multisite/</link>
		<comments>http://wpengineer.com/2324/register-settings-on-wordpress-multisite/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 07:08:59 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2324</guid>
		<description><![CDATA[The use of WordPress for several blogs in the network can be useful to simplify several steps and is becoming increasingly popular. Whether you want the classical scenarios of blog hosting service or like to create multilingual websites or other ideas. Therefore, it is also important for plugin developers to use the functions and to [...]]]></description>
			<content:encoded><![CDATA[<p>The use of WordPress for several blogs in the network can be useful to simplify several steps and is becoming increasingly popular. Whether you want the classical scenarios of blog hosting service or like to create multilingual websites or other ideas. Therefore, it is also important for plugin developers to use the functions and to expand or develop their own Plugins for it specifically.</p>
<p>Much is the same, but not all, and in this small article I would like to briefly explain how you set settings in the database when you activate a Plugin. <span id="more-2324"></span> </p>
<p>The best case for this is a Function of WordPress, which is triggered when activating a plugin <code>register_activation_hook()</code>. This Function will be called in init or constructor of the Plugin. In the called Function are the functions to store the settings of WordPress in the table options - <code>add_option()</code>. In Multisite there is also a function for it - <code>add_site_option()</code>.</p>
<p>Now you have to separate, if the Plugin is activated within the Network, in the management of Multisite installation, or if it is only used in one of the blogs in the network or a single installation. There are currently no functions, but a value that is passed. The following example illustrates it:</p>
<pre>
register_activation_hook( __FILE__, &#039;fb_add_config&#039; );
function fb_add_config() {

	$data = array(
		&#039;active&#039; =&gt; 0,
		&#039;radio&#039;  =&gt; 0,
		&#039;link&#039;   =&gt; 1,
		&#039;theme&#039;  =&gt; 1,
		&#039;role&#039;   =&gt; &#039;administrator&#039;,
		&#039;unit&#039;   =&gt; 1,
	);
	// if is active in network of multisite
	if ( is_multisite() &amp;&amp; isset($_GET&#091;&#039;networkwide&#039;&#093;) &amp;&amp; 1 == $_GET&#091;&#039;networkwide&#039;&#093; ) {
		add_site_option( &#039;my_settings_id&#039;, $data );
	} else {
		add_option( &#039;my_settings_id&#039;, $data );
	}
}
</pre>
<p>The query of the value in the global <code>GET</code> can be integrated in the long time ago <a href="http://wpengineer.com/2221/wordpress-multisite-plugins-and-activation/">mentioned solution for Multisite</a> and settings.</p>
<p>To solve other queries in a Multisite environment and to remove the setup or integrate menus in the admin area, the function <code>is_plugin_active_for_network()</code> is useful.</p>
<pre>
if ( is_multisite() &amp;&amp; is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
	$values = get_site_option( &#039;my_settings_id&#039; );
else
	$values = get_option( &#039;my_settings_id&#039; );
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2324/register-settings-on-wordpress-multisite/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easier Plugin Development by Moving Plugin Directory</title>
		<link>http://wpengineer.com/2374/easier-plugin-development-by-moving-plugin-directory/</link>
		<comments>http://wpengineer.com/2374/easier-plugin-development-by-moving-plugin-directory/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 07:07:50 +0000</pubDate>
		<dc:creator>Latz</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2374</guid>
		<description><![CDATA[If you're a experienced programmer you're testing your programs not only with the latest version of WordPress but also with some older versions since there are many dated installations. So you have several versions installed on your development server and want to test your newly created code with every single version. You could copy your [...]]]></description>
			<content:encoded><![CDATA[<p>If you're a experienced programmer you're testing your programs not only with the latest version of WordPress but also with some older versions since there are <a title="WordPress Infographic" href="http://hackertarget.com/wordpress-infographic/">many dated installations</a>. So you have several versions installed on your development server and want to test your newly created code with every single version.<br />
<span id="more-2374"></span><br />
You could copy your plugin files to all installed version's plugin directory manually every time you change the code... but you're a programmer, so this is no option, is it?<br />
If your dev server works under a *nix system you probably have tried to use symbolic links but it didn't work. This is not a bug of WordPress but <a href="https://bugs.php.net/bug.php?id=46260">of PHP</a>. So this does not work either.</p>
<p>Fortunately WordPress defines two constants which can help you to simplify things nonetheless: <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>. These constants point to the plugin directory of the respective WordPress installation. They are defined since WordPress 2.6 and supporting older versions is most likely unnecessary<br />
.<br />
To make your plugins accessible to all your installed WordPress versions you simply move them to a central directory and define the constants accordingly:</p>
<pre lang="php">
define( &#039;WP_PLUGIN_DIR&#039;, &#039;/var/www/plugins&#039; ); // or with XAMPP C:/xampp/htdocs/plugins
define( &#039;WP_PLUGIN_URL&#039;, &#039;http://localhost/plugins&#039; );
</pre>
<p>In this example the plugins reside in the directory 'plugins' in the root directory of the webserver. If you now define the above constants in every WordPress installation you have easy access to them to test your code with every version. </p>
<p>(Thanks to <a href="http://profiles.wordpress.org/users/johnbillion">John Blackbourn</a> on the <a href="http://lists.automattic.com/mailman/listinfo/wp-hackers">wp-hackers</a> list for having the idea.)</p>
<h4>Hint for Multisite-Users</h4>
<p>Also usable for WordPress Multisite</p>
<pre lang="php">
define( &#039;WPMU_PLUGIN_DIR&#039;, &#039;/var/www/multisite-plugins&#039; );
define( &#039;WPMU_PLUGIN_URL&#039;, &#039;http://localhost/multisite-plugins&#039; );
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2374/easier-plugin-development-by-moving-plugin-directory/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Restrict Mime Types on WordPress Media Upload</title>
		<link>http://wpengineer.com/2369/restrict-mime-types-on-wordpress-media-upload/</link>
		<comments>http://wpengineer.com/2369/restrict-mime-types-on-wordpress-media-upload/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 07:05:00 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[mediathek]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2369</guid>
		<description><![CDATA[WordPress has changed the library in version 3.3 - which I think is an improvement. The restrictions in terms of file types remains and you can control them via hook. So you can limit or extend the file-types. Via two hooks, this is done quickly and there is a notification displayed in your backend which [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has changed the library in version 3.3  - which I think is an improvement. The restrictions in terms of file types remains and you can control them via hook. So you can limit or extend the file-types. Via two hooks, this is done quickly and there is a notification displayed in your backend which lists the allowed file types.</p>
<p><span id="more-2369"></span><br />
<a href="http://wpengineer.com/wp-content/uploads/restrict-mime-type.png"><img src="http://wpengineer.com/wp-content/uploads/restrict-mime-type-300x187.png" alt="Screenshot Example for restrive the mime type" title="restrict-mime-type" width="300" height="187" class="aligncenter size-medium wp-image-2370" /></a></p>
<p>The following small Plugin may extend to different roles or authorization objects, so that you can upload, depending on the role, different types of files in the system - <a href="http://wpengineer.com/?s=current_user_can"><code>current_user_can()</code></a>.</p>
<p>Anyone interested in the currently allowed types, you can return the array of the first function or look into the function <code>get_allowed_mime_types()</code> in <code>wp-includes/functions.php</code>.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/restrict-mime-type-hint.png"><img src="http://wpengineer.com/wp-content/uploads/restrict-mime-type-hint-300x65.png" alt="Screenshot for Hint about allowed Mime Types" title="restrict-mime-type-hint" width="300" height="65" class="aligncenter size-medium wp-image-2371" /></a></p>
<pre>
&lt;?php
/**
 * Plugin Name: Restrict mime types
 * Plugin URI:  http://wpengineer.com/?p=2369
 * Description: Restrict list of allowed mime types and file extensions.
 * Version:     1.0.0
 * License:     GPLv3
 * Author:      Frank B&uuml;ltge
 * Author URI:  http://bueltge.de/
 */

 // This file is not called from WordPress. We don&#039;t like that.
! defined( &#039;ABSPATH&#039; ) and exit;

// If the function exists this file is called as upload_mimes.
// We don&#039;t do anything then.
if ( ! function_exists( &#039;fb_restrict_mime_types&#039; ) ) {

	add_filter( &#039;upload_mimes&#039;, &#039;fb_restrict_mime_types&#039; );
	/**
	 * Retrun allowed mime types
	 *
	 * @see     function get_allowed_mime_types in wp-includes/functions.php
	 * @param   array Array of mime types
	 * @return  array Array of mime types keyed by the file extension regex corresponding to those types.
	 */
	function fb_restrict_mime_types( $mime_types ) {

		$mime_types = array(
			&#039;pdf&#039; =&gt; &#039;application/pdf&#039;,
			&#039;doc|docx&#039; =&gt; &#039;application/msword&#039;,
		);

		return $mime_types;
	}
}

// If the function exists this file is called as post-upload-ui.
// We don&#039;t do anything then.
if ( ! function_exists( &#039;fb_restrict_mime_types_hint&#039; ) ) {
	// add to wp
	add_action( &#039;post-upload-ui&#039;, &#039;fb_restrict_mime_types_hint&#039; );
	/**
	 * Get an Hint about the allowed mime types
	 *
	 * @return  void
	 */
	function fb_restrict_mime_types_hint() {

		echo &#039;&lt;br /&gt;&#039;;
		_e( &#039;Accepted MIME types: PDF, DOC/DOCX&#039; );
	}
}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2369/restrict-mime-types-on-wordpress-media-upload/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Advent Calendar- How to disable comments for WordPress pages in any theme</title>
		<link>http://wpengineer.com/2302/how-to-disable-comments-for-wordpress-pages-in-any-theme/</link>
		<comments>http://wpengineer.com/2302/how-to-disable-comments-for-wordpress-pages-in-any-theme/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 07:10:30 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2302</guid>
		<description><![CDATA[Usually you don’t need comments on pages. Unfortunately, WordPress doesn’t offer a separate option to leave comments on posts on and turn them off for pages. If your theme calls comments_template(); in its page.php and you don’t want to break automatic updates, you cannot just remove the function call, because it will be overwritten with [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-2010-021-300x200.jpg" alt="" width="300" height="200" class="alignleft size-medium wp-image-2305" />Usually you don’t need comments on pages. Unfortunately, WordPress doesn’t offer a <em>separate</em> option to leave comments on posts on and turn them off for pages. If your theme calls <code>comments_template();</code> in its <code>page.php</code> and you don’t want to break automatic updates, you cannot just remove the function call, because it will be overwritten with the next update.</p>
<p>No problem. There’s an hook for that. It’s a filter called … wait for it … <code>comments_template</code>. We can change the path to the comments template here – if haven’t figured that out already. Let’s build a small plugin.</p>
<p>So, what do we do? We hook into <code>comments_template();</code> and change the path. Our new path should point to an existing file without any HTML output. In this case, we use just our plugin file, because we <em>know</em> it exists and we control the output.</p>
<p>As you may have noticed our plugin file is included two times: First as a plugin, later as a replacement for <code>comments.php</code>. The <code>function_exists()</code> check prevents any <em>You cannot redeclare …</em> errors.</p>
<p>Putting this all together …</p>
<pre>
&lt;?php # -*- coding: utf-8 -*-
/**
Plugin Name: Disable Comments On Pages
Version:     1.0
Author:      Thomas Scholz
Author URI:  http://toscho.de
License:     GPL
*/
// This file is not called from WordPress. We don&#039;t like that.
! defined( &#039;ABSPATH&#039; ) and exit;

// If the function exists this file is called as comments template.
// We don&#039;t do anything then.
if ( ! function_exists( &#039;t5_disable_comments_on_pages&#039; ) ) {
	/**
	 * Replaces the path of the original comments template with this
	 * file&#039;s path on pages.
	 *
	 * @param  string $file Original comments template file path.
	 * @return string
	 */
	function t5_disable_comments_on_pages( $file ) {
		return is_page() ? __FILE__ : $file;
	}

	add_filter( &#039;comments_template&#039;, &#039;t5_disable_comments_on_pages&#039;, 11 );
}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2302/how-to-disable-comments-for-wordpress-pages-in-any-theme/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Plugin to Remove Comments Completely from WordPress</title>
		<link>http://wpengineer.com/2230/removing-comments-absolutely-wordpress/</link>
		<comments>http://wpengineer.com/2230/removing-comments-absolutely-wordpress/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 09:03:05 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2230</guid>
		<description><![CDATA[The comment feature in WordPress is an essential component of blogs - but not in all cases it's needed, especially if you use it as a traditional CMS. Sure, you can just leave out the comment form while you creating a theme and disable the comment options in your backend. But this is not the [...]]]></description>
			<content:encoded><![CDATA[<p>The comment feature in WordPress is an essential component of blogs - but not in all cases it's needed, especially if you use it as a traditional CMS.</p>
<p>Sure, you can just leave out the comment form while you creating a theme and disable the comment options in your backend. But this is not the best way for everyone. In such a case, I turn the comments off completely, making sure that the posts can not have that option and also remove the fields for the comments in the backend. That way the user gets exactly what he needs. Meanwhile, I have needed this so often that I created a small Plugin and I'm able to immediately „switch off“ the functions and comment areas. If there are major adaptations, I create them via Plugin or use my existing Plugin <a href="http://wordpress.org/extend/plugins/adminimize/">Adminimize</a>.<br />
<span id="more-2230"></span></p>
<p>One or the other will have some ideas or know some improvements for the Plugin - go to <a href="https://github.com/bueltge/Remove-Comments-Absolute">github</a> and fork it or improve it, I would like to hear some feedback.<br />
In the following screenshot I marked a few areas that are gone now. In the content editor of posts, pages or other post types the Metaboxes for comments, discussion and trackbacks are gone. More screenshots, what else is gone can be seen <a href="https://github.com/bueltge/Remove-Comments-Absolutely">on my Repository</a>.</p>
<p><img class="aligncenter size-full wp-image-2232" title="screenshot-1" src="http://wpengineer.com/wp-content/uploads/screenshot-11.png" alt="On Dashboard without comments" width="598" height="605" /></p>
<p>Download link and links to the latest code are on github: <a href="https://github.com/bueltge/Remove-Comments-Absolutely"> Bueltge / Remove-Comments-Absolute</a>. The following code is for a quick reading and represents only the first level. Updates or maintenance will take place on GitHub.</p>
<pre>
&lt;?php
/**
 * Plugin Name: Remove Comments Absolutely
 * Plugin URI: http://bueltge.de/
 * Text Domain: remove_comments_absolute
 * Domain Path: /languages
 * Description: Deactivate comments functions and remove areas absolutely from the WordPress install
 * Author: Frank Bültge
 * Version: 0.0.2
 * Licence: GPLv2
 * Author URI: http://bueltge.de
 * Upgrade Check: none
 * Last Change: 08.06.2011
 */

if ( ! class_exists( &#039;Remove_Comments_Absolute&#039; ) ) {
	add_action( &#039;plugins_loaded&#039;, array( &#039;Remove_Comments_Absolute&#039;, &#039;get_object&#039; ) );

	class Remove_Comments_Absolute {

		static private $classobj = NULL;

		/**
		 * Constructor, init on defined hooks of WP and include second class
		 *
		 * @access  public
		 * @since   0.0.1
		 * @uses    add_filter, add_action
		 * @return  void
		 */
		public function __construct () {

			add_filter( &#039;the_posts&#039;, array( $this, &#039;set_comment_status&#039; ) );

			add_filter( &#039;comments_open&#039;, array( $this, &#039;close_comments&#039;), 10, 2 );
			add_filter( &#039;pings_open&#039;, array( $this, &#039;close_comments&#039;), 10, 2 );

			add_action( &#039;admin_init&#039;, array( $this, &#039;remove_comments&#039; ) );
			add_action( &#039;admin_menu&#039;, array( $this, &#039;remove_menu_items&#039; ) );
			add_filter( &#039;add_menu_classes&#039;, array( $this, &#039;add_menu_classes&#039; ) );

			add_action( &#039;admin_head&#039;, array( $this, &#039;remove_comments_areas&#039; ) );

			add_action( &#039;wp_before_admin_bar_render&#039;, array( $this, &#039;admin_bar_render&#039; ) );
		}

		/**
		 * Handler for the action &#039;init&#039;. Instantiates this class.
		 *
		 * @access  public
		 * @since   0.0.1
		 * @return  object $classobj
		 */
		public function get_object () {

			if ( NULL === self :: $classobj ) {
				self :: $classobj = new self;
			}

			return self :: $classobj;
		}

		/**
		 * Set the status on posts and pages - is_singular ()
		 *
		 * @access  public
		 * @since   0.0.1
		 * @uses    is_singular
		 * @param   string $posts
		 * @return  string $posts
		 */
		public function set_comment_status ( $posts ) {

			if ( ! empty( $posts ) &amp;&amp; is_singular() ) {
				$posts&#091;0&#093;-&gt;comment_status = &#039;closed&#039;;
				$posts&#091;0&#093;-&gt;post_status = &#039;closed&#039;;
			}

			return $posts;
		}

		/**
		 * Close comments, if open
		 *
		 * @access  public
		 * @since   0.0.1
		 * @param   string | boolean $open
		 * @param   string | integer $post_id
		 * @eturn  string $posts
		 */
		public function close_comments ( $open, $post_id ) {
			// if not open, than back
			if ( ! $open )
				return $open;

			$post = get_post( $post_id );
			if ( $post -&gt; post_type ) // all post types
				return FALSE;

			return $open;
		}

		/**
		 * Change options for dont use comments
		 * Remove meta boxes on edit pages
		 * Remove support on all post types for comments
		 *
		 * @access  public
		 * @since   0.0.1
		 * @uses    update_option, get_post_types, remove_meta_box, remove_post_type_support
		 * @return  void
		 */
		public function remove_comments () {
			// int values
			foreach ( array( &#039;comments_notify&#039;, &#039;default_pingback_flag&#039; ) as $option )
				update_option( $option, 0 );
			// string false
			foreach ( array( &#039;default_comment_status&#039;, &#039;default_ping_status&#039; ) as $option )
				update_option( $option, &#039;false&#039; );

			// all post types
			// alternative define an array( &#039;post&#039;, &#039;page&#039; )
			foreach ( get_post_types() as $post_type ) {
				// comment status
				remove_meta_box( &#039;commentstatusdiv&#039;, $post_type, &#039;normal&#039; );
				// remove trackbacks
				remove_meta_box( &#039;trackbacksdiv&#039;, $post_type, &#039;normal&#039; );
				// remove all comments/trackbacks from tabels
				remove_post_type_support( $post_type, &#039;comments&#039; );
				remove_post_type_support( $post_type, &#039;trackbacks&#039; );
			}
			// remove dashboard meta box for recents comments
			remove_meta_box( &#039;dashboard_recent_comments&#039;, &#039;dashboard&#039;, &#039;normal&#039; );
		}

		/**
		 * Remove menu-entries
		 *
		 * @access  public
		 * @since   0.0.2
		 * @uses    remove_meta_box, remove_post_type_support
		 * @return  void
		 */
		public function remove_menu_items () {
			// Remove menu entries with WP 3.1 and higher
			if ( function_exists( &#039;remove_menu_page&#039; ) ) {
				remove_menu_page( &#039;edit-comments.php&#039; );
				remove_submenu_page( &#039;options-general.php&#039;, &#039;options-discussion.php&#039; );
			} else {
				// unset comments
				unset( $GLOBALS&#091;&#039;menu&#039;&#093;&#091;25&#093; );
				// unset menuentry Discussion
				unset( $GLOBALS&#091;&#039;submenu&#039;&#093;&#091;&#039;options-general.php&#039;&#093;&#091;25&#093; );
			}
		}

		/**
		 * Add class for last menu entry with no 20
		 *
		 * @access  public
		 * @since   0.0.1
		 * @param   array string $menu
		 * @return  array string $menu
		 */
		function add_menu_classes ( $menu ) {

			$menu&#091;20&#093;&#091;4&#093; .= &#039; menu-top-last&#039;;

			return $menu;
		}

		/**
		 * Remove areas for comments in backend via JS
		 *
		 * @access  public
		 * @since   0.0.1
		 * $return  string with js
		 */
		public function remove_comments_areas () {
			?&gt;
			&lt;script type=&quot;text/javascript&quot;&gt;
			//&lt;!&#091;CDATA&#091;
			jQuery(document).ready( function($) {
				$( &#039;.table_discussion&#039; ).remove();
			});
			//&#093;&#093;&gt;
			&lt;/script&gt;
			&lt;?php
		}

		/**
		 * Remove comment entry in Admin Bar
		 *
		 * @access  public
		 * @since   0.0.1
		 * @uses    remove_menu
		 * $return  void
		 */
		public function admin_bar_render () {
			// remove entry in admin bar
			$GLOBALS&#091;&#039;wp_admin_bar&#039;&#093; -&gt; remove_menu( &#039;comments&#039; );
		}

	} // end class

} // end if class exists
?&gt;
</pre>
<p><img class="aligncenter size-large wp-image-2231" title="screenshot-2" src="http://wpengineer.com/wp-content/uploads/screenshot-21-1024x744.png" alt="on write post" width="1024" height="744" /><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2230/removing-comments-absolutely-wordpress/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>New Plugin to Style your Plugin on WordPress Admin with Default Styles!</title>
		<link>http://wpengineer.com/2226/new-plugin-to-style-your-plugin-on-wordpress-admin-with-default-styles/</link>
		<comments>http://wpengineer.com/2226/new-plugin-to-style-your-plugin-on-wordpress-admin-with-default-styles/#comments</comments>
		<pubDate>Tue, 31 May 2011 08:51:52 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2226</guid>
		<description><![CDATA[WordPress is developing fast - this also applies to the design of the backend. So it is important not to use your own styles in the admin area and use tags and classes of WordPress. This is the best way you can simplify your work as a developer and you don't have to test the [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress is developing fast - this also applies to the design of the backend. So it is important not to use your own styles in the admin area and use tags and classes of WordPress. This is the best way you can simplify your work as a developer and you don't have to test the design with every update. Unfortunately, there are quite extensive opportunities in the backend to implement the requirements. Several different classes and HTML structures are used. To be able to look up something this simple, I have developed a small Plugin, which tinkers in the development environment and quickly represents the necessary elements. Here you see two screenshots with the differences between version 3.1 and 3.2 of WordPress and the current contained elements of the Plugin.<br />
<span id="more-2226"></span><br />
<a href="http://wpengineer.com/wp-content/uploads/screenshot-1.png"><img src="http://wpengineer.com/wp-content/uploads/screenshot-1-201x1024.png" alt="" title="screenshot-1" width="201" height="1024" class="alignnone size-large wp-image-2227" /></a> <a href="http://wpengineer.com/wp-content/uploads/screenshot-2.png"><img src="http://wpengineer.com/wp-content/uploads/screenshot-2-204x1024.png" alt="" title="screenshot-2" width="204" height="1024" class="alignnone size-large wp-image-2228" /></a></p>
<p>You can find the Plugin in <a href="https://github.com/bueltge/WordPress-Admin-Style">Github</a> and it would be great if you expand it, add new ideas and possibilities to it: - <a href="https://github.com/bueltge/WordPress-Admin-Style">github.com/bueltge/WordPress-Admin-Style</a><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2226/new-plugin-to-style-your-plugin-on-wordpress-admin-with-default-styles/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Plugin To Add Custom Field To An Attachment In WordPress</title>
		<link>http://wpengineer.com/2076/add-custom-field-attachment-in-wordpress/</link>
		<comments>http://wpengineer.com/2076/add-custom-field-attachment-in-wordpress/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 09:30:20 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[advent]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2076</guid>
		<description><![CDATA[The media library is on WordPress in some areas, certainly not perfect, but it has great potential. Each attachment can contain various metadata and also WordPress stores some data directly while uploading - for example a part of the Exif data of an image. However, it might not be enough for you and you need [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-2010-05-300x200.jpg" alt="5 Day" title="WordPress-Christmas-2010-05" width="300" height="200" class="alignleft size-medium wp-image-2096" /><br />
The media library is on WordPress in some areas, certainly not perfect, but it has great potential. Each attachment can contain various <a href="http://wpengineer.com/126/image-metadata-in-wordpress/">metadata</a> and also WordPress stores some data directly while uploading - for example a part of the Exif data of an image.</p>
<p>However, it might not be enough for you and you need some additional custom data with the attachment, whether in order to control something in the backend of WordPress, or even display the data in the front end to the image. So here is a small tutorial how to add an additional field. You can use this solution directly and adding a new field with the help of a Plugin.<br />
<span id="more-2076"></span><br />
For the output of the data I present a simple method that can be adjusted accordingly. To read the data, which is assigned to the attachment, there are many functions provided by WordPress and enables you to realize so many amazing things - depending on knowledge and skills of the developer - such as <a href = "http://wpengineer.com/1735%20/%20shows%20easier-better-solutions-to-get-pictures-on-your-posts/">related articles</a>.</p>
<p><img src="http://wpengineer.com/wp-content/uploads/aaf-wp.png" alt="" title="aaf-wp" width="482" height="668" class="aligncenter size-full wp-image-2077" /></p>
<p>The above screenshot shows what we are aim for. An additional field with the name <em>Example Custom Field</em>, also an input field and a description below the field.</p>
<h3>Add the Custom Field</h3>
<p>First we create a function, which outputs the 3 new fields in the attachment area. These fields are getting delivered in an array and then via the according hook <code>attachment_fields_to_edit</code> integrated in WordPress.</p>
<pre>
// Add a custom field to an attachment in WordPress
function fb_attachment_fields_edit($form_fields, $post) {

	$form_fields&#091;&#039;custom_example&#039;&#093;&#091;&#039;label&#039;&#093; = __( &#039;Example Custom Field&#039;, FB_AAF_TEXTDOMAIN );
	$form_fields&#091;&#039;custom_example&#039;&#093;&#091;&#039;value&#039;&#093; = get_post_meta($post-&gt;ID, &#039;_custom_example&#039;, true);
	$form_fields&#091;&#039;custom_example&#039;&#093;&#091;&#039;helps&#039;&#093; = __( &#039;A helpful text for this field.&#039;, FB_AAF_TEXTDOMAIN );

	return $form_fields;
}
</pre>
<h3>Save the custom values</h3>
<p>Now that we have completed the data fields, we must take care about saving the values. For this case WordPress provides the hook <code>attachment_fields_to_save</code>, so that you only need to hook in the memory function.</p>
<pre>
// save custom field to post_meta
function fb_attachment_fields_save($post, $attachment) {

	if ( isset($attachment&#091;&#039;custom_example&#039;&#093;) )
		update_post_meta($post&#091;&#039;ID&#039;&#093;, &#039;_custom_example&#039;, $attachment&#091;&#039;custom_example&#039;&#093;);

	return $post;
}
</pre>
<h3>Hook to work in WordPress</h3>
<p>The two functions, explained before, providing the necessary functions and now we are going to integrate it into WordPress. Here a short explanation with the help of these two filter hooks. In both cases,  our functions passing <strong>two</strong> parameters to the hooks of WordPress and they are passed with the default value of <strong>priority 10</strong>. Everything goes through one filter in WordPress and therefore to hook on the respective <strong>Filter-Hook (<code>add_filter</code>) </strong> <code>attachment_fields_to_*</code>. The transfer via array <code>array(&#038;$this, ...</code> takes place here only because everything is used in connection within a class.</p>
<pre>
add_filter( &#039;attachment_fields_to_edit&#039;, array(&amp;$this, &#039;fb_attachment_fields_edit&#039;), 10, 2);
add_filter( &#039;attachment_fields_to_save&#039;, array(&amp;$this, &#039;fb_attachment_fields_save&#039;), 10, 2);
</pre>
<h3>The Example Plugin</h3>
<p>Now we incorporate the functions and their hooks in a Plugin and we can simple use the additional functions inside of WordPress. I think the separation of additional functions in Theme and Plugin is very important because the priority of integration is different and because from my point of view function expansions in a Theme are useful only if they are just additional functions for the Theme and not for WordPress.<br />
Also the use via class is useful, because of a cleaner code. But there are enough articles about the benefits of object-oriented programming and the usage of classes.</p>
<pre>
&lt;?php
/**
 * @package Add Attachment Fields
 * @author Frank B&uuml;ltge
 */

/*
Plugin Name: Add Attachment Fields
Plugin URI: http://bueltge.de/
Text Domain: add_attachment_fields
Domain Path: /languages
Description: Example for add a custom field to an attachment in WordPress
Author: Frank B&uuml;ltge
Version: 0.0.1
Author URI: http://bueltge.de/
Donate URI: http://bueltge.de/wunschliste/
License: GPL
Last change: 24.11.2010 10:21:19
*/ 

/**
License:
==============================================================================
Copyright 2009/2010 Frank Bueltge  (email : frank@bueltge.de)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Requirements:
==============================================================================
This plugin requires WordPress &gt;= 2.7 and tested with PHP Interpreter &gt;= 5.2.9
*/

//avoid direct calls to this file, because now WP core and framework has been used
if ( !function_exists(&#039;add_action&#039;) ) {
	header(&#039;Status: 403 Forbidden&#039;);
	header(&#039;HTTP/1.1 403 Forbidden&#039;);
	exit();
} elseif ( version_compare(phpversion(), &#039;5.0.0&#039;, &#039;&lt;&#039;) ) {
	$exit_msg = &#039;The plugin require PHP 5 or higher&#039;;
	header(&#039;Status: 403 Forbidden&#039;);
	header(&#039;HTTP/1.1 403 Forbidden&#039;);
	exit($exit_msg);
}

if ( !class_exists(&#039;add_attachment_fields&#039;) ) {

	//WordPress definitions
	if ( !defined(&#039;WP_CONTENT_URL&#039;) )
		define(&#039;WP_CONTENT_URL&#039;, get_option(&#039;siteurl&#039;) . &#039;/wp-content&#039;);
	if ( !defined(&#039;WP_CONTENT_DIR&#039;) )
		define(&#039;WP_CONTENT_DIR&#039;, ABSPATH . &#039;wp-content&#039;);
	if ( !defined(&#039;WP_PLUGIN_URL&#039;) )
		define(&#039;WP_PLUGIN_URL&#039;, WP_CONTENT_URL.&#039;/plugins&#039;);
	if ( !defined(&#039;WP_PLUGIN_DIR&#039;) )
		define(&#039;WP_PLUGIN_DIR&#039;, WP_CONTENT_DIR.&#039;/plugins&#039;);
	if ( !defined(&#039;PLUGINDIR&#039;) )
		define( &#039;PLUGINDIR&#039;, &#039;wp-content/plugins&#039; ); // Relative to ABSPATH.  For back compat.
	if ( !defined(&#039;WP_LANG_DIR&#039;) )
		define(&#039;WP_LANG_DIR&#039;, WP_CONTENT_DIR . &#039;/languages&#039;);

	// plugin definitions
	define( &#039;FB_AAF_BASENAME&#039;, plugin_basename(__FILE__) );
	define( &#039;FB_AAF_BASEDIR&#039;, dirname( plugin_basename(__FILE__) ) );
	define( &#039;FB_AAF_TEXTDOMAIN&#039;, &#039;add_attachment_fields&#039; );

	class add_attachment_fields {

		function __construct() {

			if ( !is_admin() )
				return FALSE;

			add_action( &#039;init&#039;, array(&amp;$this, &#039;text_domain&#039;) );
			add_filter( &#039;attachment_fields_to_edit&#039;, array(&amp;$this, &#039;fb_attachment_fields_edit&#039;), 10, 2);
			add_filter( &#039;attachment_fields_to_save&#039;, array(&amp;$this, &#039;fb_attachment_fields_save&#039;), 10, 2);
		}

		function text_domain() {

			load_plugin_textdomain( FB_AAF_TEXTDOMAIN, false, FB_AAF_BASEDIR . &#039;/languages&#039; );
		}

		// Add a custom field to an attachment in WordPress
		function fb_attachment_fields_edit($form_fields, $post) {

			$form_fields&#091;&#039;custom_example&#039;&#093;&#091;&#039;label&#039;&#093; = __( &#039;Example Custom Field&#039;, FB_AAF_TEXTDOMAIN );
			$form_fields&#091;&#039;custom_example&#039;&#093;&#091;&#039;value&#039;&#093; = get_post_meta($post-&gt;ID, &#039;_custom_example&#039;, true);
			$form_fields&#091;&#039;custom_example&#039;&#093;&#091;&#039;helps&#039;&#093; = __( &#039;A helpful text for this field.&#039;, FB_AAF_TEXTDOMAIN );

			return $form_fields;
		}

		// save custom field to post_meta
		function fb_attachment_fields_save($post, $attachment) {

			if ( isset($attachment&#091;&#039;custom_example&#039;&#093;) )
				update_post_meta($post&#091;&#039;ID&#039;&#093;, &#039;_custom_example&#039;, $attachment&#091;&#039;custom_example&#039;&#093;);

			return $post;
		}

	}

	function add_attachment_fields_start() {

		new add_attachment_fields();
	}

	add_action( &#039;plugins_loaded&#039;, &#039;add_attachment_fields_start&#039; );
}
?&gt;
</pre>
<h3>Example to use the values on Frontend or Plugins</h3>
<p>Additional to the Plugin, I have a small solution to output the meta data of the attachment. But I also recommend to read the previously mentioned <a href="http://wpengineer.com/1735/easier-better-solutions-to-get-pictures-on-your-posts/">article</a>, as you can get far more information there.</p>
<pre>
$attachments = get_children( array(
		&#039;post_parent&#039;    =&gt; get_the_ID(),
		&#039;post_type&#039;      =&gt; &#039;attachment&#039;,
		&#039;numberposts&#039;    =&gt; 1, // show all -1
		&#039;post_status&#039;    =&gt; &#039;inherit&#039;,
		&#039;post_mime_type&#039; =&gt; &#039;image&#039;,
		&#039;order&#039;          =&gt; &#039;ASC&#039;,
		&#039;orderby&#039;        =&gt; &#039;menu_order ASC&#039;
	) );
foreach ( $attachments as $attachment_id =&gt; $attachment ) {
	echo get_post_meta($attachment_id, &#039;_custom_example&#039;, true);
}
</pre>
<p>A practical example - photographer and its URL - has been recently posted by Thomas Scholz on <a href = "http://wordpress.stackexchange.com/questions/3097/how-can-i-add-a-url-field-to-the -attachments-window/3108 # 3108 ">WordPress Answers</a>. A nice usage for this possibility.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2076/add-custom-field-attachment-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>debugConsole with WordPress</title>
		<link>http://wpengineer.com/2068/debugconsole-with-wordpress/</link>
		<comments>http://wpengineer.com/2068/debugconsole-with-wordpress/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 10:47:42 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Debug Queries]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2068</guid>
		<description><![CDATA[For debugging inside of WordPress there are different approaches and preferences. I like xDebug and in some cases I use FirePHP. Now there is another possibility which I had to test at least once - debugConsole - I like it. The debugConsole is a tool for debugging and tracing PHP5 applications on productive servers without [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wpengineer.com/wp-content/uploads/debugconsole-backend.png"><img src="http://wpengineer.com/wp-content/uploads/debugconsole-backend-230x300.png" alt="" title="debugconsole-backend" width="230" height="300" class="alignright size-medium wp-image-2069" /></a><br />
For debugging inside of WordPress there are different approaches and preferences. I like <a href="http://www.xdebug.org/">xDebug</a> and in some cases I use <a href="http://www.firephp.org/">FirePHP</a>. Now there is another possibility which I had to test at least once - <a href="http://www.debugconsole.de/">debugConsole</a> - I like it.</p>
<blockquote><p>The debugConsole is a tool for debugging and tracing PHP5 applications on productive servers without compromising the live-traffic. </p></blockquote>
<p><span id="more-2068"></span></p>
<h4>The features</h4>
<ul>
<li>access features</li>
<li>variable inspector</li>
<li>variable watches</li>
<li>replace PHP's errorhandling</li>
<li>timer clock</li>
<li>checkpoint management</li>
<li>and other features
<ul>
<li>filter events</li>
<li>log console output into logfiles additionally to or instead of the popup</li>
<li>configure dimensions and design of console window</li>
<li>color-coded events for quicker overview</li>
</ul>
</li>
</ul>
<p>So I created a little Plugin to play and test the console.<br />
Currently I have only created a demo Plugin which shows the function. It won't be maintained, but can be downloaded here. As a small start and quick look at the possibilities I used the examples of the author of the <a href="http://www.debugconsole.de/">debugConsole</a>.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/debugconsole-frontend.png"><img src="http://wpengineer.com/wp-content/uploads/debugconsole-frontend-300x117.png" alt="" title="debugconsole-frontend" width="300" height="117" class="aligncenter size-medium wp-image-2070" /></a></p>
<p>The Plugin has the following source code and you can add to any URL of the WP-installation the string <code>?debug=true</code>, so that the popup called with the information of the console. Currently this is possible for frontend and backend.</p>
<pre>
&lt;?php
/*
Plugin Name: debugConsole
Plugin URI: http://bueltge.de/
Text Domain: debugconsole
Domain Path: /languages
Description: The &lt;a href=&quot;http://www.debugconsole.de/&quot;&gt;debugConsole&lt;/a&gt;
is a tool for debugging and tracing PHP5 applications on productive servers
without compromising the live-traffic. Add &lt;code&gt;?debug=true&lt;/code&gt; to the URL for see
the Popup-Window with debugConsole
Author: Frank B&uuml;ltge
Version: 0.1
Author URI: http://bueltge.de/
Donate URI: http://bueltge.de/wunschliste/
License: Apache License
Last change: 14.10.2010 11:30:51
*/ 

/**
License:
==============================================================================
Copyright 2010 Frank Bueltge  (email : frank@bueltge.de)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Requirements:
==============================================================================
This plugin requires WordPress &gt;= 2.7 and tested with PHP Interpreter &gt;= 5.2.9
*/

/* PHP5 required */
if (version_compare(PHP_VERSION, &#039;5.0.0&#039;) &lt; 0) {
	die(&#039;The debugConsole requires PHP 5.x.x or greater.&#039;);
}

/* load debugConsole functionality */
require_once &#039;debugconsole-1.3.0/debugConsole.php&#039;;

// add ?debug=true to the URL
if ( isset($_GET&#091;&#039;debug&#039;&#093;) &amp;&amp; $_GET&#091;&#039;debug&#039;&#093; == &#039;true&#039;) {
	add_action( &#039;wp_footer&#039;, &#039;wp_debug_console&#039; );
	add_action( &#039;admin_footer&#039;, &#039;wp_debug_console&#039; );
}

function wp_debug_console() {

	/**
	* debugConsole demonstration
	*
	* This script demonstrates each feature of the debugConsole. The
	* debugConsole is a PHP5 class using JavaScripts to show debug
	* information in a popup window. The popup has IP-based access
	* control. Configurate everything in debugConsole.config.php.
	* Additionally, PHP&#039;s default errorhandler is replaced.
	*
	* @author Andreas Demmer &lt;mail@andreas-demmer.de&gt;
	* @version 1.0.1
	* @package debugConsole_1.2.0
	*/

	/*
	Now you got an extended commandset:

	dc_watch()           watch variable changes in console
	dc_dump()            var_dump variables in console
	dc_here()            mark checkpoints in console
	dc_start_timer()     measure a timespan
	dc_stop_timer()      output timespan in console
	*/

	/* test watches */
	dc_watch(&#039;foo&#039;);

	declare (ticks = 1) {
		$foo = &#039;1&#039;;
		$foo++;

		/* test checkpoints */
		dc_here(&#039;The interpreter passed through here!&#039;);

		/* test timer clock */
		$myTimer = dc_start_timer(&#039;Measure an one second sleep:&#039;);
		sleep(1);
		dc_stop_timer($myTimer);

		/* test variable debugging */
		$bar = 42.0;
		dc_dump($bar, &#039;$bar tells us the meaning of life:&#039;);

		$foobar = array (
				&#039;foo&#039; =&gt; $foo,
				&#039;bar&#039; =&gt; $bar
		);

		dc_dump($foobar, &#039;$foobar is a neat array!&#039;);

		/* test errorhandling */
		echo $notSet;
		fopen(&#039;not existing!&#039;, &#039;r&#039;);
	}

}
?&gt;
</pre>
<p>Download as zip-file: <a href="http://wpengineer.com/wp-content/uploads/debugConsole.zip">debugConsole.zip</a> - 131 kByte<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2068/debugconsole-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How To List All Posts Of An Archive, A Category Or A Search Result</title>
		<link>http://wpengineer.com/2031/how-to-list-all-posts-of-an-archive-a-category-or-a-search-result/</link>
		<comments>http://wpengineer.com/2031/how-to-list-all-posts-of-an-archive-a-category-or-a-search-result/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 07:52:28 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2031</guid>
		<description><![CDATA[Archive pages are usually paged according to your settings in options/reading. Sometimes you may want to offer a page with all posts for an archive (time, category, search result). You need: a separate address for the unpaged archive, a filter for the internal WordPress query and a link to your ‘all posts’ page. We put [...]]]></description>
			<content:encoded><![CDATA[<p>Archive pages are usually paged according to your settings in options/reading. Sometimes you may want to offer a page with all posts for an archive (time, category, search result).</p>
<p>You need:</p>
<ul>
<li>a separate address for the unpaged archive,</li>
<li>a filter for the internal WordPress query and</li>
<li>a link to your ‘all posts’ page.</li>
</ul>
<p>We put everything into a class to avoid name collisions and to keep the global namespace clean.<br />
We name the file <code>class.View_All_Posts.php</code>.</p>
<p>Let’s start with the class, the parameter and a checker, this is easy:</p>
<pre lang="php">
class View_All_Posts
{
    /**
     * GET parameter to trigger a complete, not paged archive.
     * @var string
     */
    protected $all_param = &#039;all&#039;;

    /**
     * Are we there already?
     *
     * @return bool
     */
    public function is_all_posts()
    {
        return isset ( $_GET&#091;$this-&gt;all_param&#093; );
    }
}</pre>
<p>For the address I use a very simple approach: a GET parameter named <code>all</code>. You may change the name here; just stay with ASCII chars from a—z. <samp lang="ru">все_сообщения</samp> will get you in trouble!</p>
<p>Next we need a constructor that manages our work:</p>
<pre lang="php">
    public function __construct()
    {
        /* Register the query argument. */
        add_filter(&#039;query_vars&#039;, array ( $this, &#039;add_query_arg&#039;) );

        /* Hook into the query. */
        add_action(&#039;pre_get_posts&#039;, array ( $this, &#039;view_all_posts&#039;) );
    }</pre>
<p>The constructor references two internal functions – <code>add_query_arg()</code> and view_all_posts(), which we build next:</p>
<pre lang="php">
    /**
     * Registers the query arg in WordPress.
     * Otherwise it will be unset.
     *
     * @param  array $vars Already registered query args.
     * @return array
     */
    public function add_query_arg( array $vars )
    {
        return array_merge( $vars, array ( $this-&gt;query_arg ) );
    }

    /**
     * Alters the query to remove the paging.
     * @return void
     */
    public function view_all_posts()
    {
        if ( ! $this-&gt;is_all_posts() )
        {
            return;
        }

        $GLOBALS&#091;&#039;wp_query&#039;&#093;-&gt;query_vars&#091;&#039;nopaging&#039;&#093; = TRUE;

        return;
    }</pre>
<p>The first function just registers our GET parameter in WordPress. The second alters the query to the database and removes the paging.</p>
<p>We are almost done. A template tag for the link would be nice, wouldn’t it?</p>
<pre lang="php">
    /**
     * Creates the markup for the link.
     *
     * Usage in archive.php, category.php or search.php:
     * $GLOBALS&#091;&#039;view_all_posts&#039;&#093;-&gt;get_allposts_link();
     *
     * @param  string $text Linktext
     * @param  bool   $print echo or return
     * @return string|void
     */
    public function get_allposts_link(
        $text   = &#039;View all posts&#039;
    ,   $before = &#039;&lt;p class=&quot;allpostslink&quot;&gt;&#039;
    ,   $after  = &#039;&lt;/p&gt;;&#039;
    ,   $print  = TRUE
    )
    {
        if ( $this-&gt;is_all_posts()
         or $GLOBALS&#091;&#039;wp_query&#039;&#093;-&gt;found_posts &lt;= get_option(&#039;posts_per_page&#039;)
        )
        {   // No link needed.
            return;
        }

        if ( isset ( $_SERVER&#091;&#039;QUERY_STRING&#039;&#093; )
            &amp;&amp; ! empty ( $_SERVER&#091;&#039;QUERY_STRING&#039;&#093; )
        )
        {
            /* We have already visible GET parameters: /?hello=world. */
            $new_url = $_SERVER&#091;&#039;REQUEST_URI&#039;&#093; . &#039;&amp;&#039;;
        }
        else
        {
            /* Note the difference: REQUEST_URL doesn&#039;t include
             * the query string while REQUEST_URI does. */
            $new_url = $_SERVER&#091;&#039;REQUEST_URL&#039;&#093; . &#039;?&#039;;
        }

        $link = &quot;$before&lt;a href=&#039;$new_url$this-&gt;all_param&#039;&gt;$text&lt;/a&gt;$after&quot;;

        if ( $print )
        {
            print $link;
            return;
        }
        return $link;
    }</pre>
<p>Note: <code>$GLOBALS['wp_query']->found_posts</code> holds the sum of all posts for a given query, not just for the current page. Useful if you want to print out the total number on a paged archive.</p>
<p>If you want to avoid duplicate content, hide the full archives from search engines in your header:</p>
<pre lang="php">    /**
     * Prevents indexing from search engines.
     *
     * Add this as an action to &#039;wp_head&#039;.
     *
     * @return void
     */
    public function meta_noindex()
    {
        if ( $this-&gt;is_all_posts() )
        {
             print &#039;&lt;meta name=&quot;robots&quot; content=&quot;noindex&quot;&gt;&#039;;
        }
    }</pre>
<p>Our class is complete. Now we put an object of the class into the global namespace …</p>
<pre lang="php">$GLOBALS&#091;&#039;view_all_posts&#039;&#093; = new View_All_Posts;</pre>
<p>… add an action to <code>wp_head</code> …</p>
<pre lang="php">
add_action(
    &#039;wp_head&#039;
,   array ( $GLOBALS&#091;&#039;view_all_posts&#039;&#093;, &#039;meta_noindex&#039; )
);</pre>
<p>… and include the file into the functions.php of our theme:</p>
<pre lang="php">
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR
    . &#039;class.View_All_Posts.php&#039;;</pre>
<p>In our archive templates (archive.php, category.php, search.php) we print the link:</p>
<pre lang="php">
$GLOBALS&#091;&#039;view_all_posts&#039;&#093;-&gt;get_allposts_link();
</pre>
<p>Done.</p>
<p>…</p>
<p>Oh, wait … maybe you want to see the full code? And a download link?</p>
<p>Here’s the link: <a href="http://gist.github.com/gists/451940/download">Download class.View_All_Posts.php</a></p>
<p>The complete code:</p>
<pre lang="php">/**
 * Adds a view all posts page to any query.
 * @author Thomas Scholz http://toscho.de
 * @version 1.1
 */
class View_All_Posts
{
    /**
     * GET parameter to trigger a complete, not paged archive.
     * @var string
     */
    protected $all_param = &#039;all&#039;;

    public function __construct()
    {
        /* Register the query argument. */
        add_filter(&#039;query_vars&#039;, array ( $this, &#039;add_query_arg&#039;) );

        /* Hook into the query. */
        add_action(&#039;pre_get_posts&#039;, array ( $this, &#039;view_all_posts&#039;) );
    }

    /**
     * Registers the query arg in WordPress.
     * Otherwise it will be unset.
     *
     * @param  array $vars Already registered query args.
     * @return array
     */
    public function add_query_arg( array $vars )
    {
        return array_merge( $vars, array ( $this-&gt;query_arg ) );
    }

    /**
     * Alters the query to remove the paging.
     * @return void
     */
    public function view_all_posts()
    {
        if ( ! $this-&gt;is_all_posts() )
        {
            return;
        }

        $GLOBALS&#091;&#039;wp_query&#039;&#093;-&gt;query_vars&#091;&#039;nopaging&#039;&#093; = TRUE;

        return;
    }

    /**
     * Are we there already?
     *
     * @return bool
     */
    public function is_all_posts()
    {
        return isset ( $_GET&#091;$this-&gt;all_param&#093; );
    }

    /**
     * Creates the markup for the link.
     *
     * Usage in archive.php, category.php or search.php:
     * $GLOBALS&#091;&#039;view_all_posts&#039;&#093;-&gt;get_allposts_link();
     *
     * @param  string $text Linktext
     * @param  bool   $print echo or return
     * @return string|void
     */
    public function get_allposts_link(
        $text   = &#039;View all posts&#039;
    ,   $before = &#039;&lt;p class=&quot;allpostslink&quot;&gt;&#039;
    ,   $after  = &#039;&lt;/p&gt;&#039;
    ,   $print  = TRUE
    )
    {
        if ( $this-&gt;is_all_posts()
        or $GLOBALS&#091;&#039;wp_query&#039;&#093;-&gt;found_posts &lt;= get_option(&#039;posts_per_page&#039;)
        )
        {   // No link needed.
            return;
        }

        if ( isset ( $_SERVER&#091;&#039;QUERY_STRING&#039;&#093; )
            &amp;&amp; ! empty ( $_SERVER&#091;&#039;QUERY_STRING&#039;&#093; )
        )
        {
            /* We have already visible GET parameters: /?hello=world. */
            $new_url = $_SERVER&#091;&#039;REQUEST_URI&#039;&#093; . &#039;&amp;&#039;;
        }
        else
        {
            /* Note the difference: REQUEST_URL doesn&#039;t include
             * the query string while REQUEST_URI does. */
            $new_url = $_SERVER&#091;&#039;REQUEST_URL&#039;&#093; . &#039;?&#039;;
        }

         $link = &quot;$before&lt;a href=&#039;$new_url$this-&gt;all_param&#039;&gt;$text&lt;/a&gt;$after&quot;;

        if ( $print )
        {
            print $link;
            return;
        }
        return $link;
    }
}

$GLOBALS&#091;&#039;view_all_posts&#039;&#093; = new View_All_Posts;</pre>
<p>Mission completed. Any suggestions?</p>
<h4>Guest Post</h4>
<p><img src="http://wpengineer.com/wp-content/uploads/toscho.png" alt="Thomas Scholz" title="Thomas Scholz" width="32" height="32" class="alignleft size-full wp-image-2032" />This post is written by Thomas Scholz <a href="http://toscho.de" class="liexternal">toscho.de</a>, a good friend of us and a web designer from Halle, Germany.</p>
<p>Thank you very much from our part to Thomas.</p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2031/how-to-list-all-posts-of-an-archive-a-category-or-a-search-result/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin Development: Style Your Message Boxes</title>
		<link>http://wpengineer.com/2004/wordpress-plugin-development/</link>
		<comments>http://wpengineer.com/2004/wordpress-plugin-development/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 05:53:32 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Plugin Development]]></category>
		<category><![CDATA[WordPress Admin]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2004</guid>
		<description><![CDATA[Displaying a message to the user after he started an action belongs to a good usability. In the era of Web 2.0 applications, the user is expecting such optical signal after his actions. Also WordPress Plugin developer should give the user a result message, if necessary, provided with further information. The WordPress admin area often [...]]]></description>
			<content:encoded><![CDATA[<p>Displaying a message to the user after he started an action belongs to a good usability. In the era of Web 2.0 applications, the user is expecting such optical signal after his actions. Also WordPress Plugin developer should give the user a result message, if necessary, provided with further information.</p>
<p>The WordPress admin area often likes to show information at the top of the window. For developers, this has a great benefit: Tools for generating the error and information messages are integrated and can easily be implemented in Plugins - without any self-definitions or changes in the style sheet.</p>
<h4>Automatically generated information in WordPress</h4>
<pre lang="php">wp_safe_redirect(
  add_query_arg(
    &#039;updated&#039;,
    &#039;true&#039;,
    wp_get_referer()
  )
);
</pre>
<h4>Manual and more flexible solution to output a message box</h4>
<pre lang="php">&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;
  &lt;p&gt;
    Output
  &lt;/p&gt;
&lt;/div&gt;</pre>
<h4>Colorful: The availability of CSS classes</h4>
<p>Messages within an application have to communicate different informations. For this purpose WordPress has numerous stylesheet classes available, which suits best to the message.</p>
<pre lang="php">&lt;div id=&quot;message&quot; class=&quot;updated&quot;&gt;...&lt;/div&gt;</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/wordpress-messages_updated.png" alt="" title="wordpress-messages_updated" width="474" height="200" class="aligncenter size-full wp-image-2009" /></p>
<pre lang="php">&lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;...&lt;/div&gt;</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/wordpress-messages_error.png" alt="" title="wordpress-messages_error" width="474" height="200" class="aligncenter size-full wp-image-2007" /></p>
<pre lang="php">&lt;div id=&quot;message&quot; class=&quot;updated highlight&quot;&gt;...&lt;/div&gt;</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/wordpress-messages_highlight.png" alt="" title="wordpress-messages_highlight" width="474" height="200" class="aligncenter size-full wp-image-2008" /></p>
<pre lang="php">&lt;div id=&quot;message&quot; class=&quot;updated below-h2&quot;&gt;...&lt;/div&gt;</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/wordpress-messages_below.png" alt="" title="wordpress-messages_below" width="474" height="200" class="aligncenter size-full wp-image-2006" /></p>
<h4>Recommendation</h4>
<p>Don't use your own format. A common and familiar message box provides trust and increases the potential of perception.</p>
<h4>Guest Post</h4>
<p><img src="http://wpengineer.com/wp-content/uploads/sergej_mueller.jpg" alt="" title="sergej_mueller" width="64" height="64" class="alignleft size-full wp-image-2005" />This post is written by Sergej Müller <a href="http://wpseo.org">wpseo.org</a>, who created the popular WordPress Plugin to optimize your SEO.</p>
<p>Thank you very much from our part to Sergej.</p>
<p>If you also like to have your interesting post published on our website, please let us know on our contact page. Of course we will appreciate your contribution! </p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2004/wordpress-plugin-development/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

