Use theme constants in plugin?

TEMPLATEPATH and STYLESHEETPATH will be deprecated in the near future. It is not safe to rely on these constants. Use get_template_directory() and get_stylesheet_directory() instead. And wait until the init hook (or after_setup_theme before you use them to be sure all needed files are loaded. Example for a plugin: add_action( ‘after_setup_theme’, ‘wpse_50359_set_plugin_basics’ ); function wpse_50359_set_plugin_basics() { … Read more

How to use defined in class file with namespace

From the PHP manual on defining namespaces: Namespaces are declared using the namespace keyword. A file containing a namespace must declare the namespace at the top of the file before any other code – with one exception: the declare keyword. To fix the issue, simply make sure that your namespace declaration comes before the other … Read more

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

I think this is happening because Constants cannot be redefined later. Once they are set, they are fixed. http://php.net/manual/en/language.constants.php I’m not exactly sure how WP language constructs work, but part of me thinks that they are defined, then changed later on the fly when plugins/themes use them. I don’t have a reference for this but … Read more

get plugin directory url

Use plugin_dir_url( __FILE__ ); for the URL and plugin_dir_path( __FILE__ ); for the path. Pass the plugin’s main file to both functions to get similar results. Besides that, ADMIN_PATH and ADMIN_DIR are really poor names for custom code. They might result in collisions with other code in the future. Try to use better names, something … Read more

Syntax of FS_CHMOD_DIR and FS_CHMOD_FILE

The basic syntax for define() is: define ( $name, $value ) In the above definition, the value is: ( 0755 & ~ umask() ) The ‘&’ (ampersand) is the ‘And’ bitwise operator, the ‘~’ (tilde) is the ‘Not’ bitwise operator, and the umask() function returns the current umask. To answer your question in short (if … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)