Exemplo n.º 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();
 }
Exemplo n.º 2
0
 /**
  * Triggered by the 'add_menu_page' or 'add_submenu_page'.
  *
  * @return void
  */
 public function displayPage()
 {
     // Share the page instance to the view.
     $this->with('__page', $this);
     echo $this->view->render();
 }