add_action in namespace not working

Before going too far down this path I would suggest that you familiarize yourself with PHP name resolution rules. To answer your actual question – When you namespace functions, the fully qualified name of those functions includes the namespace. In your example, you have defined two functions: \myPlugin\add_activation_notice and \myPlugin\activation_notice. When calling either of these … Read more

Using a plugin class inside a template

The best way to use your class without knowing the object is an action. You register the action before the theme files for presentation are loaded, WordPress will handle the rest. Sample code: <?php # -*- coding: utf-8 -*- /** * Plugin Name: Plugin Action Demo */ add_action( ‘init’, array ( ‘Plugin_Action_Demo’, ‘init’ ) ); … Read more

How to name files of namespaced classes?

First, ignore the class- prefix. This comes from WordPress’ pure procedural code approach, classes are used as containers for procedural code, not for real objects, and most files do not contain classes at all or classes and other code together. It doesn’t make sense when all of your files contain just one class and nothing … Read more

Get menu object from theme_location

This method looks like what you’re looking for, using get_nav_menu_locations() and get_term(): $theme_locations = get_nav_menu_locations(); $menu_obj = get_term( $theme_locations[$theme_location], ‘nav_menu’ ); $menu_name = $menu_obj->name; (See the link for the whole thing wrapped up in a custom function; the above code just highlights the relevant WP functions for getting what you’re after.)

How to use classes declared in another plugin?

You have to check if the class exists, but before that you have to wait that all plugin are loaded: no one can assure that your plugin is loaded after WooCommerce. For run a code from plugin when all plugin are loaded hook into plugins_loaded hook. Be aware that you cannot use this hook in … Read more

Will WordPress become completely OOP?

I can say with about 99.9999% certainty that WordPress will never become completely OOP in future version, not the least of which is that the topic has come up time and again on the wp-hackers list and the core team members has expressed no interest in doing so. As I look at my personal experience … Read more

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