<?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; development</title>
	<atom:link href="http://wpengineer.com/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:32:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Best Practice for Multilanguage WordPress Content? New Plugin!</title>
		<link>http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/</link>
		<comments>http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 07:00:20 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[language plugin]]></category>
		<category><![CDATA[Multilanguage]]></category>
		<category><![CDATA[multilnual]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2389</guid>
		<description><![CDATA[Since the beginning of WordPress the desire to publish the content in different languages is huge. But the topic can quickly become complex, because not only the rendering of content in the form of text in different languages ​​is an issue, we also have to take care of the meta data for content, for images [...]]]></description>
			<content:encoded><![CDATA[<p>Since the beginning of WordPress the desire to publish the content in different languages is huge. But the topic can quickly become complex, because not only the rendering of content in the form of text in different languages ​​is an issue, we also have to take care of the meta data for content, for images that can be different depending on the language and the use of the admin interface in the preferred language. Thus, only a part would be covered depending on the requirements (<a href="http://wordpress.stackexchange.com/questions/1552/best-practices-for-localizing-wordpress-content">a example on StackExchange</a>) it would quickly become an project and WordPress would be just a "small" framework behind it. There are already many <a href="http://codex.wordpress.org/Multilingual_WordPress">Plugins available</a>, the different approaches - new tables in the system or separation of content for each language in a table entry to post, or other solutions.</p>
<p>All these solutions have their limitations, are inflexible and you go into a dependency that will be hard to get out and with each update of WordPress you have to check if the Plugin is still working or has any bugs with the new version. Therefore, I would suggest a solution that we use in our <a title="Inpsyde photo" href="http://inpsyde.com">Inpsyde Team</a> frequently for customers and maintained their strength in the flexibility, in extensibility and in its capacity to use the WordPress standard without changing the core or anything else. You can deactivate the Plugin at any time, you won't lose anything, your website remains the same.</p>
<p><span id="more-2389"></span><br />
<img class="aligncenter size-medium wp-image-2390" title="banner-772x250" src="http://wpengineer.com/wp-content/uploads/banner-772x250-300x97.png" alt="" width="300" height="97" /></p>
<h3>Why multilanuage?</h3>
<ul>
<li>2/3, if not even more, of the worldwide population speak another language</li>
<li>Globale Aufstellung von Unternehmen</li>
<li>Better distribution of content</li>
<li>Service for the client</li>
<li>Search Engine Optimization</li>
</ul>
<h3>The solution</h3>
<p>WordPress Multi-site provides the solution already.<br />
This makes the management of different instances, with similarities and differences, with the help of an installation possible. The exchange of data is possible via core functions, which get united and simplified via Plugin.</p>
<h3>Advantages</h3>
<ul>
<li>WordPress Core Functions</li>
<li>No dependency to Plugins</li>
<li>Independent to WordPress development*</li>
<li>Control Themes, Plugins at a central place, use them decentralized</li>
<li>Low maintenance</li>
<li>Seperating languages in Backend/Frontend (user dependent)</li>
<li>Complete mirrored or in every content form seperated</li>
<li>Subdomains or Subdirectories</li>
<li>de.example.com, example.com/de</li>
<li>Seperate Domains via Domainmapping</li>
<li>example.de, example.com</li>
<li>Free in development in design and usability</li>
<li>Optimization not only on frontend, also lang-attributes, SEO</li>
</ul>
<h3>Plugin</h3>
<p>With all these requirements and benefits, we use a base that is available as a Plugin in the official repository of WordPress: <a href="http://wordpress.org/extend/plugins/multilingual-press/"> Multilingual Press </a>. The plugin provides several convenient tools to use Multisite for the implementation of multilingualism.</p>
<p>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/banner-772x250/' title='banner-772x250'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/banner-772x250-150x150.png" class="attachment-thumbnail" alt="banner-772x250" title="banner-772x250" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-1-3/' title='screenshot-1'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-12-150x150.png" class="attachment-thumbnail" alt="screenshot-1" title="screenshot-1" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-2-3/' title='screenshot-2'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-22-150x150.png" class="attachment-thumbnail" alt="screenshot-2" title="screenshot-2" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-3/' title='screenshot-3'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-3-150x150.png" class="attachment-thumbnail" alt="screenshot-3" title="screenshot-3" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-4/' title='screenshot-4'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-4-150x150.png" class="attachment-thumbnail" alt="screenshot-4" title="screenshot-4" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/wordpress-christmas-2010-24-2/' title='WordPress-Christmas-2010-24'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-2010-241-150x150.jpg" class="attachment-thumbnail" alt="WordPress-Christmas-2010-24" title="WordPress-Christmas-2010-24" /></a>
</p>
<p>This plugin simplifies the identification of different blogs in the network to a language and linking to other blogs, so that when you publish the content in blog A, it will create a post as draft in blog B. Thus, the articles are in relation, the system knows this and with the help of some functions, it may be used in the frontend and backend.<br />
The Plugin provides in the article or page the ability to see a meta box with the content of the linked data, in the simplest case as a translation aid. Similarly, there is a widget that simplifies the frontend to change. In each blog you can be make ​​some adjustments, assigning a flag and language.</p>
<h3>An outlook</h3>
<p>We are in the midst of the development, which adds the extra help. For example a dashboard widget with the overview of article and all links, an extension of the mediathek to seperate global content across all blogs and independent content per blog. Similarly, there are helpers for updating existing installations. In addition there is the possibility to directly load the language in the backend, without the need of FTP/SSH and assign the languages accordingly​​. We will also add the function to copy existing blogs with all the content and options if you want to.</p>
<h3>Summary</h3>
<p>WordPress Multisite provides the basis and with some adjustments, a clean, controlled solution exists for the use of WordPress in a multilingual environment. Now it's up to you - use Multisite, Test the Plugin and give us a feedback, preferable on <a href="https://github.com/inpsyde/multilingual-press">our repo on Github</a>.</h3>
<p>.</p>
<p>This was our last door of our Advent Calendar. We hope you enjoyed it! </p>
<p>We wish you a Merry Christmas and thanks a lot for reading our posts!<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/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Separate Logic From Output</title>
		<link>http://wpengineer.com/2355/separate-logic-from-output/</link>
		<comments>http://wpengineer.com/2355/separate-logic-from-output/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 06:58:57 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2355</guid>
		<description><![CDATA[Once HTML is defined within a function for output, the HTML will be separated from the logic! In this case the function is defined twice. A function contains only logic and values ​​are returned only as return. The second function will contain HTML, test logic, loops or hooks and outputs values ​​as echo. Ok, the [...]]]></description>
			<content:encoded><![CDATA[<p>Once HTML is defined within a function for output, the HTML will be separated from the logic! In this case the function is defined twice. A function contains only logic and values ​​are returned only as return. The second function will contain HTML, test logic, loops or hooks and outputs values ​​as echo. Ok, the smart asses will say <a href="http://de.wikipedia.org/wiki/Model_View_Controller">MVC</a>, yeah you right, but WordPress does not pursue a Consistent MVC pattern!</p>
<p><span id="more-2355"></span></p>
<h4>Why WordPress doesn't follow MVC pattern consistently?</h4>
<p>If we have a close look on WordPress, we can detect an MVC pattern. By separating the Themes (view) from the core (model) it gives the impression WordPress pursues an MVC pattern. But this patternn is found only in the frontend. Let's take a closer look and we see that there is no such logic for the admin area. So, the view for the admin area has to be anchored somewhere in the core. We can also notice that in the core itself are lose SQL queries within PHP. Well, a general separation of view and logic is not equal MVC. An MVC-Pattern is principally composed of a sort of object-oriented programming paradigm, in WordPress, these can also be found occasionally, but we find much more procedural than object-oriented programming paradigms. Conclusion WordPress itself does not pursue a MVC pattern, but it is quite possible MVC principles, as we used in the following.</p>
<pre>
function get_some_foo() {
	$my_foo = &#039;This is Foo!&#039;;
	return $my_foo;
}

function some_foo() {
	$foo = get_some_foo();
	echo $foo;
}
</pre>
<p>Why is this useful? We want the function <code>some_foo()</code> returns a predefined output. In another template we want to change the default behavior of the function <code>some_foo()</code>. In order to effectively reflect both requirements, two functions are defined. The first function consists only the elementary logic and is only returned as return values​​, it is always preceded by a <code>get_...</code>. The second function includes predefined information, which in turn can be HTML, test logic, loops, or a hook.</p>
<pre>
function get_some_foo() {
	$foo_bar_array = array( &#039;Foo&#039;, &#039;Bar&#039;, &#039;FooBar&#039;, &#039;BarFoo&#039; );
	$foo_bar_array = apply_filters( &#039;some_foo_array&#039;, $foo_bar_array );

	return $foo_bar_array ;
}

function some_foo() {
    $foo_list = &#039;&lt;ul&gt;&#039;; 

    foreach( get_some_foo() as $foo_key =&gt; $foo_value ){
		$foo_list .= &#039;&lt;li&gt;&#039; . $foo_value . &#039;&lt;/li&gt;&#039;;
    }

    $foo_list .= &#039;&lt;/ul&gt;&#039;;

    echo apply_filters( &#039;some_foo&#039;, $foo_list );
}
</pre>
<p>In the previous example in each of the two functions with the function <a href="http://codex.wordpress.org/Function_Reference/apply_filter"> <code>apply_filters()</code></a> the possibility will be created, to change returned values later as you desired. A manipulation can take place via the so-defined hooks <code>some_foo_array</code> or <code>some_foo</code>. Here is an example of how a possible manipulation can look with the two defined hooks.</p>
<p>In the next code example, we change an array <code>$foo_bar_array</code> and the HTML output. This involves the two hooks <code>some_foo_array</code> and <code>some_foo</code>, which were set with <code>apply_filters('some_foo' ...</code>. With the function <a href="http://codex.wordpress.org/Function_Reference/add_filter"><code>add_filter()</code></a> filter functions for further processing in the global variable <code>$wp_filter</code> will be registered.</p>
<pre>
function get_my_some_foo( $foo_bar_array ) {
	$foo_bar_array&#091; count( $foo_bar_array ) + 1 &#093; = &#039;FuuBoo&#039;;

	return $foo_bar_array ;
}

function my_some_foo( $foo_list ) {
    $foo_list = str_replace( &#039;ul&#039;, &#039;ol&#039;, $foo_list ); 

    return $foo_list;
}

add_filter( &#039;some_foo_array&#039;, &#039;get_my_some_foo&#039;);
add_filter( &#039;some_foo&#039;, &#039;my_some_foo&#039;);

// do not forget, call some_foo()
some_foo();
</pre>
<p>Let's look briefly what's happening. What outputs <code>some_foo()</code> has without manipulation we see in the following example.</p>
<pre>
function get_some_foo() {
	$foo_bar_array = array( &#039;Foo&#039;, &#039;Bar&#039;, &#039;FooBar&#039;, &#039;BarFoo&#039; );
	$foo_bar_array = apply_filters( &#039;some_foo_array&#039;, $foo_bar_array );

	return $foo_bar_array ;
}

function some_foo() {
    $foo_list = &#039;&lt;ul&gt;&#039;; 

    foreach(get_some_foo() as $foo_key =&gt; $foo_value){
		$foo_list .= &#039;&lt;li&gt;&#039; . $foo_value . &#039;&lt;/li&gt;&#039;;
    }

    $foo_list .= &#039;&lt;/ul&gt;&#039;;

    echo apply_filters( &#039;some_foo&#039;, $foo_list );
}
?&gt; 

// output
&lt;ul&gt;
	&lt;li&gt;Foo&lt;/li&gt;
	&lt;li&gt;Bar&lt;/li&gt;
	&lt;li&gt;FooBar&lt;/li&gt;
	&lt;li&gt;BarFoo&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>In the next example we use the functions defined in the hooks <code>some_foo_array</code> and <code>some_foo</code> to add the array another element to make the unordered list, an ordered list.</p>
<pre>
function get_my_some_foo( $foo_bar_array ) {
	$foo_bar_array&#091; count( $foo_bar_array ) + 1 &#093; = &#039;FuuBoo&#039;;

	return $foo_bar_array ;
}

function my_some_foo( $foo_list ) {
    $foo_list = str_replace( &#039;ul&#039;, &#039;ol&#039;, $foo_list ); 

    return $foo_list;
}

// register Hooks in the stack ($wp_filter)
add_filter( &#039;some_foo_array&#039;, &#039;get_my_some_foo&#039;);
add_filter( &#039;some_foo&#039;, &#039;my_some_foo&#039;);
?&gt;

//output
&lt;ol&gt;
	&lt;li&gt;Foo&lt;/li&gt;
	&lt;li&gt;Bar&lt;/li&gt;
	&lt;li&gt;FooBar&lt;/li&gt;
	&lt;li&gt;BarFoo&lt;/li&gt;
	&lt;li&gt;FuuBoo&lt;/li&gt;
&lt;/ol&gt;
</pre>
<p>How does <code>add_filter</code> and <code>apply_filters</code> work in the program flow?<br />
Each hook which should be executed is registered with <code>add_filter</code> or <code>add_action</code> in the global variable <code>$wp_filter</code>. If the function <code>apply_filters()</code> is called, an appropriate filter function based on the transmitted variables will be searched in the <code>$wp_filter</code>, if this is registered with <code>add_filter</code>, the appropriate function will execute. Now values will be manipulated now and then passed back to <code>apply_filters</code>.</p>
<p>Let's take our example from above, it looks like this.</p>
<pre>
&lt;?php
// the default function
function get_some_foo() {
	$foo_bar_array = array( &#039;Foo&#039;, &#039;Bar&#039;, &#039;FooBar&#039;, &#039;BarFoo&#039; );
	$foo_bar_array = apply_filters( &#039;some_foo_array&#039;, $foo_bar_array );

	return $foo_bar_array ;
}

// the filter function
function get_my_some_foo( $foo_bar_array ) {
	$foo_bar_array&#091; count( $foo_bar_array ) + 1 &#093; = &#039;FuuBoo&#039;;

	return $foo_bar_array ;
}

// register function in $wp_filter
add_filter( &#039;some_foo_array&#039;, &#039;get_my_some_foo&#039; );
?&gt;
</pre>
<p>Without hook functionality the whole thing would look like the following. Although we have much less code, but this is not reusable.</p>
<pre>
&lt;?php
//Das ist unsere default Funktion
function get_some_foo() {
	$foo_bar_array = array( &#039;Foo&#039;, &#039;Bar&#039;, &#039;FooBar&#039;, &#039;BarFoo&#039; );
	$foo_bar_array&#091; count( $foo_bar_array ) + 1 &#093; = &#039;FuuBoo&#039;;

	return $foo_bar_array ;
}
?&gt;
</pre>
<div class="incontent">
<h4>Guest Post</h4>
<p><img src="http://wpengineer.com/wp-content/uploads/rene-reimann-150x150.jpg" alt="Rene Reimann Avatar" title="Rene Reimann" width="150" height="150" class="alignleft size-thumbnail wp-image-2356" /><a href="http://www.rene-reimann.de/" title="rene-reimann.de">René</a> lives in Halle at Saale, he is married, has a daughter (8) and a dog (12). He is a professional media designer for digital and print media, with a flair for design and color combinations. He is a creative WordPress developer, designer and media consultant who always has a suitable solution. <a href="https://plus.google.com/u/0/116520935691953756105/posts" title="Is G+ profile"> René </a> is an instructor and member of the Examination Board of the Chamber of Halle/Dessau for the education of media designer for digital and print media.
</div>
<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/2355/separate-logic-from-output/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding Custom Fields to WordPress User Profile</title>
		<link>http://wpengineer.com/2173/custom-fields-wordpress-user-profile/</link>
		<comments>http://wpengineer.com/2173/custom-fields-wordpress-user-profile/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 07:08:34 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2173</guid>
		<description><![CDATA[The user profile of WordPress can be fairly easily adapted to add your own values​​. So you can add the necessary fields according to your requirements. Here is how you do it, we add a field for the address and the content will be stored in the database. Various hooks in WordPress make sure that [...]]]></description>
			<content:encoded><![CDATA[<p>The user profile of WordPress can be fairly easily adapted to add your own values​​. So you can add the necessary fields according to your requirements. Here is how you do it, we add a field for the address and the content will be stored in the database. Various hooks in WordPress make sure that you only have to worry about the fields.<br />
<span id="more-2173"></span><br />
<img src="http://wpengineer.com/wp-content/uploads/custom-profile-fields.png" alt="" title="custom-profile-fields" width="630" height="162" class="aligncenter size-full wp-image-2174" /></p>
<p>The function to store the entries is <code>fb_save_custom_user_profile_fields()</code> and here it is important to check the rights of each active user, only if the rights are available, in this case for editing users (<code>edit_user</code>), then data may be stored.<br />
The actual saving of data takes place via <code>update_usermeta()</code>.</p>
<p>It can pass all kinds of fields of course, the input field is just an example. It is advisable to outsource the functions in a Plugin, an alternative is also the <code>functions.php</code> of the Theme, but is certainly not the best way.</p>
<p>Each function of the small sample was referred to two hooks. Because WordPress differentiate between editing of user profiles and update personal data. This is done using the constant <code>IS_PROFILE_PAGE</code>. On default this constant is on TRUE and so would the hooks <code>show_user_profile</code> and <code>personal_options_update</code> be enough to bring in new fields and save them. But this can vary depending on the installation and this way the admin cannot maintain these new fields. In particular, two more hooks are needed. Otherwise there might be many cases, where the admin has to maintain data which the user doesn't even see in his profile.</p>
<pre>
function fb_add_custom_user_profile_fields( $user ) {
?&gt;
	&lt;h3&gt;&lt;?php _e(&#039;Extra Profile Information&#039;, &#039;your_textdomain&#039;); ?&gt;&lt;/h3&gt;

	&lt;table class=&quot;form-table&quot;&gt;
		&lt;tr&gt;
			&lt;th&gt;
				&lt;label for=&quot;address&quot;&gt;&lt;?php _e(&#039;Address&#039;, &#039;your_textdomain&#039;); ?&gt;
			&lt;/label&gt;&lt;/th&gt;
			&lt;td&gt;
				&lt;input type=&quot;text&quot; name=&quot;address&quot; id=&quot;address&quot; value=&quot;&lt;?php echo esc_attr( get_the_author_meta( &#039;address&#039;, $user-&gt;ID ) ); ?&gt;&quot; class=&quot;regular-text&quot; /&gt;&lt;br /&gt;
				&lt;span class=&quot;description&quot;&gt;&lt;?php _e(&#039;Please enter your address.&#039;, &#039;your_textdomain&#039;); ?&gt;&lt;/span&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
&lt;?php }

function fb_save_custom_user_profile_fields( $user_id ) {

	if ( !current_user_can( &#039;edit_user&#039;, $user_id ) )
		return FALSE;

	update_usermeta( $user_id, &#039;address&#039;, $_POST&#091;&#039;address&#039;&#093; );
}

add_action( &#039;show_user_profile&#039;, &#039;fb_add_custom_user_profile_fields&#039; );
add_action( &#039;edit_user_profile&#039;, &#039;fb_add_custom_user_profile_fields&#039; );

add_action( &#039;personal_options_update&#039;, &#039;fb_save_custom_user_profile_fields&#039; );
add_action( &#039;edit_user_profile_update&#039;, &#039;fb_save_custom_user_profile_fields&#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/2173/custom-fields-wordpress-user-profile/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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>unserialize() Error at Offset&#8230; Different solutions</title>
		<link>http://wpengineer.com/2327/unserialize-error-at-offset-different-olutions/</link>
		<comments>http://wpengineer.com/2327/unserialize-error-at-offset-different-olutions/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 07:00:12 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2327</guid>
		<description><![CDATA[The problem is not always obvious, for example the error message in relation to the function unserialize(). If you look around the net to help you find countless search and few answers, because usually the problem lies in the source, in the passed value. But not always you can control it, especially in debugging helpers [...]]]></description>
			<content:encoded><![CDATA[<p>The problem is not always obvious, for example the error message in relation to the function <code>unserialize()</code>. If you look around the net to help you find countless search and few answers, because usually the problem lies in the source, in the passed value. But not always you can control it, especially in debugging helpers there are different contents.</p>
<p>To help some people who are seeking help, here are some solutions you can work with. Some are to be used only in conjunction with WordPress, because the function comes from the core. But there are similar things, of course, even without WP.<br />
<span id="more-2327"></span><br />
The first solution can be found directly in the comments for the function of <a href="http://www.php.net/manual/de/function.unserialize.php#71270">PHP.net</a>. </p>
<pre>
$object = preg_replace( &#039;!s:(\d+):&quot;(.*?)&quot;;!e&#039;, &quot;&#039;s:&#039;.strlen(&#039;$2&#039;).&#039;:\&quot;$2\&quot;;&#039;&quot;, $object );
</pre>
<p>Similar this approach:</p>
<pre>
$object = preg_replace( &#039;/;n;/&#039;, &#039;;N;&#039;, $object );
</pre>
<p>Alternative <a href="http://ryanbosinger.com/blog/2009/php-unserialize-error-at-offset-simple-solution/">others</a> prefer to use <code>trim()</code></p>
<pre>
$object = trim( $object );
</pre>
<p>But even with these solutions you can't always get what you want, you need a queries which gives you the answer whether it is serialized data or not. Usually <code>unserialize()</code> takes care of it, but as I said, this does not always help. WordPress provides its own functions for this.</p>
<ul>
<li>is_serialized( $data )</li>
<li>is_serialized_string( $data )</li>
</ul>
<p>With these two functions it can be queried in a clean way.<br />
But also there you can use a simple snippet. Not the best practice maybe, therefore, I prefer to use the functions or outside of WP, a separate function, see <a href="https://gist.github.com/1415653" title="gist.github.com/1415653">Gist 1415653</a>.</p>
<pre>
$is_serialized = preg_match( &quot;/^(O:|a:)/&quot;, $object );
</pre>
<p>It may help one or the other, otherwise I use it as a memory aid.<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/2327/unserialize-error-at-offset-different-olutions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Activate WordPress Plugins Automatically via a Function</title>
		<link>http://wpengineer.com/2300/activate-wordpress-plugins-automatically-via-a-function/</link>
		<comments>http://wpengineer.com/2300/activate-wordpress-plugins-automatically-via-a-function/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 07:11:17 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[backend]]></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=2300</guid>
		<description><![CDATA[WordPress stores the active Plugins in the database table options, field activate_plugins, so it is easy to change this value to activate various Plugins by WordPress; either as a Plugin solution after setting up a new installation or because some Plugins need some other Plugins. I show you as an example a solution. It is [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress stores the active Plugins in the database table <code>options</code>, field <code>activate_plugins</code>, so it is easy to change this value to activate various Plugins by WordPress; either as a Plugin solution after setting up a new installation or because some Plugins need some other Plugins.<br />
<span id="more-2300"></span><br />
I show you as an example a solution. It is important that you don't use the Plugin names, but the string of the file, which is also required in various hooks. Below you will also find a simple solution to get to this string in your backend.</p>
<pre>
// example on admin init, control about register_activation_hook()
add_action( &#039;admin_init&#039;, &#039;fb_activate_plugins&#039; );
// the exmple function
function fb_activate_plugins() {

	if ( ! current_user_can(&#039;activate_plugins&#039;) )
		wp_die(__(&#039;You do not have sufficient permissions to activate plugins for this site.&#039;));
	$plugins = FALSE;
	$plugins = get_option(&#039;active_plugins&#039;); // get active plugins

	if ( $plugins ) {
		// plugins to active
		$pugins_to_active = array(
			&#039;hello.php&#039;, // Hello Dolly
			&#039;adminimize/adminimize.php&#039;, // Adminimize
			&#039;akismet/akismet.php&#039; // Akismet
		);

		foreach ( $pugins_to_active as $plugin ) {
			if ( ! in_array( $plugin, $plugins ) ) {
				array_push( $plugins, $plugin );
				update_option( &#039;active_plugins&#039;, $plugins );
			}
		}

	} // end if $plugins

}
</pre>
<p>The following function and its hook provides a direct output of the string of the Plugin file on the Plugin page in your backend, so please use it only for a quick finding.</p>
<pre>
add_filter( &#039;plugin_row_meta&#039;, &#039;fb_get_plugin_string&#039;, 10, 4 );
function fb_get_plugin_string( $plugin_meta, $plugin_file, $plugin_data, $status ) {
	// echo plugin file string
	echo &#039;&lt;code&gt;&#039; . $plugin_file . &#039;&lt;/code&gt;&lt;br&gt;&#039;;
	return $plugin_meta;
}
</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/2300/activate-wordpress-plugins-automatically-via-a-function/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Comment Length Limiter</title>
		<link>http://wpengineer.com/2321/comment-length-limiter/</link>
		<comments>http://wpengineer.com/2321/comment-length-limiter/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 07:02:14 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2321</guid>
		<description><![CDATA[If you have used Twitter, then you know that you are only allowed to type 140 characters in a single Tweet. There is a nice little number below the text field indicating how much is left to write. It would be nice to have this feature for WordPress comments too. Or any text field, for [...]]]></description>
			<content:encoded><![CDATA[<p>If you have used Twitter, then you know that you are only allowed to type 140 characters in a single Tweet. There is a nice little number below the text field indicating how much is left to write.<br />
<span id="more-2321"></span><br />
<img src="http://wpengineer.com/wp-content/uploads/Screen-Shot-2011-12-02-at-11.27.23-AM.png" alt="" title="Screen Shot 2011-12-02 at 11.27.23 AM" width="508" height="153" class="aligncenter size-full wp-image-2322" /></p>
<p>It would be nice to have this feature for WordPress comments too. Or any text field, for that matter. It can be done with the following piece of JavaScript:</p>
<pre>
jQuery(function($) {
	// configure
	var comment_input = $( &#039;#commentform textarea&#039; );
	var submit_button = $( &#039;#commentform .form-submit&#039; );
	var comment_limit_chars = 1000;
	// stop editing here

	// display how many characters are left
	$( &#039;&lt;div class=&quot;comment_limit_info&quot;&gt;&lt;span&gt;&#039; + comment_limit_chars + &#039;&lt;/span&gt; characters left&lt;/div&gt;&#039; ).insertAfter( comment_input );

	comment_input.bind( &#039;keyup&#039;, function() {
		// calculate characters left
		var comment_length = $(this).val().length;
		var chars_left = comment_limit_chars - comment_length;

		// display characters left
		$( &#039;.comment_limit_info span&#039; ).html( chars_left );

		// hide submit button if too many chars were used
		if (submit_button)
			( chars_left &lt; 0 ) ? submit_button.hide() : submit_button.show();
	});
});
</pre>
<p><cite><a href="https://gist.github.com/1422754">https://gist.github.com/1422754</a></cite></p>
<p>The first three <code>var</code>s below the <code>// configure</code> comment can be edited.<br />
<code>comment_input</code> is the DOM element of the text field.<br />
<code>submit_button</code> is the DOM element for the button to submit the form.<br />
Finally, <code>comment_limit_chars</code> is the amount of characters allowed.</p>
<p>This snippet automatically inserts a <code>div</code> tag below the text field and updates the character count when the user types. The <code>submit_button</code> is optional. Set the <code>var</code> to <code>null</code> if you don't want it to be grayed out.</p>
<p>Please keep in mind that this only validates the input on the client side. If you have to rely on the maximum text length, like Twitter does, you need to check the length on the back end side with PHP too.</p>
<div class="incontent">
<h4>Guest Post</h4>
<p><img src="http://wpengineer.com/wp-content/uploads/eric-teubert.jpg" alt="" title="selbst" width="150" height="150" class="alignleft size-full wp-image-2163" />This post is written by Eric Teubert - <a href="http://www.satoripress.com/">www.satoripress.com</a> and is a post in our Advent Calendar on WP Engineer about WordPress.<br />
Thank you very much from my part to <a href="http://twitter.com/#!/ericteubert" title="see Eric also on Twitter">Eric</a>.<br />
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!
</div>
<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/2321/comment-length-limiter/feed/</wfw:commentRss>
		<slash:comments>5</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>How to Add and Deactivate the new Feature Pointer in WordPress 3.3</title>
		<link>http://wpengineer.com/2272/how-to-add-and-deactivate-the-new-feature-pointer-in-wordpress-3-3/</link>
		<comments>http://wpengineer.com/2272/how-to-add-and-deactivate-the-new-feature-pointer-in-wordpress-3-3/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 11:36:46 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[wp3.3]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2272</guid>
		<description><![CDATA[With WordPress version 3.3 comes with the Feature Pointer a well-known idea from other tools. We know this for example from Gmail or Google Doc where they notice you of new features, in which they point with bubbles to these new features. In WordPress 3.3, the Admin Bar has been redesigned successfully - I think [...]]]></description>
			<content:encoded><![CDATA[<p>With WordPress version 3.3 comes with the Feature Pointer a well-known idea from other tools. We know this for example from Gmail or Google Doc where they notice you of new features, in which they point with bubbles to these new features. In WordPress 3.3, the Admin Bar has been redesigned successfully - I think - and this is the first time the feature pointer points to it.</p>
<p><img src="http://wpengineer.com/wp-content/uploads/wp-pointer.png" alt="" title="wp-pointer" width="600" height="149" class="aligncenter size-medium wp-image-2273" /> <span id="more-2272"></span><br />
If you are in the environment of customers, it may be that you don't want the feature pointer - different scenarios are possible. But here it also relies on the WordPress hooks so you can intervene in various ways. One idea is to adjust the user settings of the user, as the feature pointer is using Javascript to drop an option in the table, so that the user does not read the instructions again. Alternatively, you can disable it via hook, following solution paste into a small Plugin or the functions.php of your theme (whereas the second solution isn't the best).</p>
<pre>&lt;code&gt;
add_filter( &#039;show_wp_pointer_admin_bar&#039;, &#039;__return_false&#039; );
&lt;/code&gt;</pre>
<p>If you don't have the admin bar not active, then it won't show a feature pointer to it.</p>
<p>Also you can use the hooks to create your own feature pointer. Without adjustment in the design and position is the following simple example conceivable. If the position is changed, it is sufficient to adapt the script section JS-function <code>pointer()</code> in the PHP function <code>get_content_in_wp_pointer()</code>. The function <code>pointer()</code> can be controlled by various parameters (<code>content, position, arrow</code>) .</p>
<pre>
function get_content_in_wp_pointer() {
	$pointer_content  = &#039;&lt;h3&gt;&#039; . __( &#039;WP Pointer with version 3.3.&#039;, &#039;my_textdomain&#039; ) . &#039;&lt;/h3&gt;&#039;;
	$pointer_content .= &#039;&lt;p&gt;&#039; . __( &#039;Add your own informations to WP Pointer.&#039;, &#039;my_textdomain&#039; ) . &#039;&lt;/p&gt;&#039;;

?&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
//&lt;!&#091;CDATA&#091;
jQuery(document).ready( function($) {
	$(&#039;#wpadminbar&#039;).pointer({
		content: &#039;&lt;?php echo $pointer_content; ?&gt;&#039;,
		position: {
			my: &#039;left top&#039;,
			at: &#039;center bottom&#039;,
			offset: &#039;-25 0&#039;
		},
		close: function() {
			setUserSetting( &#039;p1&#039;, &#039;1&#039; );
		}
	}).pointer(&#039;open&#039;);
});
//&#093;&#093;&gt;
&lt;/script&gt;
&lt;?php
}

function fb_enqueue_wp_pointer( $hook_suffix ) {
	$enqueue = FALSE;

	$admin_bar = get_user_setting( &#039;p1&#039;, 0 ); // check settings on user
	// check if admin bar is active and default filter for wp pointer is true
	if ( ! $admin_bar &amp;&amp; apply_filters( &#039;show_wp_pointer_admin_bar&#039;, TRUE ) ) {
		$enqueue = TRUE;
		add_action( &#039;admin_print_footer_scripts&#039;, &#039;get_content_in_wp_pointer&#039; );
	}
	// in true, include the scripts
	if ( $enqueue ) {
		wp_enqueue_style( &#039;wp-pointer&#039; );
		wp_enqueue_script( &#039;wp-pointer&#039; );
		wp_enqueue_script( &#039;utils&#039; ); // for user settings
	}
}
add_action( &#039;admin_enqueue_scripts&#039;, &#039;fb_enqueue_wp_pointer&#039; );
</pre>
<p><a href="http://wpengineer.com/wp-content/uploads/wp-pointer-2.png"><img src="http://wpengineer.com/wp-content/uploads/wp-pointer-2-300x96.png" alt="" title="wp-pointer-2" width="300" height="96" class="aligncenter size-medium wp-image-2274" /></a></p>
<p><strong>Please note:</strong> The implementation is based on a nightly build of WordPress, not the final Release 3.3 and thus might have some changes or other solutions are possible in a later version. Therefore, please validate according to the version of WordPress the solution. As a tip this should be enough - anything else is creativity and your skills.<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/2272/how-to-add-and-deactivate-the-new-feature-pointer-in-wordpress-3-3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

