WordPress Functions

The following are a number of functions within WordPress that we utilized, with examples.

__

string __( string $text [, string $domain ])

Retrieves the translated string into the current locale. The $domain is "default" by default, but when authoring your own plugin, you should define your own text domain.

Example:

print __('Hello', 'my_text_domain'); // Might print "Hola" in a Spanish speaking locale.

_e

_e( $text, $domain )

Prints the translated string into the current locale. The result is the same as if you had done:

echo __('your-string');

add_action

add_action( $event, $function_to_add, $priority, $accepted_args );

Hooks an action event to a user-defined callback function; normally, no values are returned from these callback functions. ...

Get WordPress 3 Plugin Development Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.