<?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; backend</title>
	<atom:link href="http://wpengineer.com/tag/backend/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>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>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>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>Advent Calendar – WordPress, WPCron and the right Time</title>
		<link>http://wpengineer.com/2350/advent-calendar-wordpress-wpcron-and-the-right-time/</link>
		<comments>http://wpengineer.com/2350/advent-calendar-wordpress-wpcron-and-the-right-time/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 07:52:59 +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[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2350</guid>
		<description><![CDATA[WordPress offers a pseudo-cronjob functionality, which allows the developer to execute scheduled events. For example, the whole Update Notification does it. In these so-called Scheduled Events you can define your own jobs. Thereby you should however pay attention to one important thing: time. The wp-cron.php works outside the core and loads only the most important [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress offers a pseudo-cronjob functionality, which allows the developer to execute scheduled events. For example, the whole Update Notification does it. In these so-called <em>Scheduled Events</em> you can define your own jobs. Thereby you should however pay attention to one important thing: time.<br />
<span id="more-2350"></span><br />
The <code>wp-cron.php</code> works outside the core and loads only the most important things and leaves all settings of WordPress open. In the <em>Settings -> General</em> set time zone is not included. <code>wp-cron.php</code> runs on UTC.</p>
<p>That means: Are we in the time zone of Berlin, the local time is UTC +1. Are we performing a scheduled event, it will always be one hour after the actual time we like to execute. To change this, we use the following function:</p>
<pre>
function get_offset_to_gmt_in_seconds() {

	$current_timezone_offset = get_option( &#039;gmt_offset&#039; );
	$offset = $current_timezone_offset * 3600;

	return $offset;
}
</pre>
<div class="incontent">
<h4>Guest Post</h4>
<p><img src="http://wpengineer.com/wp-content/uploads/dasllama-150x150.png" alt="" title="dasllama" width="150" height="150" class="alignleft size-thumbnail wp-image-2223" />This post is written by Thomas Herzog - <a href="http://hughwillfayle.de/">hughwillfayle.de</a> and is a guest post on WP Engineer about WordPress.<br />
Thank you very much from my part to Thomas. Please see <a href="http://profiles.wordpress.org/users/hughwillfayle/">his nice plugins</a> on the official WordPress repository.<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/2350/advent-calendar-wordpress-wpcron-and-the-right-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Advent Calendar – WordPress Editor: Preserve the scroll position</title>
		<link>http://wpengineer.com/2340/advent-calendar-%e2%80%93-wordpress-editor-preserve-the-scroll-position/</link>
		<comments>http://wpengineer.com/2340/advent-calendar-%e2%80%93-wordpress-editor-preserve-the-scroll-position/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 06:59:38 +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[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2340</guid>
		<description><![CDATA[WordPress has a nice editor, with which are several hundreds of articles written daily. But in my opinion the editor has an usability issue. Every time you save a post the scroll position of the editor will be on top again. If you want to continue writing the post you have first to find he [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has a nice editor, with which are several hundreds of articles written daily.</p>
<p>But in my opinion the editor has an usability issue.<br />
Every time you save a post the scroll position of the editor will be on top again. If you want to continue writing the post you have first to find he old position again. This can be time-consuming.<br />
<span id="more-2340"></span><br />
<div id="attachment_2342" class="wp-caption aligncenter" style="width: 510px"><img src="http://wpengineer.com/wp-content/uploads/wp-editor-preserve-scroll-position.png" alt="" title="wp-editor-preserve-scroll-position" width="500" height="225" class="size-full wp-image-2342" /><p class="wp-caption-text">Save editor scroll position on saving</p></div></p>
<p>To avoid this behavior I have written a snippet which I want to share now with you.</p>
<pre>
&lt;?php
/**
 * The class will help you to recover the old scoll position in your Editor.
 * Either HTML or visuel editor.
 */
final class Preserve_Editor_Scroll_Position {
	/**
	 * Init
	 */
	public static function init() {
		add_filter( &#039;redirect_post_location&#039;, array( __CLASS__, &#039;add_query_arg&#039; ) );
		add_action( &#039;edit_form_advanced&#039;, array( __CLASS__, &#039;add_input_field&#039; ) );
		add_action( &#039;edit_page_form&#039;, array( __CLASS__, &#039;add_input_field&#039; ) );
		add_filter( &#039;tiny_mce_before_init&#039;, array( __CLASS__, &#039;extend_tiny_mce&#039; ) );
	}

	/**
	 * Adds a hidden input field for scrolltop value
	 */
	public static function add_input_field() {
		$position = ! empty( $_GET&#091;&#039;scrollto&#039;&#093; ) ? $_GET&#091;&#039;scrollto&#039;&#093; : 0;

		printf( &#039;&lt;input type=&quot;hidden&quot; id=&quot;scrollto&quot; name=&quot;scrollto&quot; value=&quot;%d&quot;/&gt;&#039;, esc_attr( $position ) );

		// Print Javascript data
		add_action( &#039;admin_print_footer_scripts&#039;, array( __CLASS__, &#039;print_js&#039; ), 55 ); // Print after Editor JS.
	}

	/**
	 * Extend TinyMCE config with a setup function
	 */
	public static function extend_tiny_mce( $init ) {
		if ( &#039;tinymce&#039; == wp_default_editor() )
			$init&#091;&#039;setup&#039;&#093; = &#039;rich_scroll&#039;;

		return $init;
	}

	/**
	 * Returns redirect url with query arg for scroll position
	 */
	public static function add_query_arg( $location ) {
		if ( ! empty( $_POST&#091;&#039;scrollto&#039;&#093; ) )
			$location = add_query_arg( &#039;scrollto&#039;, (int) $_POST&#091;&#039;scrollto&#039;&#093;, $location );

		return $location;
	}

	/**
	 * Prints Javascript data
	 */
	public static function print_js() {
		?&gt;
	&lt;script&gt;
	( function( $ ) {
		$( &#039;#post&#039; ).submit( function() {
			scrollto =
				$( &#039;#content&#039; ).is( &#039;:hidden&#039; ) ?
				$( &#039;#content_ifr&#039; ).contents().find( &#039;body&#039; ).scrollTop() :
				$( &#039;#content&#039; ).scrollTop();

			$( &#039;#scrollto&#039; ).val( scrollto );
		} );

		$( &#039;#content&#039; ).scrollTop( $( &#039;#scrollto&#039; ).val() );
	} )( jQuery );

	function rich_scroll( ed ) {
		ed.onInit.add( function() {
			jQuery( &#039;#content_ifr&#039; ).contents().find( &#039;body&#039; ).scrollTop( jQuery( &#039;#scrollto&#039; ).val() );
		} );
	};
	&lt;/script&gt;
		&lt;?php
	}
}
add_action( &#039;plugins_loaded&#039;, array( &#039;Preserve_Editor_Scroll_Position&#039;, &#039;init&#039; ) );
</pre>
<p>If you want you can create your own plugin with this snippet or you can download the plugin <a href="http://wordpress.org/extend/plugins/preserve-editor-scroll-position/">Preserve Editor Scroll Position</a>.</p>
<div class="incontent">
<h4>Guest Post</h4>
<p><img src="http://wpengineer.com/wp-content/uploads/dominik-schilling-g+.png" alt="Dominik Schilling Avatar" title="selbst" width="150" height="150" class="alignleft" />This post is written by Dominik Schilling - <a href="http://wpgrafie.de/">wpgrafie.de</a> and is a post in our Advent Calendar on WP Engineer about WordPress. Dominik is Student, Web Developer, WordPress Contributing Developer - <a href="http://profiles.wordpress.org/users/ocean90">ocean90</a> and he ♥ WordPress.<br />
Thank you very much from my part to <a href="https://plus.google.com/101675293278434581718/about" title="see his G+ rofile">Dominik</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/2340/advent-calendar-%e2%80%93-wordpress-editor-preserve-the-scroll-position/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Use Constants for deactivate the Editor in WordPress Backend</title>
		<link>http://wpengineer.com/2261/use-constants-for-deactivate-the-editor-in-wordpress-backend/</link>
		<comments>http://wpengineer.com/2261/use-constants-for-deactivate-the-editor-in-wordpress-backend/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 10:22:40 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[WP3.0]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2261</guid>
		<description><![CDATA[WordPress is known for, that several constants lie dormant in the core and often provide quick solutions. In this context I have recently come across two little strings in the core of the backend editor of WordPress and in the core for updating the system as well. As far as I know, all constants mentioned [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress is known for, that several constants lie dormant in the core and often provide quick solutions. In this context I have recently come across two little strings in the core of the backend editor of WordPress and in the core for updating the system as well. As far as I know, all constants mentioned here are in the system since version 3.0.<br />
<span id="more-2261"></span><br />
The first constant takes off the editors of the backend and does not allow access to it. This makes the editing of Theme and Plugin files of the backend with standard solutions not possible.</p>
<pre class="php">
// for enabling/disabling theme/plugin editor
define( &#039;DISALLOW_FILE_EDIT&#039;, TRUE );
</pre>
<p>The second constant presented here prohibits editing, modifying or changing the core files, Plugins or Themes. In this context the menu entries in the backend are not visible or usable. Thus the update is not so easy to do and clients and unauthenticated users are blocked quickly.</p>
<pre>
// Disallow anything that creates, deletes, or edits core, plugin, or theme files.
// Files in uploads are excepted.
define( &#039;DISALLOW_FILE_MODS&#039;, TRUE );
</pre>
<p>In this context there are two constants that are useful now and then.</p>
<p>In various contexts it is very useful that all users have the option of: to write unfiltered HTML, in all aspects and this can also be easily implemented via constants:</p>
<pre>// Disallow unfiltered_html for all users, even admins and super admins
DISALLOW_UNFILTERED_HTML
</pre>
<p>Similar existing for uploads:</p>
<pre>// Allow uploads of filtered file types to users with administrator role
ALLOW_UNFILTERED_UPLOADS
</pre>
<p>The constants belong in the <code>wp-config.php</code> of the installation.<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/2261/use-constants-for-deactivate-the-editor-in-wordpress-backend/feed/</wfw:commentRss>
		<slash:comments>0</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>
		<item>
		<title>Remove Menu Item in WordPress Admin Panel</title>
		<link>http://wpengineer.com/2233/remove-menu-item-in-wordpress-admin-panel/</link>
		<comments>http://wpengineer.com/2233/remove-menu-item-in-wordpress-admin-panel/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 05:50:40 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></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[wp3.1]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2233</guid>
		<description><![CDATA[With WordPress Version 3.1 two new functions were added which makes it easier to remove menu- and submenu-entries in WordPress Admin Panel. These functions removing entries of the menu-tree remove_menu_page or submenus - remove_submenu_page. /** * Remove a top level admin menu * * @param string $menu_slug The slug of the menu * @return array&#124;bool [...]]]></description>
			<content:encoded><![CDATA[<p>With WordPress Version 3.1 two new functions were added which makes it easier to remove menu- and submenu-entries in WordPress Admin Panel. These functions removing entries of the menu-tree <code>remove_menu_page</code> or submenus - <code>remove_submenu_page</code>.<br />
<span id="more-2233"></span></p>
<pre>
/**
 * Remove a top level admin menu
 *
 * @param string $menu_slug The slug of the menu
 * @return array|bool The removed menu on success, False if not found
 */
remove_menu_page( $menu_slug )
</pre>
<pre>
/**
 * Remove an admin submenu
 *
 * @param string $menu_slug The slug for the parent menu
 * @param string $submenu_slug The slug of the submenu
 * @return array|bool The removed submenu on success, False if not found
 */
remove_submenu_page( $menu_slug, $submenu_slug ) {
</pre>
<p>It's easy to remove menu entries and it is not necessary anymore to read the arrays $menu and $submenu. Until now you had to search for them in the array and remove them via unset() from the array. Alternatively you were also able to find the entry on the basis of a key - the above new features make this unnecessary and as a parameter value only the "slug" is passed, which can be found in the link or the URL of the backend. A small example, where we remove the entries to the comments and the submenu-page discussion will show the new possibilities.</p>
<pre>
function fb_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_action( &#039;admin_menu&#039;, &#039;fb_remove_menu_entries&#039; );
</pre>
<p>The above code provides a simple solution, removed the two entries and also has a fallback for WordPress, smaller version 3.1. It is also conceivable that the removal is also connected with user rights</p>
<pre>if ( function_exists( &#039;remove_menu_page&#039; ) &amp;&amp; ! current_user_can( &#039;manage_options&#039; ) ) {</pre>
<p>so it would be possible to optimize the menu explicitly for a user.  Alternatively, the plug <a href="http://wordpress.org/extend/plugins/adminimize/">Adminimize</a> helps and facilitates the job via admin area.<br />
You can also read about this topic on <a href="http://devpress.com/blog/removing-menu-pages-from-the-wordpress-admin/">Justin's post</a>, but my post was an older draft and now was published - the topic is worth it.<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/2233/remove-menu-item-in-wordpress-admin-panel/feed/</wfw:commentRss>
		<slash:comments>1</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>View Blog ID in WordPress Multisite</title>
		<link>http://wpengineer.com/2188/view-blog-id-in-wordpress-multisite/</link>
		<comments>http://wpengineer.com/2188/view-blog-id-in-wordpress-multisite/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 09:49:56 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Multisite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[WP3.0]]></category>
		<category><![CDATA[wp3.1]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2188</guid>
		<description><![CDATA[When you work quite a bit with WordPress Multisites, sometimes you need the IDs for some functions or Plugins. The easiest way is via the hover effect with your mouse or you use a little code snippet to add a column with the ID in the table view. The following code belongs into a Plugin [...]]]></description>
			<content:encoded><![CDATA[<p>When you work quite a bit with WordPress Multisites, sometimes you need the IDs for some functions or Plugins. The easiest way is via the hover effect with your mouse or you use a little code snippet to add a column with the ID in the table view.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/wp-blog-id.png"><img src="http://wpengineer.com/wp-content/uploads/wp-blog-id-300x99.png" alt="" title="wp-blog-id" width="300" height="99" class="aligncenter size-medium wp-image-2189" /></a><br />
<span id="more-2188"></span><br />
The following code belongs into a Plugin and should be placed in the folder mu-plugins.</p>
<pre>
class Add_Blog_ID {

	public static function init() {
		$class = __CLASS__ ;

		if ( empty( $GLOBALS&#091; $class &#093; ) )
			$GLOBALS&#091; $class &#093; = new $class;
	}

	public function __construct() {

		add_filter( &#039;wpmu_blogs_columns&#039;, array( $this, &#039;get_id&#039; ) );
		add_action( &#039;manage_sites_custom_column&#039;, array( $this, &#039;add_columns&#039; ), 10, 2 );
		add_action( &#039;manage_blogs_custom_column&#039;, array( $this, &#039;add_columns&#039; ), 10, 2 );
		add_action( &#039;admin_footer&#039;, array( $this, &#039;add_style&#039; ) );
	}

	public function add_columns( $column_name, $blog_id ) {

		if ( &#039;blog_id&#039; === $column_name )
			echo $blog_id;

		return $column_name;
	}

	// Add in a column header
	public function get_id( $columns ) {

		$columns&#091;&#039;blog_id&#039;&#093; = __(&#039;ID&#039;);

		return $columns;
	}

	public function add_style() {

		echo &#039;&lt;style&gt;#blog_id { width:7%; }&lt;/style&gt;&#039;;
	}
}
add_action( &#039;init&#039;, array( &#039;Add_Blog_ID&#039;, &#039;init&#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/2188/view-blog-id-in-wordpress-multisite/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

