예제 #1
0
 /**
  * Render the user fields.
  *
  * @param \WP_User|string If adding a user, $user is the context (string): 'add-existing-user' for multisite, 'add.new-user' for single. Else is a \WP_User instance.
  * @return void
  */
 public function displayFields($user)
 {
     // Add nonce fields for safety.
     if (!static::$hasNonce) {
         wp_nonce_field(Session::nonceAction, Session::nonceName);
         static::$hasNonce = true;
     }
     // Set the value attribute for each field.
     $fields = $this->setDefaultValue($user, $this->fields);
     // User view data
     $params = ['__factory' => $this, '__fields' => $fields, '__sections' => $this->sections, '__user' => $user, '__userContext' => null];
     // Check if $user is a string context
     if (is_string($user)) {
         // Set to null __user
         $params['__user'] = null;
         // Set the context
         $params['__userContext'] = $user;
     }
     // Pass data to user view.
     $this->view->with($params);
     // Render the fields.
     echo $this->view->render();
 }
예제 #2
0
 /**
  * Allow a user to pass custom datas to
  * the page view instance.
  *
  * @param string|array $key
  * @param mixed $value
  * @return \Themosis\Page\PageBuilder
  */
 public function with($key, $value = null)
 {
     $this->view->with($key, $value);
     return $this;
 }