Articles of constants

Can't we use strings defined as PHP constants if we want to translate them in a plugin?

I want to translate constant strings in my plugin defined as: define( ‘CONSTANT’, __( ‘string-A’, ‘textdomain’ ) ); And later using it somewhere like: $x= ‘<h4>’.CONSTANT_NAME.'<h4>’; echo $x; But I am still getting English text even after adding that locale’s .mo file & the text-domain. This is happening only for strings defined by PHP constants, […]

How can I append blog_id to … echo ?

I use ‘constants‘ a lot. I set them in functions.php like define(‘mytheme_town’, ‘Orlando’); and then call them into the theme <?php echo mytheme_town ; ?>. It’s simple and easy. But I need them to be site-specific (for multisite) so I thought it might be possible to append the current blog_id to the theme call and […]

How to define constant before plugin

This question already has an answer here: In what order does WordPress load plugin files? 2 answers

Synchronizing Two WordPress Sites Content

I’ve googled a lot, and I do have found answers at WordPress SE and at However, the answers are somewhat incomplete or doesn’t work at all. Here I’ll explain my problem in detail, give my progress on the problem and the obstacles I’m facing in solving the problem. Assumptions:- Plugins and themes at both […]

get plugin directory url

I am trying to use SMOF Options Framework in a plugin and i have this problem. SMOOF use this constants to get theme directory url: if( !defined(‘ADMIN_PATH’) ) define( ‘ADMIN_PATH’, get_template_directory() . ‘/admin/’ ); if( !defined(‘ADMIN_DIR’) ) define( ‘ADMIN_DIR’, get_template_directory_uri() . ‘/admin/’ ); But i want to use SMOF in a plugin, not in theme, […]

Update the value of a constant

I have a file containing all the constants used in the plugin. For example, I have a variable in one of my file define(‘APPOINTMENTS_DEFAULT_ENABLE_PAYPAL’, 1); I have a checkbox in admin area where user can enable or disable the paypal feature. This is the checkbox code: <input type=”checkbox” name=”enable_paypal” size=”40″ value=””/> Issue: Can anybody please […]

is there a benefit in using a constant over get_stylesheet_directory_uri?

Is there any benefit perfomance wise when defining a constant in the wp-config.php like so <php define(‘PATH_TO_THEME’, get_stylesheet_directory_uri() ); ?> and then referring to PATH_TO_THEME instead using get_stylesheet_directory_uri() multiple times? I got this from a wordpress handbook, saying that when you call this function multiple times it consumes more performance in comparison to using a […]

Autosave interval remains default despite wp-config.php defines

On site which I maintain there are writers that spend a lot of time editing single posts, and autosave every minute is very painful for them. So they asked me to set it to at least 10 minutes. I found an official way to change autosave interval, so I’ve put this line in wp-config (at […]

URL for images folder on Multisite

I am developing a theme locally on a local multisite installation and trying to change the default gravitar with the following function: function custom_gravitar ($avatar_defaults) { $myavatar = get_bloginfo(‘template_directory’) . ‘/img/gravitar.gif’; $avatar_defaults[$myavatar] = “Custom gravitar”; return $avatar_defaults; } add_filter( ‘avatar_defaults’, ‘custom_gravitar’ ); The path that is output is but my local url is http://localhost/my-site-folder/ […]

How can I change the language of automated Mails?

I’ve got a problem with translations, that sounds pretty simple, but I can’t find a way around this. The Situation I got a software running on WordPress, and I need to send Emails to my users after certain actions. The contents of these Mails has been localized using __() and all the other built in […]