WordPress-Plugin-Boilerplate
WordPress-Plugin-Boilerplate copied to clipboard
How to get instance of variables?
Hi, In this file iben-woocommerce-bank-options.php How can i get the plugin name after below function is fire?
function run_iben_woocommerce_bank_options() {
$plugin = new Iben_Woocommerce_Bank_Options();
$plugin->run();
}
run_iben_woocommerce_bank_options();
For example
$plugin->get_plugin_name();
or $this->get_plugin_name()
is not working
Thanks
is this right?
function run_iben_woocommerce_bank_options() {
$plugin = new Iben_Woocommerce_Bank_Options();
$plugin->run();
}
run_iben_woocommerce_bank_options();
/**
* Check if WooCommerce is activated
*/
add_action( 'plugins_loaded', 'checkWOO' );
function checkWOO(){
if ( class_exists( 'woocommerce' ) ) {
} else {
add_action( 'admin_notices', 'errormsg' );
}
}
GET INSTANCE AGAIN
$plugin_instance = new Iben_Woocommerce_Bank_Options();
$plugin_name = $plugin_instance->get_plugin_name();
if ( ! function_exists( 'errormsg' ) ) {
function errormsg($plugin_name) {
global $plugin_name;
$class = 'notice notice-error';
$message = sprintf( __( 'Error you did not meet the WP minimum version. %s', 'text-domain' ), $plugin_name);
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
}
}
Hi,
I'm a learning now. If I'm saying some crazy thing you guys can correct me.
What's is the debug of $plugin_instance? If the object is returned you need to check if the function get_plugin_name has protected or private type. If the method has those types you need to change or create a new function to have access and use.
If nothing is returned in $plugin_instance you need to check if your function is being fired before the class load.