Last active
March 29, 2018 01:11
-
-
Save kselax/f82e97e7ee2dfa6b52d6eb000570b280 to your computer and use it in GitHub Desktop.
PHP Current class loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace ddd; | |
| if(!class_exists('Plugin')){ | |
| class Plugin{ | |
| function __construct(){ | |
| $this->loadCore(); | |
| } | |
| private function loadCore(){ | |
| $this->loadWpCore(); | |
| $this->loadClass(); | |
| $this->loadShortcode(); | |
| $this->loadAction(); | |
| } | |
| private function loadWpCore(){ | |
| $dir = dirname(__FILE__).'/../wp-core/'; | |
| if (is_dir($dir)) | |
| { | |
| if ($dh = opendir($dir)) | |
| { | |
| while ($filename = readdir($dh)) | |
| { | |
| if (strstr($filename,'.php') ) | |
| require_once($dir.$filename); | |
| } | |
| } | |
| else | |
| { | |
| echo " can't open dir <br>"; | |
| } | |
| } | |
| else | |
| { | |
| echo $dir.' incorect path to dir<br>'; | |
| } | |
| }//loadWpCore | |
| private function loadClass(){ | |
| $dir = dirname(__FILE__).'/../class/'; | |
| if (is_dir($dir)) | |
| { | |
| if ($dh = opendir($dir)) | |
| { | |
| while ($filename = readdir($dh)) | |
| { | |
| if (strstr($filename,'.php') ) | |
| require_once($dir.$filename); | |
| } | |
| } | |
| else | |
| { | |
| echo " can't open dir <br>"; | |
| } | |
| } | |
| else | |
| { | |
| echo $dir.' incorect path to dir<br>'; | |
| } | |
| }//loadClass | |
| private function loadShortcode(){ | |
| $dir = dirname(__FILE__).'/../shortcode/'; | |
| if (is_dir($dir)) | |
| { | |
| if ($dh = opendir($dir)) | |
| { | |
| while ($filename = readdir($dh)) | |
| { | |
| if (strstr($filename,'.php') ) | |
| require_once($dir.$filename); | |
| } | |
| } | |
| else | |
| { | |
| echo " can't open dir <br>"; | |
| } | |
| } | |
| else | |
| { | |
| echo $dir.' incorect path to dir<br>'; | |
| } | |
| }//loadShortcode | |
| private function loadAction(){ | |
| $dir = dirname(__FILE__).'/../action/'; | |
| if (is_dir($dir)) | |
| { | |
| if ($dh = opendir($dir)) | |
| { | |
| while ($filename = readdir($dh)) | |
| { | |
| if (strstr($filename,'.php') ) | |
| require_once($dir.$filename); | |
| } | |
| } | |
| else | |
| { | |
| echo " can't open dir <br>"; | |
| } | |
| } | |
| else | |
| { | |
| echo $dir.' incorect path to dir<br>'; | |
| } | |
| }//loadAction | |
| }//Plugin | |
| new Plugin(); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment