Exemple #1
0
 private function _register_actions()
 {
     foreach (get_class_methods($this) as $method) {
         if (String::position($method, 'action_') === 0) {
             $action = String::sub_string($method, 7);
             add_action('wp_ajax_' . $this->get_prefix() . '_' . $action, [$this, $method]);
             add_action('wp_ajax_nopriv_' . $this->get_prefix() . '_' . $action, [$this, $method]);
         }
     }
 }
 private function _execute_add_action_methods()
 {
     foreach (get_class_methods($this) as $method) {
         if (String::position($method, 'add_action_') === 0 || String::position($method, 'add_filter_') === 0) {
             $action_name = str_replace(['add_filter_', 'add_action_'], '', $method);
             $reflection = new \ReflectionMethod($this, $method);
             $params_count = $reflection->getNumberOfParameters();
             add_filter($action_name, [$this, $method], 10, $params_count);
         }
     }
 }
Exemple #3
0
 protected function _is_default_page()
 {
     $reflection = new \ReflectionClass(__CLASS__);
     if (in_array($this->_page, $reflection->getConstants()) && String::position($_SERVER['REQUEST_URI'], "options-{$this->_page}.php") !== false) {
         return true;
     }
     return false;
 }
Exemple #4
0
 /**
  * Init autoload for classes in modules
  */
 private function _init_module_autoloader()
 {
     spl_autoload_register(function ($class_name) {
         if (String::position($class_name, "modules") !== false) {
             $filename = TEMPLATEPATH . DIRECTORY_SEPARATOR . ltrim(str_replace("\\", DIRECTORY_SEPARATOR, $class_name), DIRECTORY_SEPARATOR) . ".php";
             if (is_file($filename)) {
                 require_once $filename;
                 return true;
             }
         }
         return false;
     });
 }