Ejemplo n.º 1
0
 protected function _get_labels()
 {
     $singular_name = Strings::capitalize($this->_name);
     $plural_name = $this->_pluralize ? Strings::pluralize($singular_name) : $singular_name;
     $lowercase_singular_name = Strings::lowercase($singular_name);
     $lowercase_plural_name = Strings::lowercase($plural_name);
     $default_labels = ['name' => $plural_name, 'singular_name' => $singular_name, 'add_new' => __("Add New", 'wpkit'), 'add_new_item' => sprintf(__("Add New %s", 'wpkit'), $lowercase_singular_name), 'edit_item' => sprintf(__("Edit %s", 'wpkit'), $lowercase_singular_name), 'new_item' => sprintf(__("New %s", 'wpkit'), $lowercase_singular_name), 'all_items' => sprintf(__("All %s", 'wpkit'), $lowercase_plural_name), 'view_item' => sprintf(__("View %s", 'wpkit'), $lowercase_singular_name), 'search_items' => sprintf(__("Search %s", 'wpkit'), $lowercase_plural_name), 'not_found' => sprintf(__("No %s found", 'wpkit'), $lowercase_plural_name), 'not_found_in_trash' => sprintf(__("No %s found in Trash", 'wpkit'), $lowercase_plural_name), 'parent_item_colon' => null, 'menu_name' => $plural_name];
     return wp_parse_args($this->_custom_labels, $default_labels);
 }
Ejemplo n.º 2
0
 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]);
         }
     }
 }
Ejemplo n.º 3
0
 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);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * 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;
     });
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 protected function _get_labels()
 {
     $singular_name = Strings::capitalize($this->_name);
     $plural_name = $this->_pluralize ? Strings::pluralize($singular_name) : $singular_name;
     $lowercase_plural_name = Strings::lowercase($plural_name);
     return wp_parse_args($this->_custom_labels, ['name' => $plural_name, 'singular_name' => $singular_name, 'search_items' => sprintf(__("Search %s", 'wpkit'), $plural_name), 'popular_items' => sprintf(__("Popular %s", 'wpkit'), $plural_name), 'all_items' => sprintf(__("All %s", 'wpkit'), $plural_name), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => sprintf(__("Edit %s", 'wpkit'), $singular_name), 'update_item' => sprintf(__("Update %s", 'wpkit'), $singular_name), 'add_new_item' => sprintf(__("Add New %s", 'wpkit'), $singular_name), 'new_item_name' => sprintf(__("New %s Name", 'wpkit'), $singular_name), 'separate_items_with_commas' => sprintf(__("Separate %s with commas", 'wpkit'), $lowercase_plural_name), 'add_or_remove_items' => sprintf(__("Add or remove %s", 'wpkit'), $lowercase_plural_name), 'choose_from_most_used' => sprintf(__("Choose from the most used %s", 'wpkit'), $lowercase_plural_name), 'not_found' => sprintf(__("No %s found", 'wpkit'), $lowercase_plural_name), 'menu_name' => $plural_name]);
 }