Documentation

DefaultFolder
in package
implements IUserSettings, IOverrideDefaultFolder Uses CommonUserSettingsTrait, UtilsProvider, DefaultFolder

Add an option so the user can set the default startup folder.

It replaces this plugin: https://wordpress.org/plugins/default-startup-folder-for-real-media-library/

Tags
since
4.6.0

Table of Contents

Interfaces

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.
IOverrideDefaultFolder

Constants

FIELD_NAME  = 'defaultFolder'
ID_LAST_QUERIED  = -3
ID_NONE  = -2
OPTION_NAME  = 'rmlDefaultFolder'

Methods

__construct()  : mixed
C'tor.
content()  : string
Return modified content for the meta box.
getDefaultFolder()  : mixed
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
gettext()  : string
Modify text in list table.
localize()  : array<string|int, mixed>
Localize frontend.
overrideConstruct()  : mixed
overrideSave()  : mixed
posts_clauses()  : array<string|int, mixed>
Modify fields to a fast select query when the setting "None at startup" is configured.
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.
get()  : string|bool
Gets (and persists) a string to the user (settings) metadata.
is()  : bool
Gets (and persists) a checkbox to the user (settings) metadata.

Constants

Methods

content()

Return modified content for the meta box.

public content(mixed $content, mixed $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 : mixed

the HTML formatted string for the dialog

$user : mixed

Current user id

Return values
string

Content

getDefaultFolder()

public static getDefaultFolder([mixed $persist = null ]) : mixed
Parameters
$persist : mixed = null

getPluginConstantPrefix()

Get the prefix of this plugin so composer packages can dynamically build other constant values on it.

public getPluginConstantPrefix() : string
Tags
codeCoverageIgnore

It only returns a string with the constant prefix

Return values
string

gettext()

Modify text in list table.

public gettext(array<string|int, string> $translation, string $text, string $domain) : string
Parameters
$translation : array<string|int, string>
$text : string
$domain : string
Return values
string

localize()

Localize frontend.

public localize(array<string|int, mixed> $arr) : array<string|int, mixed>
Parameters
$arr : array<string|int, mixed>
Return values
array<string|int, mixed>

overrideSave()

public overrideSave(mixed $response, mixed $user, mixed $request) : mixed
Parameters
$response : mixed
$user : mixed
$request : mixed

posts_clauses()

Modify fields to a fast select query when the setting "None at startup" is configured.

public posts_clauses(array<string|int, mixed> $clauses, WP_Query $query, int $folderId, int $root) : array<string|int, mixed>
Parameters
$clauses : array<string|int, mixed>
$query : WP_Query
$folderId : int
$root : int
Return values
array<string|int, mixed>

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(mixed $response, mixed $user, mixed $request) : array<string|int, string>
$response["errors"][] = "Your error";
$response["data"]["myData"] = "Test";
Parameters
$response : mixed

Array of errors and successful data.

$user : mixed

Current user id

$request : mixed

The server request

Return values
array<string|int, string>

scripts()

Enqueue scripts and styles for this meta box.

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

The assets instance so you can enqueue library scripts

get()

Gets (and persists) a string to the user (settings) metadata.

protected static get(string $meta[, bool $persist = null ]) : string|bool
Parameters
$meta : string

The meta key

$persist : bool = null

If setted it will be updated or deleted

Return values
string|bool

is()

Gets (and persists) a checkbox to the user (settings) metadata.

protected static is(string $meta[, bool $persist = null ]) : bool
Parameters
$meta : string

The meta key

$persist : bool = null

If setted it will be updated or deleted

Return values
bool

        
On this page

Search results