private function _register_actions() { foreach (get_class_methods($this) as $method) { if (Strings::position($method, 'action_') === 0) { $action = Strings::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 (Strings::position($method, 'add_action_') === 0 || Strings::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); } } }
/** * Init autoload for classes in modules */ private function _init_module_autoloader() { spl_autoload_register(function ($class_name) { if (Strings::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; }); }
protected function _is_default_page() { $reflection = new \ReflectionClass(__CLASS__); if (in_array($this->_page, $reflection->getConstants()) && Strings::position($_SERVER['REQUEST_URI'], "options-{$this->_page}.php") !== false) { return true; } return false; }