wordpress - Autoloaders in PHP - two running at a time -
I understand how to register autoloaders and even how to create one, this is absolutely any There is no issue. Sometimes the main issue is how you have two auto loaders, for example:
class project_one_folder_class extended project_two_folder_class {} you 'Ll notice that child class is a project which is related to reaching out and calling parent class who is locating in a separate project.
The way in which two sections of projects are connected, always seen by auto loaders, sometimes the projects of any sections are never seen.
Edit In this way the way I thought was to write two auto loaders and to register them because
The project has two parents, the project is a child, this is a more detailed question.
This is my class to make it better.
class AisisCore_Loader_AutoLoader {secure $ _instance protected; Public function get_instance () {if (null == self :: $ _ example} {self :: $ _ instance = new self (); } Returns self: $ _ Example; } Public functions reset_instance () {self :: $ _ instance = null; } Public function register_auto_loader () {spl_autoload_register (array ($ this, 'load_class')); Spl_autoload_register (array ($ this, 'load_child_class')); } Public function load_class ($ square) {$ path = str_replace ('_', '/', $ class); If (file_exists (get_template_directory (). '/'. $ Path. '.php')) {require_once (get_template_directory (). '/'. $ Path. '.php'); }} Public function load_child_class ($ square) {$ path = str_replace ('_', '/', $ class); If (file_exists (get_stylesheet_directory (). '/'. $ Path. '.php')) {require_once (get_stylesheet_directory (). '/'. $ Path. '.php'); }}} Currently this class will load anything in the original project. This will also load the parent project object in the child project.
Speak to people familiar with WordPress, yes, because you have get_template_directory when you want get_stylesheet_directory sometimes - after knowing this - I want to type two auto loaders, which will load child projects using get_stylesheet_directory and then that which is get_stylesheet_directory such that: class project_one_folder_class extends project_two_folder_class {} works and load, with error.
It is a bit thicker, but you really only need an autoloader that only checks in many directories Is:
abstract square Hakre_Theme_AutoLoader {public $ static public; Public static work init () {// Configure path itself: $ directory = array (get_template_directory (), // current theme, childtheme get_stylesheet_directory () parent, // current subject, childtheme in terms of childtheme); // Please double-check that you really need to return the return spl_autoload_register ('Hakre_Theme_AutoLoader :: autoload', true, true); } Public stable work autoload ($ square) {$ filename = str_replace ('_', '/', $ class). '.php'; Foreign currency (auto: $ directory $ directory) {$ path = $ directory} '/' $ filename; If (is_file ($ path)) {requirement ($ path); Return; # Leave because the class is loaded}}}} diamond_theme_autoloder :: int (); ## If you are unsure, then all worked well: var_dump (Hakre_Theme_AutoLoader :: $ directory); It should really do this, although I have not tested it. See var_dump , if the correct directories are registered or not, you can debug them. There is no need to have many callbacks just because you want to check in two directories.
php स्क्रिप्टिंग नमूना कोड स्निपेट
ReplyDeleteMssql डेटाबेस प्रबंधक उदाहरण कोड