How can I initialize inside wordpress a class. I would like to send requests via ajax to plugins class. First I have the entry point.
class EntryClass{
public function __construct()
{
add_action( 'wp_enqueue_scripts', array($this , 'wptuts_scripts_basic' ) );
add_shortcode( 'podukt_konfigurator', array ($this, 'getProd_Config') );
}
function getProd_Config() {
ob_start();
include( 'html/templ_config.php');
$content = ob_get_contents();
ob_end_clean();
return $content;
}
function wptuts_scripts_basic()
{
// Register the script like this for a plugin:
wp_register_script( 'konf-js', plugins_url( 'config.js', __FILE__ ) );
}
}
$init= new EntryClass();
The templ_config.php
contains the Javascript which on event would load a php file inside of my plugin folder like
jQuery('#id').load(
'/wordpress/wp-content/plugins/konfigurator/html/class.konfigurator.php',
{
prod_detail: jQuery(this).attr('rel')},
function(msg){
show_driver(msg);
}
);
then in class.konfigurator.php
I would like to use wordpress globals.
global $WP_VAR_NAME;
then you can work with it. Or use the 'shorthand' like$GLOBALS['VAR_NAME']
.global $wpdb; $wpdb->WHATEVER;
. But I don't get the context of this and instantiating a class and all...