How to use namespaces with wp plugins
-
Hi!
I created class Includes.php in theme and created the same file in my plugin and I see only one file is included that that is belonged to plugin.How I can use the same classes in each plugin and each theme without rename them???
This classes are using for create structure, and both have equal structure like this
<?php if(!class_exists('Includes')){ class Includes{ function __construct(){ add_action( 'wp_enqueue_scripts', array(&$this, 'includeScripts') ); } function includeScripts(){ $this->includeCss(); $this->includeJavaScripts(); } function includeCss(){ // include parent style wp_enqueue_style( 'style', get_template_directory_uri().'/public/css/style.css' ); } function includeJavaScripts(){ wp_deregister_script( 'jquery' ); wp_enqueue_script( 'jquery', get_template_directory_uri().'/public/js/jquery-3.2.1.min.js', null, '3.2.1', false ); wp_enqueue_script( 'public', get_template_directory_uri().'/public/js/public.js', array('jquery'), '1.0.0', true ); // wp_enqueue_script( 'jquery' ); } }//Includes new Includes(); } ?>
it is theme file, for plugin I use equal class only differ files and I’m going use the same classes for each next plugin, but it doesn’t work….
Who know how to reuse created code?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to use namespaces with wp plugins’ is closed to new replies.