Best Practice for Multilanguage WordPress Content? New Plugin!

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 (ein Bsp. bei StackExchange) it would quickly become an project and WordPress would be just a "small" framework behind it. There are already many Plugins available, the different approaches - new tables in the system or separation of content for each language in a table entry to post, or other solutions.

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 Inpsyde Team 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.


Why multilanuage?

  • 2/3, if not even more, of the worldwide population speak another language
  • Globale Aufstellung von Unternehmen
  • Better distribution of content
  • Service for the client
  • Search Engine Optimization

The solution

WordPress Multi-site provides the solution already.
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.

Advantages

  • WordPress Core Functions
  • No dependency to Plugins
  • Independent to WordPress development*
  • Control Themes, Plugins at a central place, use them decentralized
  • Low maintenance
  • Seperating languages in Backend/Frontend (user dependent)
  • Complete mirrored or in every content form seperated
  • Subdomains or Subdirectories
  • de.example.com, example.com/de
  • Seperate Domains via Domainmapping
  • example.de, example.com
  • Free in development in design and usability
  • Optimization not only on frontend, also lang-attributes, SEO

Plugin

With all these requirements and benefits, we use a base that is available as a Plugin in the official repository of WordPress: Multilingual Press . The plugin provides several convenient tools to use Multisite for the implementation of multilingualism.

banner-772x250 screenshot-1 screenshot-2 screenshot-3 screenshot-4 WordPress-Christmas-2010-24

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.
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.

An outlook

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.

Summary

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 our repo on Github.

.

This was our last door of our Advent Calendar. We hope you enjoyed it!

We wish you a Merry Christmas and thanks a lot for reading our posts!


WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Separate Logic From Output

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 MVC, yeah you right, but WordPress does not pursue a Consistent MVC pattern!

Why WordPress doesn't follow MVC pattern consistently?

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.

function get_some_foo() {
        $my_foo = 'This is Foo!';
        return $my_foo;
}
function some_foo() {
        $foo = get_some_foo();
        echo $foo;
}

Why is this useful? We want the function some_foo() returns a predefined output. In another template we want to change the default behavior of the function some_foo(). 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 get_.... The second function includes predefined information, which in turn can be HTML, test logic, loops, or a hook.

function get_some_foo() {
        $foo_bar_array = array( 'Foo', 'Bar', 'FooBar', 'BarFoo' );
        $foo_bar_array = apply_filters( 'some_foo_array', $foo_bar_array );
        return $foo_bar_array ;
}
function some_foo() {
    $foo_list = '<ul>';
    foreach( get_some_foo() as $foo_key => $foo_value ){
                $foo_list .= '<li>' . $foo_value . '</li>';
    }
    $foo_list .= '</ul>';
    echo apply_filters( 'some_foo', $foo_list );
}

In the previous example in each of the two functions with the function apply_filters() the possibility will be created, to change returned values later as you desired. A manipulation can take place via the so-defined hooks some_foo_array or some_foo. Here is an example of how a possible manipulation can look with the two defined hooks.

In the next code example, we change an array $foo_bar_array and the HTML output. This involves the two hooks some_foo_array and some_foo, which were set with apply_filters('some_foo' .... With the function add_filter() filter functions for further processing in the global variable $wp_filter will be registered.

function get_my_some_foo( $foo_bar_array ) {
        $foo_bar_array[ count( $foo_bar_array ) + 1 ] = 'FuuBoo';
        return $foo_bar_array ;
}
function my_some_foo( $foo_list ) {
    $foo_list = str_replace( 'ul', 'ol', $foo_list );
    return $foo_list;
}
add_filter( 'some_foo_array', 'get_my_some_foo');
add_filter( 'some_foo', 'my_some_foo');
// do not forget, call some_foo()
some_foo();

Let's look briefly what's happening. What outputs some_foo() has without manipulation we see in the following example.

function get_some_foo() {
        $foo_bar_array = array( 'Foo', 'Bar', 'FooBar', 'BarFoo' );
        $foo_bar_array = apply_filters( 'some_foo_array', $foo_bar_array );
        return $foo_bar_array ;
}
function some_foo() {
    $foo_list = '<ul>';
    foreach(get_some_foo() as $foo_key => $foo_value){
                $foo_list .= '<li>' . $foo_value . '</li>';
    }
    $foo_list .= '</ul>';
    echo apply_filters( 'some_foo', $foo_list );
}
?>
// output
<ul>
        <li>Foo</li>
        <li>Bar</li>
        <li>FooBar</li>
        <li>BarFoo</li>
</ul>

In the next example we use the functions defined in the hooks some_foo_array and some_foo to add the array another element to make the unordered list, an ordered list.

function get_my_some_foo( $foo_bar_array ) {
        $foo_bar_array[ count( $foo_bar_array ) + 1 ] = 'FuuBoo';
        return $foo_bar_array ;
}
function my_some_foo( $foo_list ) {
    $foo_list = str_replace( 'ul', 'ol', $foo_list );
    return $foo_list;
}
// register Hooks in the stack ($wp_filter)
add_filter( 'some_foo_array', 'get_my_some_foo');
add_filter( 'some_foo', 'my_some_foo');
?>
//output
<ol>
        <li>Foo</li>
        <li>Bar</li>
        <li>FooBar</li>
        <li>BarFoo</li>
        <li>FuuBoo</li>
</ol>

How does add_filter and apply_filters work in the program flow?
Each hook which should be executed is registered with add_filter or add_action in the global variable $wp_filter. If the function apply_filters() is called, an appropriate filter function based on the transmitted variables will be searched in the $wp_filter, if this is registered with add_filter, the appropriate function will execute. Now values will be manipulated now and then passed back to apply_filters.

Let's take our example from above, it looks like this.

<?php
// the default function
function get_some_foo() {
        $foo_bar_array = array( 'Foo', 'Bar', 'FooBar', 'BarFoo' );
        $foo_bar_array = apply_filters( 'some_foo_array', $foo_bar_array );
        return $foo_bar_array ;
}
// the filter function
function get_my_some_foo( $foo_bar_array ) {
        $foo_bar_array[ count( $foo_bar_array ) + 1 ] = 'FuuBoo';
        return $foo_bar_array ;
}
// register function in $wp_filter
add_filter( 'some_foo_array', 'get_my_some_foo' );
?>

Without hook functionality the whole thing would look like the following. Although we have much less code, but this is not reusable.

<?php
//Das ist unsere default Funktion
function get_some_foo() {
        $foo_bar_array = array( 'Foo', 'Bar', 'FooBar', 'BarFoo' );
        $foo_bar_array[ count( $foo_bar_array ) + 1 ] = 'FuuBoo';
        return $foo_bar_array ;
}
?>

Guest Post

Rene Reimann AvatarRené 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. René 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.


WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Adding Custom Fields to WordPress User Profile

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.

The function to store the entries is fb_save_custom_user_profile_fields() 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 (edit_user), then data may be stored.
The actual saving of data takes place via update_usermeta().

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 functions.php of the Theme, but is certainly not the best way.

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 IS_PROFILE_PAGE. On default this constant is on TRUE and so would the hooks show_user_profile and personal_options_update 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.

function fb_add_custom_user_profile_fields( $user ) {
?>
        <h3><?php _e('Extra Profile Information', 'your_textdomain'); ?></h3>
        <table class="form-table">
                <tr>
                        <th>
                                <label for="address"><?php _e('Address', 'your_textdomain'); ?>
                        </label></th>
                        <td>
                                <input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br />
                                <span class="description"><?php _e('Please enter your address.', 'your_textdomain'); ?></span>
                        </td>
                </tr>
        </table>
<?php }
function fb_save_custom_user_profile_fields( $user_id ) {
        if ( !current_user_can( 'edit_user', $user_id ) )
                return FALSE;
        update_usermeta( $user_id, 'address', $_POST['address'] );
}
add_action( 'show_user_profile', 'fb_add_custom_user_profile_fields' );
add_action( 'edit_user_profile', 'fb_add_custom_user_profile_fields' );
add_action( 'personal_options_update', 'fb_save_custom_user_profile_fields' );
add_action( 'edit_user_profile_update', 'fb_save_custom_user_profile_fields' );

WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Register Settings on WordPress Multisite

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.

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.

The best case for this is a Function of WordPress, which is triggered when activating a plugin register_activation_hook(). 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 - add_option(). In Multisite there is also a function for it - add_site_option().

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:

register_activation_hook( __FILE__, 'fb_add_config' );
function fb_add_config() {
        $data = array(
                'active' => 0,
                'radio'  => 0,
                'link'   => 1,
                'theme'  => 1,
                'role'   => 'administrator',
                'unit'   => 1,
        );
        // if is active in network of multisite
        if ( is_multisite() && isset($_GET['networkwide']) && 1 == $_GET['networkwide'] ) {
                add_site_option( 'my_settings_id', $data );
        } else {
                add_option( 'my_settings_id', $data );
        }
}

The query of the value in the global GET can be integrated in the long time ago mentioned solution for Multisite and settings.

To solve other queries in a Multisite environment and to remove the setup or integrate menus in the admin area, the function is_plugin_active_for_network() is useful.

if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
        $values = get_site_option( 'my_settings_id' );
else
        $values = get_option( 'my_settings_id' );

WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Easier Plugin Development by Moving Plugin Directory

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 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?
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 of PHP. So this does not work either.

Fortunately WordPress defines two constants which can help you to simplify things nonetheless: WP_PLUGIN_DIR and WP_PLUGIN_URL. 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
.
To make your plugins accessible to all your installed WordPress versions you simply move them to a central directory and define the constants accordingly:

define( 'WP_PLUGIN_DIR', '/var/www/plugins' ); // or with XAMPP C:/xampp/htdocs/plugins
define( 'WP_PLUGIN_URL', 'http://localhost/plugins' );

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.

(Thanks to John Blackbourn on the wp-hackers list for having the idea.)

Hint for Multisite-Users

Also usable for WordPress Multisite

define( 'WPMU_PLUGIN_DIR', '/var/www/multisite-plugins' );
define( 'WPMU_PLUGIN_URL', 'http://localhost/multisite-plugins' );

WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

unserialize() Error at Offset… Different solutions

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 there are different contents.

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.

The first solution can be found directly in the comments for the function of PHP.net.

$object = preg_replace( '!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $object );

Similar this approach:

$object = preg_replace( '/;n;/', ';N;', $object );

Alternative others prefer to use trim()

$object = trim( $object );

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 unserialize() takes care of it, but as I said, this does not always help. WordPress provides its own functions for this.

  • is_serialized( $data )
  • is_serialized_string( $data )

With these two functions it can be queried in a clean way.
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 Gist 1415653.

$is_serialized = preg_match( "/^(O:|a:)/", $object );

It may help one or the other, otherwise I use it as a memory aid.


WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Activate WordPress Plugins Automatically via a Function

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 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.

// example on admin init, control about register_activation_hook()
add_action( 'admin_init', 'fb_activate_plugins' );
// the exmple function
function fb_activate_plugins() {
        if ( ! current_user_can('activate_plugins') )
                wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
        $plugins = FALSE;
        $plugins = get_option('active_plugins'); // get active plugins
        if ( $plugins ) {
                // plugins to active
                $pugins_to_active = array(
                        'hello.php', // Hello Dolly
                        'adminimize/adminimize.php', // Adminimize
                        'akismet/akismet.php' // Akismet
                );
                foreach ( $pugins_to_active as $plugin ) {
                        if ( ! in_array( $plugin, $plugins ) ) {
                                array_push( $plugins, $plugin );
                                update_option( 'active_plugins', $plugins );
                        }
                }
        } // end if $plugins
}

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.

add_filter( 'plugin_row_meta', 'fb_get_plugin_string', 10, 4 );
function fb_get_plugin_string( $plugin_meta, $plugin_file, $plugin_data, $status ) {
        // echo plugin file string
        echo '<code>' . $plugin_file . '</code><br>';
        return $plugin_meta;
}

WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Comment Length Limiter

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 that matter. It can be done with the following piece of JavaScript:

jQuery(function($) {
        // configure
        var comment_input = $( '#commentform textarea' );
        var submit_button = $( '#commentform .form-submit' );
        var comment_limit_chars = 1000;
        // stop editing here
        // display how many characters are left
        $( '<div class="comment_limit_info"><span>' + comment_limit_chars + '</span> characters left</div>' ).insertAfter( comment_input );
        comment_input.bind( 'keyup', function() {
                // calculate characters left
                var comment_length = $(this).val().length;
                var chars_left = comment_limit_chars - comment_length;
                // display characters left
                $( '.comment_limit_info span' ).html( chars_left );
                // hide submit button if too many chars were used
                if (submit_button)
                        ( chars_left < 0 ) ? submit_button.hide() : submit_button.show();
        });
});

https://gist.github.com/1422754

The first three vars below the // configure comment can be edited.
comment_input is the DOM element of the text field.
submit_button is the DOM element for the button to submit the form.
Finally, comment_limit_chars is the amount of characters allowed.

This snippet automatically inserts a div tag below the text field and updates the character count when the user types. The submit_button is optional. Set the var to null if you don't want it to be grayed out.

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.

Guest Post

This post is written by Eric Teubert - www.satoripress.com and is a post in our Advent Calendar on WP Engineer about WordPress.
Thank you very much from my part to Eric.
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!


WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Advent Calendar- How to disable comments for WordPress pages in any theme

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 the next update.

No problem. There’s an hook for that. It’s a filter called … wait for it … comments_template. We can change the path to the comments template here – if haven’t figured that out already. Let’s build a small plugin.

So, what do we do? We hook into comments_template(); 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 know it exists and we control the output.

As you may have noticed our plugin file is included two times: First as a plugin, later as a replacement for comments.php. The function_exists() check prevents any You cannot redeclare … errors.

Putting this all together …

<?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't like that.
! defined( 'ABSPATH' ) and exit;
// If the function exists this file is called as comments template.
// We don't do anything then.
if ( ! function_exists( 't5_disable_comments_on_pages' ) ) {
        /**
         * Replaces the path of the original comments template with this
         * file'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( 'comments_template', 't5_disable_comments_on_pages', 11 );
}

WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

How to Add and Deactivate the new Feature Pointer in WordPress 3.3

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.


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).

<code>
add_filter( 'show_wp_pointer_admin_bar', '__return_false' );
</code>

If you don't have the admin bar not active, then it won't show a feature pointer to it.

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 pointer() in the PHP function get_content_in_wp_pointer(). The function pointer() can be controlled by various parameters (content, position, arrow) .

function get_content_in_wp_pointer() {
        $pointer_content  = '<h3>' . __( 'WP Pointer with version 3.3.', 'my_textdomain' ) . '</h3>';
        $pointer_content .= '<p>' . __( 'Add your own informations to WP Pointer.', 'my_textdomain' ) . '</p>';
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready( function($) {
        $('#wpadminbar').pointer({
                content: '<?php echo $pointer_content; ?>',
                position: {
                        my: 'left top',
                        at: 'center bottom',
                        offset: '-25 0'
                },
                close: function() {
                        setUserSetting( 'p1', '1' );
                }
        }).pointer('open');
});
//]]>
</script>
<?php
}
function fb_enqueue_wp_pointer( $hook_suffix ) {
        $enqueue = FALSE;
        $admin_bar = get_user_setting( 'p1', 0 ); // check settings on user
        // check if admin bar is active and default filter for wp pointer is true
        if ( ! $admin_bar && apply_filters( 'show_wp_pointer_admin_bar', TRUE ) ) {
                $enqueue = TRUE;
                add_action( 'admin_print_footer_scripts', 'get_content_in_wp_pointer' );
        }
        // in true, include the scripts
        if ( $enqueue ) {
                wp_enqueue_style( 'wp-pointer' );
                wp_enqueue_script( 'wp-pointer' );
                wp_enqueue_script( 'utils' ); // for user settings
        }
}
add_action( 'admin_enqueue_scripts', 'fb_enqueue_wp_pointer' );

Please note: 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.


WordPress Snippet PluginXtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)




btbt
Designed by Wbcom Designs
#