/** * Retrieve Role based on ID * * @return WP_Role|null * * @access protected */ protected function retrieveSubject() { $roles = new WP_Roles(); $role = $roles->get_role($this->getId()); if (is_null($role)) { aam_Core_Console::write('Role ' . $this->getId() . ' does not exist'); } elseif (isset($role->capabilities)) { //add role capability as role id, weird WordPress behavior //example is administrator capability $role->capabilities[$this->getId()] = true; } return $role; }
/** * * @param type $zip * @return boolean */ protected function insert($zip) { $response = true; if (is_wp_error(unzip_file($zip, $this->_basedir))) { aam_Core_Console::write('Failed to insert extension'); $response = false; } return $response; }
/** * * @param type $param * @param type $default * @return type */ protected function parseParam($param, $default) { if (is_object($param) && isset($param->userFunc)) { $func = trim($param->userFunc); if (is_string($func) && is_callable($func)) { $response = call_user_func($func); } else { aam_Core_Console::write("ConfigPress userFunc {$func} failure"); $response = $default; } } else { $response = $param; } return $response; }
/** * Trigger Subject native methods * * @param string $name * @param array $arguments * * @return mixed * * @access public */ public function __call($name, $arguments) { $subject = $this->getSubject(); //make sure that method is callable if (method_exists($subject, $name)) { $response = call_user_func_array(array($subject, $name), $arguments); } else { aam_Core_Console::write("Method {$name} does not exist in " . get_class($subject)); $response = null; } return $response; }