Creating WP help tabs in admin, plugins or themes pages

WordPress has got a help manager very simple, just a couple of functions, so you can easily use it for creating help screen for your own developements. Learn you step by step how the WP help manager works, and how to use it.

Creating WP helps for your plugins and themes

But before beginning to create our own WP help pages, first we should see the internal structure of the WP help manager that, basically has just got two modules. Continue reading…

Selective enqueueing of WordPress scripts and styles through conditional loading

Both in front and back end, WordPress themes and plugins usually enqueue styles and scripts; the real cornerstone of the our work. Security systems, communications, silent or programmed operations, intelligent data process… Most of these common operations have in their backgrounds the loading of scripts and styles. Today we’re going to see how design a selective loading of these components.

Big, big tires

Habitually, the loading of scripts and styles is made by themes and plugins through the functions.php and the /root-plugin-folder/plugin-name.php files respectively. In both cases, usually there is (are) a little function in these php files that programmes the loading of all of these essential components. Continue reading…

How to change the WordPress post updated messages of the edit screen

WordPress posts edit interface has got a good information messages system for all user actions. It doesn’t matter what is the done action, WordPress talks to us: draft saved, post updated, published… Actually, it’s a perfect information system if regulary you only publish posts or sometimes a new page, ie, if you have just got a blog but, when your website has other kinds of information (films, cats, recipies, products…) WordPress keeps saying “post updated” and in fact, you are editing an actor’s profile, or a recipe, or whatever, but not a post… Would not it be awesome that WordPress says “Actor profile updated”, or “Recipe improved” or any message more like the natural language? So, if you don’t want that WordPress talks like a machine, you need use post_updated_messages.

Some examples of WordPress post updated messages on the edit screen

I’m sure that if your website talks about recipes, or actor profiles (whatever that is not a post), you are used to use the WP function register_post_type but probably you don’t know that there is another option that works together with register_post_type that allows us also to change the information messages related with these new kinds of information Continue reading…

Examples of adding fields to WordPress Metabox

A few days ago, we was talking about how to construct a WordPress metabox for a couple of fields, today we will extend that example with several examples of code for adding different kinds of fields.

Examples of adding fields to WordPress Metabox

The fields of a regular WordPress metabox are almost always constructed using a <p></p> HTML tag so, in general, the main structure of any field for a metabox should be like this. Continue reading…

Additional Fields to the WordPress Media Uploader

In general, WordPress Media Uploader module has enogh data fields for identifying perfectly any of its elements, images, videos or whatever however, some times, you need not just identifying, for example an image, but to add some information about the exact url source, technical data about the place where it was taken, the people that appears in a photo, etc. In this cases, you need to add some more data fields to the WordPress Media Uploader.

How to add additional fields to the WordPress Media Uploader

In this example, we’re going to suppose that we want to add the name of the place where a photo was taken and, for example, the name of the client for who we are working thus, two additional fields because. By the way, if you was thinking in adding fields to keep the technical information of the photo Continue reading…

Constructing WP themes or plugins that take into account future gender translations (2)

Few days ago I began a serie of articles about how to design a WordPress Theme that facilitates that in the future it is possible to make a translation that takes into account the gender. In the first article I suggested a little technique to mark the Post Type (and for extension Taxonomy) objects including a new property that keeps the gender of the object and that depends on the translation today I’m going to extend this technique also for the labels of the Post type inside the Admin interface.

The #superhero bathroom at  @CommonDesk #fordtx #digitaldallas

As we saw, the core of the first proposal consists of adding one more line inside the array that is used to register any post type Continue reading…

Checkbox fields in WordPress Metaboxes a solution for NULL values

Talking about forms, one of the most common issues is that checkbox fields don’t return any value when they are not checked. We just receive their values -usually TRUE- when they are checked but if they are unchecked they ‘say’ nothing. What can we do?

Checkbox fields in WordPress Metaboxes a solution for NULL values

This behavior of checkboxes fields is not an error, long time ago they was designed in that way (they are silent) however, in most cases,  this behaviour is a problem because the lacking of value doesn’t allow developers to know whether there is not actually a value, or if the value is actually FALSE. There is not difference between NOTHING and FALSE so Continue reading…

How to add a Metabox. A step by step approach. add_meta_box

The WordPress posts edit Tool is not an unique compact module that shows all the boxes that appear on the screen but it’s a set of different little modules –called metaboxes– working together. A little module controls the title, another one controls the visual editor, another one defines the publishing options and actions, another one is for the Post Format… the Categories, the Author’s post, etc. The reason of this modular design is to allow developers to introduce easily new boxes (or remove some ones) in the Edit Screen.

The Edit Screen of Posts and its different Metaboxes

So thanks to this modular design, we can create our metaboxes for adding new functionalities or data to the WordPress Posts Continue reading…

Changing the user’s Contact Info fields

By default, WordPress still maintains very old contact info fields for users so the most probable is that you want to improve them and, on the other hand, despite of some themes or plugins have already made this change, probably you don’t want either that these improvements depend on one installed theme or plugin but rather they always keep available.

Improving User’s Contact Info

So, in this example, we’re going to develope a simple plugin that makes three different things Continue reading…

Using wp_add_inline_script function. A Google Analytics example.

Until version version 4.4, in WordPress, there was only one way to add script files to the WordPress themes, the function wp_enqueue_script however, the new version 4.5 has introduced a new way, the function wp_add_inline_script that allows us to add javascript text scripts directly inside a template and that, in addition, it can be directly connected with other scripts. Let’s go to see how it works.

Example of using the wp_add_inline_script function

At bottom, this new function wp_add_inline_script is the equivalent for scripts files, to the wp_add_inline_script function is for CSS files. Let’s see how it works through and example based on adding the Google Analytics script to a WP theme. Continue reading…