Documentation

IUserSettings

Metadata content for the general user settings. The metadata can be changed in the cog icon in the folders sidebar toolbar. To handle metadata for general user settings you can use the default WordPress add_user_meta function.

To register the metadata class you must use the following API function add_rml_user_settings_box.

Tags
see
https://developer.wordpress.org/reference/functions/add_user_meta/
since
3.2

Table of Contents

Methods

content()  : string
Return modified content for the meta box.
save()  : array<string|int, string>
Save the infos. Add an error to the array to show on the frontend dialog. Add an successful data to receive it in JavaScript.
scripts()  : mixed
Enqueue scripts and styles for this meta box.

Methods

content()

Return modified content for the meta box.

public content(string $content, int $user) : string

Note: If you want to use a more complex content in a meta table use something like this:

<tr>
 <th scope="row">Medium size</th>
 <td><fieldset>
     <legend class="screen-reader-text"><span>Medium size</span></legend>
     <label for="medium_size_w">Max Width</label>
     <input name="medium_size_w" type="number" step="1" min="0" id="medium_size_w" value="300" class="small-text">
     <label for="medium_size_h">Max Height</label>
     <input name="medium_size_h" type="number" step="1" min="0" id="medium_size_h" value="300" class="small-text">
 </fieldset></td>
</tr>

If you want to "group" your meta boxes you can use this code to create a empty space: <tr class="rml-meta-margin"></tr>

Parameters
$content : string

the HTML formatted string for the dialog

$user : int

Current user id

Return values
string

Content

save()

Save the infos. Add an error to the array to show on the frontend dialog. Add an successful data to receive it in JavaScript.

public save(array<string|int, string> $response, int $user, WP_REST_Request $request) : array<string|int, string>
$response["errors"][] = "Your error";
$response["data"]["myData"] = "Test";
Parameters
$response : array<string|int, string>

Array of errors and successful data.

$user : int

Current user id

$request : WP_REST_Request

The server request

Return values
array<string|int, string>

scripts()

Enqueue scripts and styles for this meta box.

public scripts(Assets $assets) : mixed
Parameters
$assets : Assets

The assets instance so you can enqueue library scripts


        
On this page

Search results