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 Plugin Xtreme 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 Plugin Xtreme 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 Plugin Xtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

Restrict Mime Types on WordPress Media Upload

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.


Screenshot Example for restrive the mime type

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

Anyone interested in the currently allowed types, you can return the array of the first function or look into the function get_allowed_mime_types() in wp-includes/functions.php.

Screenshot for Hint about allowed Mime Types

<?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ültge
 * Author URI:  http://bueltge.de/
 */
 // 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 upload_mimes.
// We don't do anything then.
if ( ! function_exists( 'fb_restrict_mime_types' ) ) {
        add_filter( 'upload_mimes', 'fb_restrict_mime_types' );
        /**
         * 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(
                        'pdf' => 'application/pdf',
                        'doc|docx' => 'application/msword',
                );
                return $mime_types;
        }
}
// If the function exists this file is called as post-upload-ui.
// We don't do anything then.
if ( ! function_exists( 'fb_restrict_mime_types_hint' ) ) {
        // add to wp
        add_action( 'post-upload-ui', 'fb_restrict_mime_types_hint' );
        /**
         * Get an Hint about the allowed mime types
         *
         * @return  void
         */
        function fb_restrict_mime_types_hint() {
                echo '<br />';
                _e( 'Accepted MIME types: PDF, DOC/DOCX' );
        }
}

WordPress Snippet Plugin Xtreme 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 Plugin Xtreme One WordPress Framework
© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

35 Best WordPress Plugins – Want Unfair Advantage?

WordPress is certainly one of the most feature rich and user friendly publishing platforms available today. At the same time it is loved for its openness, extendibility and great open source community. WordPress is today used in serious projects and on large commercial websites besides the millions of hard working bloggers sharing their valuable knowledge. This trend have created a huge market for professional high quality premium themes and recently we have also seen a market emerge for best wordpress plugins as nearly any kind.

While WordPress originally gained it’s position in the market by being a pure open source and completely free platform I believe the premium offerings around it today is going to make it even stronger. You see best WordPress plugins are created by expert plugin developers that back their best WordPress plugins with excellent support for their customers. In some cases free plugin developers provide support, but typically it depends on how busy they are and there is a significant risk that free plugins you rely heavily on, suddenly is not maintained any more. We all know how time consuming or expensive it can be to implement the perfect website or blog. Making sure the important extension we use are going to be maintained, developed upon and most importantly well supported is key and worth spending a few bucks on.

In this post, we will showcase some of the best WordPress plugins. I hope you will enjoy this tour.


WooThemes - Made by Designers
WooThemes - Made by Designers

Advertisement

Hand-picked Best WordPress Plugins

As already mentioned WordPress is an exceptional open source blog tool and the great variety of best WordPress plugins and themes makes it even more useful. Choosing the right extensions can make the difference between whether you succeed or not. Let’s be inspired to make things easier and more effective with these great premium plugins.

WordPress Events Calendar – DEMO

Professional and elegant plugin that adds an Event Calendar to your posts or pages.

Post Type Column Editor – DEMO

Easily customize the dashboard columns for all your post types.

This plugin gives you a really easy to use way to modify and manage the table columns for your post types. You can display post type entry titles, categories, tags, excerpts, authors, custom meta fields, thumbnails, and custom taxonomies.

Customize the columns for each built-in and custom post type separately with a straight forward drag-and-drop interface.

Video Player WordPress Plugin – DEMO

This wordpress plugin will help you administrate the entire video player using a very friendly interface. You’ll be able to customize the player look & feel, playlist and CSS file.

Any type of video file that Flash Player supports can be played with this player:
– FLV /H.264 encoded video : MP4 , M4V, M4A , MOV, Mp4v, F4V
– YOUTUBE
– RTMP (using FMS or RED5 ) and RTMP live streaming

You can set this player to any size you want in wp-admin, changing the player width, the player height and the playlist width. You can easy integrate this in your pages using a shortcode.

960 Grid System Shortcode – DEMO

best wordpress plugins

Do you have a 960 grid system installed in your WP theme? By using this plugin, writing the post/page content is become very easy. No more typo-error and no need to remember one_fourth, two_third_first or first_for_the_last. You just need to know your grid number for your content such as 9 grids content with sidebar for 12 grid system.

Roo Link Directory – DEMO

Roo Link Directory is a full-featured, compact and quick to set up business link directory plugin for WordPress which allows users to add their sites or businesses to your directory based on multiple criteria.

WordPress Message Bar – DEMO

The Message Bar is a professional and elegant plugin that adds a message bar to your pages.

Facebook Walleria – DEMO

facebook wall best wordpress plugins

Facebook Walleria is a WordPress Plugin that embeds a number of Facebook Objects into your website. It uses the Facebook Graph to pull information about Albums, Photos, Feed, Comments, Events and presents the information on your website in a sleek style.

Instead of doing a double job of updating your site and Facebook profile, Facebook Walleria enables you to update your albums, events and feed on Facebook with the changes appearing in real-time on your website.

Facebook sharing for logged in Facebook users is also integrated with Events and Wall allowing interactivity with your visitors. Commenting and Liking has also been enabled on the Wall, thus your visitors can make comments on topics on your feed without leaving your website.

SocialBox – Social WordPress Widget – DEMO

socialbox best wordpress plugins

With SocialBox you get an absolutely easy to use WordPress Plugin which enables you to add a sleek social widget to your WordPress site or blog. It displays the current numbers of Facebook likes, Twitter followers and YouTube Channel and Feedburner Feed subscriptions. You can enter default values which will be shown if the related API is not reachable.

CSS3 Web Pricing Tables Grids – DEMO

pricing tables best wordpress plugins

This is a pack of pure CSS3 Web Pricing Tables Grids For WordPress with 2 table styles and 12 predefined color versions including hover states.

Security Ninja – DEMO

security ninja

This plugin combines years of industry’s best practices on security in one plugin. It has been featured on CodeCanyon – check it out.

WPSubscribers – Best WordPress Plugins – DEMO

wpsubscribers

If your serious about list building and adding a large group followers to your website you need a good list building plugin. There is a lot of them to choose from and I won’t be the judge here, but I think this is one of the best WordPress plugins. It give your visitors multiple  chances to connect with you increasing the chances of getting an opt-in.

Events Calendar – Best WordPress Plugins – DEMO

Events Calendar

Events Calendar are great best WordPress plugins for developing a system of event-style posts. Once installed WordPress will create a custom Events post type for your new calendar system! Each scheduled object can connect into a location through Google Maps and offers support for multinational time zones and languages.

UberMenu – Top Megamenu – DEMO

ubermenu Best WordPress Plugins

UberMenu is a user-friendly, highly customizable mega menu ( or mega drop down menu ) best WordPress plugins. It works out of the box with the WordPress 3 Menu Management System, making it simple to get started but powerful enough to create highly customized and creative mega menu configurations.

uBillboard – Premium Slider for WordPress – DEMO

ubillboard best wordpress plugins

uBillboard are slider best WordPress plugins. We have been developing sliders for our WordPress themes for over a year now, and all that experience has been distilled into this one slider plugin. It is a premium quality jQuery-based slider with a nicely polished WordPress admin.

Styles with Shortcodes for WordPress – DEMO

Best WordPress Plugins shortcodes

Have you ever been in the situation where you have a great looking WordPress theme, but you are missing some custom styling for different elements? Maybe you don’t know PHP , CSS and Javascript and are not able to implement the cool feature you are missing. Styles with Shortcodes is the solution for this problem. These best WordPress plugins lets you customize content faster and easier than ever before by using Shortcodes. Choose from 100 built in Shortcodes.

Video Gallery WordPress Plugin – DEMO

video gallery Best WordPress Plugins

The most advanced stock video gallery in the world! Now as one of the best WordPress plugins!

 

 

uPricing – Pricing Table for WordPress DEMO

Best WordPress Plugins Shopping upricing

uPricing is a pricing table for WordPress. We have been developing it for our WordPress themes, but have decided to release it as a standalone best wordpress plugin. It is a premium quality Pricing Table with a nicely polished WordPress admin.

WP Robot – Unique Autoblogging Plugin – DEMO

WP robot Best WordPress Plugins

A premium WordPress plugin that permits the administrator to automatically add content and posts to his/her WordPress blog. Currently this best WordPress plugins for autoblogging can add, translate, and rewrite content from RSS feeds, Amazon, eBay, Yahoo, YouTube, Flickr, ClickBank and more.

 

Gravity Forms – DEMO

Gravity Forms Best WordPress Plugins

Build and publish your WordPress forms in just minutes. No drudgery, just quick and easy form-building. Select your fields, configure your options and easily embed forms on your WordPress powered site using the built-in tools.

AJAX Contact Forms – DEMO

AjaxContact Forms Best WordPress Plugins

A slick jQuery-based contact form plugin powered by AJAX. Best WordPress plugins  that brings style to your plain contact form and reduces page loading. While it’s not as elaborate as the Gravity Forms plugin it gets the job done and makes for a nice upgrade from your free contact form plugin.

DDSlider – Best WordPress Plugins – DEMO

ddslider-wp-plugin Best WordPress Plugins

DDSliderWP features everything that the jQuery plugin already offered PLUS a custom admin panel, with total management of slides. These best wordpress plugins is worth investigating.

VidEmbed – DEMO

vid-embed

VidEmbed is a powerful simple to use solution to adding videos inline within your WordPress posts, pages, and widget areas. With support for both self-hosted videos as well as YouTube and Vimeo you can quickly add videos from many sources. With the explosion of media on the web it is important to be able to easily and quickly provide video content to your site visitors.

Twitter Widget Pro – DEMO

twitter-widget-pro Best WordPress Plugins

With the premium Twitter plugin for WordPress you’re able to link multiple Twitter accounts to display your latest tweets, favorites, or retweets. Additionally these best wordpress plugins will display user avatars and links for hashtags if you so choose! A powerful caching system is running behind-the-scenes to reduce calls into Twitter’s databases.

WP Geo Tagger – best plugin WordPress – DEMO

 Best WordPress Plugins geo-tagger

The WP Geo Tagger plugin can be used to add your current location to posts or to add an event location, so your readers can get directions in a snap. It even integrates Google Maps right on your posts!

Dynamic Step Process Panels – DEMO

dynamic process panels

Dynamic Step Process Panels for WordPress is one of the more confusing plugins. It’s premium-themed base costs only $25 and allows you to generate dynamic AJAX content in tabbed form. This may include bulleted content, photos, videos, product descriptions, or anything else. These are truly  multipurpose best wordpress plugins with resources available to those who understand WordPress’ systems.

Extended Google Analytics – DEMO

extended google analytics

With Extended Analytics you’re given Dashboard stats for key page events and traffic data. Additionally if you run an AdSense account it’s possible to tie in your earnings ID targeting keywords for ad links.

Special Recent Posts PRO – DEMO

Special Recent Posts PRO is a very powerful plugin/widget for WordPress which displays your recent posts with thumbnails.

It’s the perfect solution for online magazines or simple blogs and it comes with more than 60+ customization options available. You can dynamically re-size thumbnails to any desired dimension, drag multiple widget instances and configure each one with its specific settings. You can also use auto-generated PHP code/shortcodes to insert the widget in any part of your theme.

Portfolio for WordPress – DEMO

portfolio best wordpress plugins

With this script you can easily manage your portfolio (images and videos) items on your website. Because this plugin uses a custom post type to manage your portfolio this is a very clean and powerfull way to build a portfolio into your website.

Magic Members – Best WordPress Plugins – DEMO

Best WordPress Plugins Magic Members

A premium WordPress membership plugin that allows you to create a closed site that’s only available to paying members. It offers lots of great features to totally customize your WP site and transform it into a professional premium content members-only website that’s easy to use. Magic Members best WordPress plugins also allows you to sell your posts and downloads separately.

Visual Composer – Shortcode Plugin – DEMO

composer best wordpress plugins
Visual Composer best WordPress Plugins will save you tons of time working on the site content. Now you’ll be able to create complex layouts within minutes!

WordPress Email Newsletter Plugin – DEMO

Best WordPress Plugins email plugin

The email newsletter plugin is an advanced bulk emailer designed especially for WordPress 3. It is very easy to use and feature rich. Heaps of features which allow you to quickly send professional newsletters to your existing wordpress user database.

Vaultpress

Vaultpress Best WordPress Plugins

Vaultpress is premium backup service for WordPress, brought to you by Autommatic, creator of WordPress. Vaultpress backups your blog’s database, theme files and plugins, keeping multiple revisions (real time) so you can always revert back to any prefered copy.

WordPress Shopping Cart Plugin – DEMO

Best WordPress Plugins Shopping Cart Plugin

A premium WordPress shopping cart plugin built by Tribulant that allows the WP blog admin to sell both digital and physical goods online plus any services the admin decides to offer. Such services may include online teaching courses, hands on training, premium support, or any other non-product related sales that are service oriented. Using this premium wordPress plugin you can easily find ways to monetize your WP blog whether it’s through selling digital products like ebooks, selling online services, or selling any tangible goods.

Subscribers Magnet – DEMO

Subscribers magnet

Created by MaxBlogPress, these best WordPress plugins allows you to easily integrate email list sign-up forms into nearly every section of your current WP site. Doing so helps you grow your email based newsletter subscription and earn more revenue from your website. Growing a well targeted email subscription list is highly desired by online publishers because it’s one of the best marketing tools available, it increases the probability of additional purchases, and it encourages customer loyalty.

DirectoryPress – DEMO

Directory Press Best WordPress Plugins

A premium WordPress directory plugin that transforms your plain WP install into a revenue generating professional online directory website. The script includes several different template themes that vary in color and layout which can be customized to fit nearly any need.

WP Review Plugin – DEMO

myreviewplugin best wordpress plugins

This is a great WordPress-powered review plugin. MyReviewPlugin turns WordPress in to a one-click review site with star ratings, editor ratings, custom fields, automatic embedding, automatic plugin installation, 3 great themes and more. Truely one of the best WordPress plugins available on the market if you publish reviews on your website.

TotalFeedback – Get to know what your visitors think – DEMO

totalfeedback wordpress plugin

Analytics and statistics tell only half the story. To understand why your site isn’t performing as well as it should, you need actual feedback from real users.

Enter Total Feedback – a plug-in for WordPress that allows you to create unlimited polls that appear in small unobtrusive popup in the timing of your choosing. The poll collects feedback from your visitors so you can eliminate guesswork and know exactly what to do to improve your site.

Best WordPress Plugins – please leave a comment

 

Author : Dustin Betonio

Dustin Betonio is a Translation Management graduate at University of Mindanao. His earlier career was devoted on customer service outside the information highway. Currently studying Law in the same University.

 

Plugin to Remove Comments Completely from WordPress

The comment feature in WordPress is an essential component of blogs - but not in all cases it's needed, especially if you use it as a traditional CMS.

Sure, you can just leave out the comment form while you creating a theme and disable the comment options in your backend. But this is not the best way for everyone. In such a case, I turn the comments off completely, making sure that the posts can not have that option and also remove the fields for the comments in the backend. That way the user gets exactly what he needs. Meanwhile, I have needed this so often that I created a small Plugin and I'm able to immediately „switch off“ the functions and comment areas. If there are major adaptations, I create them via Plugin or use my existing Plugin Adminimize.

One or the other will have some ideas or know some improvements for the Plugin - go to github and fork it or improve it, I would like to hear some feedback.
In the following screenshot I marked a few areas that are gone now. In the content editor of posts, pages or other post types the Metaboxes for comments, discussion and trackbacks are gone. More screenshots, what else is gone can be seen on my Repository.

On Dashboard without comments

Download link and links to the latest code are on github: Bueltge / Remove-Comments-Absolute. The following code is for a quick reading and represents only the first level. Updates or maintenance will take place on GitHub.

<?php
/**
 * Plugin Name: Remove Comments Absolutely
 * Plugin URI: http://bueltge.de/
 * Text Domain: remove_comments_absolute
 * Domain Path: /languages
 * Description: Deactivate comments functions and remove areas absolutely from the WordPress install
 * Author: Frank Bültge
 * Version: 0.0.2
 * Licence: GPLv2
 * Author URI: http://bueltge.de
 * Upgrade Check: none
 * Last Change: 08.06.2011
 */
if ( ! class_exists( 'Remove_Comments_Absolute' ) ) {
        add_action( 'plugins_loaded', array( 'Remove_Comments_Absolute', 'get_object' ) );
        class Remove_Comments_Absolute {
                static private $classobj = NULL;
                /**
                 * Constructor, init on defined hooks of WP and include second class
                 *
                 * @access  public
                 * @since   0.0.1
                 * @uses    add_filter, add_action
                 * @return  void
                 */
                public function __construct () {
                        add_filter( 'the_posts', array( $this, 'set_comment_status' ) );
                        add_filter( 'comments_open', array( $this, 'close_comments'), 10, 2 );
                        add_filter( 'pings_open', array( $this, 'close_comments'), 10, 2 );
                        add_action( 'admin_init', array( $this, 'remove_comments' ) );
                        add_action( 'admin_menu', array( $this, 'remove_menu_items' ) );
                        add_filter( 'add_menu_classes', array( $this, 'add_menu_classes' ) );
                        add_action( 'admin_head', array( $this, 'remove_comments_areas' ) );
                        add_action( 'wp_before_admin_bar_render', array( $this, 'admin_bar_render' ) );
                }
                /**
                 * Handler for the action 'init'. Instantiates this class.
                 *
                 * @access  public
                 * @since   0.0.1
                 * @return  object $classobj
                 */
                public function get_object () {
                        if ( NULL === self :: $classobj ) {
                                self :: $classobj = new self;
                        }
                        return self :: $classobj;
                }
                /**
                 * Set the status on posts and pages - is_singular ()
                 *
                 * @access  public
                 * @since   0.0.1
                 * @uses    is_singular
                 * @param   string $posts
                 * @return  string $posts
                 */
                public function set_comment_status ( $posts ) {
                        if ( ! empty( $posts ) && is_singular() ) {
                                $posts[0]->comment_status = 'closed';
                                $posts[0]->post_status = 'closed';
                        }
                        return $posts;
                }
                /**
                 * Close comments, if open
                 *
                 * @access  public
                 * @since   0.0.1
                 * @param   string | boolean $open
                 * @param   string | integer $post_id
                 * @eturn  string $posts
                 */
                public function close_comments ( $open, $post_id ) {
                        // if not open, than back
                        if ( ! $open )
                                return $open;
                        $post = get_post( $post_id );
                        if ( $post -> post_type ) // all post types
                                return FALSE;
                        return $open;
                }
                /**
                 * Change options for dont use comments
                 * Remove meta boxes on edit pages
                 * Remove support on all post types for comments
                 *
                 * @access  public
                 * @since   0.0.1
                 * @uses    update_option, get_post_types, remove_meta_box, remove_post_type_support
                 * @return  void
                 */
                public function remove_comments () {
                        // int values
                        foreach ( array( 'comments_notify', 'default_pingback_flag' ) as $option )
                                update_option( $option, 0 );
                        // string false
                        foreach ( array( 'default_comment_status', 'default_ping_status' ) as $option )
                                update_option( $option, 'false' );
                        // all post types
                        // alternative define an array( 'post', 'page' )
                        foreach ( get_post_types() as $post_type ) {
                                // comment status
                                remove_meta_box( 'commentstatusdiv', $post_type, 'normal' );
                                // remove trackbacks
                                remove_meta_box( 'trackbacksdiv', $post_type, 'normal' );
                                // remove all comments/trackbacks from tabels
                                remove_post_type_support( $post_type, 'comments' );
                                remove_post_type_support( $post_type, 'trackbacks' );
                        }
                        // remove dashboard meta box for recents comments
                        remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
                }
                /**
                 * Remove menu-entries
                 *
                 * @access  public
                 * @since   0.0.2
                 * @uses    remove_meta_box, remove_post_type_support
                 * @return  void
                 */
                public function remove_menu_items () {
                        // Remove menu entries with WP 3.1 and higher
                        if ( function_exists( 'remove_menu_page' ) ) {
                                remove_menu_page( 'edit-comments.php' );
                                remove_submenu_page( 'options-general.php', 'options-discussion.php' );
                        } else {
                                // unset comments
                                unset( $GLOBALS['menu'][25] );
                                // unset menuentry Discussion
                                unset( $GLOBALS['submenu']['options-general.php'][25] );
                        }
                }
                /**
                 * Add class for last menu entry with no 20
                 *
                 * @access  public
                 * @since   0.0.1
                 * @param   array string $menu
                 * @return  array string $menu
                 */
                function add_menu_classes ( $menu ) {
                        $menu[20][4] .= ' menu-top-last';
                        return $menu;
                }
                /**
                 * Remove areas for comments in backend via JS
                 *
                 * @access  public
                 * @since   0.0.1
                 * $return  string with js
                 */
                public function remove_comments_areas () {
                        ?>
                        <script type="text/javascript">
                        //<![CDATA[
                        jQuery(document).ready( function($) {
                                $( '.table_discussion' ).remove();
                        });
                        //]]>
                        </script>
                        <?php
                }
                /**
                 * Remove comment entry in Admin Bar
                 *
                 * @access  public
                 * @since   0.0.1
                 * @uses    remove_menu
                 * $return  void
                 */
                public function admin_bar_render () {
                        // remove entry in admin bar
                        $GLOBALS['wp_admin_bar'] -> remove_menu( 'comments' );
                }
        } // end class
} // end if class exists
?>

on write post


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

New Plugin to Style your Plugin on WordPress Admin with Default Styles!

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.

You can find the Plugin in Github and it would be great if you expand it, add new ideas and possibilities to it: - github.com/bueltge/WordPress-Admin-Style


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

Plugin To Add Custom Field To An Attachment In WordPress

5 Day
The media library is on WordPress in some areas, certainly not perfect, but it has great potential. Each attachment can contain various metadata and also WordPress stores some data directly while uploading - for example a part of the Exif data of an image.

However, it might not be enough for you and you need some additional custom data with the attachment, whether in order to control something in the backend of WordPress, or even display the data in the front end to the image. So here is a small tutorial how to add an additional field. You can use this solution directly and adding a new field with the help of a Plugin.

For the output of the data I present a simple method that can be adjusted accordingly. To read the data, which is assigned to the attachment, there are many functions provided by WordPress and enables you to realize so many amazing things - depending on knowledge and skills of the developer - such as related articles.

The above screenshot shows what we are aim for. An additional field with the name Example Custom Field, also an input field and a description below the field.

Add the Custom Field

First we create a function, which outputs the 3 new fields in the attachment area. These fields are getting delivered in an array and then via the according hook attachment_fields_to_edit integrated in WordPress.

// Add a custom field to an attachment in WordPress
function fb_attachment_fields_edit($form_fields, $post) {
        $form_fields['custom_example']['label'] = __( 'Example Custom Field', FB_AAF_TEXTDOMAIN );
        $form_fields['custom_example']['value'] = get_post_meta($post->ID, '_custom_example', true);
        $form_fields['custom_example']['helps'] = __( 'A helpful text for this field.', FB_AAF_TEXTDOMAIN );
        return $form_fields;
}

Save the custom values

Now that we have completed the data fields, we must take care about saving the values. For this case WordPress provides the hook attachment_fields_to_save, so that you only need to hook in the memory function.

// save custom field to post_meta
function fb_attachment_fields_save($post, $attachment) {
        if ( isset($attachment['custom_example']) )
                update_post_meta($post['ID'], '_custom_example', $attachment['custom_example']);
        return $post;
}

Hook to work in WordPress

The two functions, explained before, providing the necessary functions and now we are going to integrate it into WordPress. Here a short explanation with the help of these two filter hooks. In both cases, our functions passing two parameters to the hooks of WordPress and they are passed with the default value of priority 10. Everything goes through one filter in WordPress and therefore to hook on the respective Filter-Hook (add_filter) attachment_fields_to_*. The transfer via array array(&$this, ... takes place here only because everything is used in connection within a class.

add_filter( 'attachment_fields_to_edit', array(&$this, 'fb_attachment_fields_edit'), 10, 2);
add_filter( 'attachment_fields_to_save', array(&$this, 'fb_attachment_fields_save'), 10, 2);

The Example Plugin

Now we incorporate the functions and their hooks in a Plugin and we can simple use the additional functions inside of WordPress. I think the separation of additional functions in Theme and Plugin is very important because the priority of integration is different and because from my point of view function expansions in a Theme are useful only if they are just additional functions for the Theme and not for WordPress.
Also the use via class is useful, because of a cleaner code. But there are enough articles about the benefits of object-oriented programming and the usage of classes.

<?php
/**
 * @package Add Attachment Fields
 * @author Frank Bültge
 */
/*
Plugin Name: Add Attachment Fields
Plugin URI: http://bueltge.de/
Text Domain: add_attachment_fields
Domain Path: /languages
Description: Example for add a custom field to an attachment in WordPress
Author: Frank Bültge
Version: 0.0.1
Author URI: http://bueltge.de/
Donate URI: http://bueltge.de/wunschliste/
License: GPL
Last change: 24.11.2010 10:21:19
*/
/**
License:
==============================================================================
Copyright 2009/2010 Frank Bueltge  (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Requirements:
==============================================================================
This plugin requires WordPress >= 2.7 and tested with PHP Interpreter >= 5.2.9
*/
//avoid direct calls to this file, because now WP core and framework has been used
if ( !function_exists('add_action') ) {
        header('Status: 403 Forbidden');
        header('HTTP/1.1 403 Forbidden');
        exit();
} elseif ( version_compare(phpversion(), '5.0.0', '<') ) {
        $exit_msg = 'The plugin require PHP 5 or higher';
        header('Status: 403 Forbidden');
        header('HTTP/1.1 403 Forbidden');
        exit($exit_msg);
}
if ( !class_exists('add_attachment_fields') ) {
        //WordPress definitions
        if ( !defined('WP_CONTENT_URL') )
                define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
        if ( !defined('WP_CONTENT_DIR') )
                define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
        if ( !defined('WP_PLUGIN_URL') )
                define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');
        if ( !defined('WP_PLUGIN_DIR') )
                define('WP_PLUGIN_DIR', WP_CONTENT_DIR.'/plugins');
        if ( !defined('PLUGINDIR') )
                define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH.  For back compat.
        if ( !defined('WP_LANG_DIR') )
                define('WP_LANG_DIR', WP_CONTENT_DIR . '/languages');
        // plugin definitions
        define( 'FB_AAF_BASENAME', plugin_basename(__FILE__) );
        define( 'FB_AAF_BASEDIR', dirname( plugin_basename(__FILE__) ) );
        define( 'FB_AAF_TEXTDOMAIN', 'add_attachment_fields' );
        class add_attachment_fields {
                function __construct() {
                        if ( !is_admin() )
                                return FALSE;
                        add_action( 'init', array(&$this, 'text_domain') );
                        add_filter( 'attachment_fields_to_edit', array(&$this, 'fb_attachment_fields_edit'), 10, 2);
                        add_filter( 'attachment_fields_to_save', array(&$this, 'fb_attachment_fields_save'), 10, 2);
                }
                function text_domain() {
                        load_plugin_textdomain( FB_AAF_TEXTDOMAIN, false, FB_AAF_BASEDIR . '/languages' );
                }
                // Add a custom field to an attachment in WordPress
                function fb_attachment_fields_edit($form_fields, $post) {
                        $form_fields['custom_example']['label'] = __( 'Example Custom Field', FB_AAF_TEXTDOMAIN );
                        $form_fields['custom_example']['value'] = get_post_meta($post->ID, '_custom_example', true);
                        $form_fields['custom_example']['helps'] = __( 'A helpful text for this field.', FB_AAF_TEXTDOMAIN );
                        return $form_fields;
                }
                // save custom field to post_meta
                function fb_attachment_fields_save($post, $attachment) {
                        if ( isset($attachment['custom_example']) )
                                update_post_meta($post['ID'], '_custom_example', $attachment['custom_example']);
                        return $post;
                }
        }
        function add_attachment_fields_start() {
                new add_attachment_fields();
        }
        add_action( 'plugins_loaded', 'add_attachment_fields_start' );
}
?>

Example to use the values on Frontend or Plugins

Additional to the Plugin, I have a small solution to output the meta data of the attachment. But I also recommend to read the previously mentioned article, as you can get far more information there.

$attachments = get_children( array(
                'post_parent'    => get_the_ID(),
                'post_type'      => 'attachment',
                'numberposts'    => 1, // show all -1
                'post_status'    => 'inherit',
                'post_mime_type' => 'image',
                'order'          => 'ASC',
                'orderby'        => 'menu_order ASC'
        ) );
foreach ( $attachments as $attachment_id => $attachment ) {
        echo get_post_meta($attachment_id, '_custom_example', true);
}

A practical example - photographer and its URL - has been recently posted by Thomas Scholz on WordPress Answers. A nice usage for this possibility.


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

debugConsole with WordPress


For debugging inside of WordPress there are different approaches and preferences. I like xDebug and in some cases I use FirePHP. Now there is another possibility which I had to test at least once - debugConsole - I like it.

The debugConsole is a tool for debugging and tracing PHP5 applications on productive servers without compromising the live-traffic.

The features

  • access features
  • variable inspector
  • variable watches
  • replace PHP's errorhandling
  • timer clock
  • checkpoint management
  • and other features
    • filter events
    • log console output into logfiles additionally to or instead of the popup
    • configure dimensions and design of console window
    • color-coded events for quicker overview

So I created a little Plugin to play and test the console.
Currently I have only created a demo Plugin which shows the function. It won't be maintained, but can be downloaded here. As a small start and quick look at the possibilities I used the examples of the author of the debugConsole.

The Plugin has the following source code and you can add to any URL of the WP-installation the string ?debug=true, so that the popup called with the information of the console. Currently this is possible for frontend and backend.

<?php
/*
Plugin Name: debugConsole
Plugin URI: http://bueltge.de/
Text Domain: debugconsole
Domain Path: /languages
Description: The <a href="http://www.debugconsole.de/">debugConsole</a>
is a tool for debugging and tracing PHP5 applications on productive servers
without compromising the live-traffic. Add <code>?debug=true</code> to the URL for see
the Popup-Window with debugConsole
Author: Frank Bültge
Version: 0.1
Author URI: http://bueltge.de/
Donate URI: http://bueltge.de/wunschliste/
License: Apache License
Last change: 14.10.2010 11:30:51
*/
/**
License:
==============================================================================
Copyright 2010 Frank Bueltge  (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Requirements:
==============================================================================
This plugin requires WordPress >= 2.7 and tested with PHP Interpreter >= 5.2.9
*/
/* PHP5 required */
if (version_compare(PHP_VERSION, '5.0.0') < 0) {
        die('The debugConsole requires PHP 5.x.x or greater.');
}
/* load debugConsole functionality */
require_once 'debugconsole-1.3.0/debugConsole.php';
// add ?debug=true to the URL
if ( isset($_GET['debug']) && $_GET['debug'] == 'true') {
        add_action( 'wp_footer', 'wp_debug_console' );
        add_action( 'admin_footer', 'wp_debug_console' );
}
function wp_debug_console() {
        /**
        * debugConsole demonstration
        *
        * This script demonstrates each feature of the debugConsole. The
        * debugConsole is a PHP5 class using JavaScripts to show debug
        * information in a popup window. The popup has IP-based access
        * control. Configurate everything in debugConsole.config.php.
        * Additionally, PHP's default errorhandler is replaced.
        *
        * @author Andreas Demmer <[email protected]>
        * @version 1.0.1
        * @package debugConsole_1.2.0
        */
        /*
        Now you got an extended commandset:
        dc_watch()           watch variable changes in console
        dc_dump()            var_dump variables in console
        dc_here()            mark checkpoints in console
        dc_start_timer()     measure a timespan
        dc_stop_timer()      output timespan in console
        */
        /* test watches */
        dc_watch('foo');
        declare (ticks = 1) {
                $foo = '1';
                $foo++;
                /* test checkpoints */
                dc_here('The interpreter passed through here!');
                /* test timer clock */
                $myTimer = dc_start_timer('Measure an one second sleep:');
                sleep(1);
                dc_stop_timer($myTimer);
                /* test variable debugging */
                $bar = 42.0;
                dc_dump($bar, '$bar tells us the meaning of life:');
                $foobar = array (
                                'foo' => $foo,
                                'bar' => $bar
                );
                dc_dump($foobar, '$foobar is a neat array!');
                /* test errorhandling */
                echo $notSet;
                fopen('not existing!', 'r');
        }
}
?>

Download as zip-file: debugConsole.zip - 131 kByte


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




bt bt
Designed by Wbcom Designs
#