Skip to main content

WP Media Folder Developer Documentation

This documentation will help experienced developers to plug any other service with our plugin. Here are all actions and filters for this plugin, if you need some more, feel free to ask by using this for dedicated forum. Thanks for using our plugin!

Helper file

WP Media Folder comes with a helper file with the main functions you may need to integrate it in your own themes and plugins.

  • Move a file into a folder
  • Create folders
  • Move folders
  • Get attachments in a folder
  • ...
Example: you can create a new folder like this: include('wp-content/plugins/wp-media-folder/helper.php'); \Joomunited\WPMediaFolder\Helper::createFolder('My new folder');

Hooks

import_term_meta

Fires after term meta is imported.

Parameters :

int $term_id ID of the newly created term.string $key Meta key.mixed $value Meta value.

Return :

void

In files :

class/import/class-wp-import.php line 451

wpmf_after_replace

Do action after replace file

Parameters :

integer Attachment ID

Return :

void

In files :

class/class-replace-file.php line 388

wpmf_attachment_set_folder

Set attachment folder after moving an attachment to a folder in the media managerThis hook is also used when importing attachment to categories, after an attachment upload andwhen assigning multiple folder to an attachment

Parameters :

integer Attachment IDinteger|array Target folder or array of target foldersarray Extra informations

Return :

void

In files :

class/class-main.php line 822class/class-main.php line 853class/class-main.php line 2670class/class-main.php line 3228class/class-main.php line 4455class/class-main.php line 5256class/class-wp-folder-option.php line 400class/class-wp-folder-option.php line 3505class/class-helper.php line 140class/class-helper.php line 196

wpmf_before_delete_folder

Before delete a folder

Parameters :

WP_Term Folder, this term is not available anymore as it as been deleted

Return :

void

In files :

class/class-main.php line 3978class/class-main.php line 4355

wpmf_create_folder

Create a folder from media libraryThis hook is also used when syncing and importing files from FTP, creating user and role based foldersand importing from Nextgen Gallery

Parameters :

integer Created folder IDstring Created folder nameinteger Parent folder IDarray Extra informations

Return :

void

In files :

class/class-main.php line 2647class/class-main.php line 3485class/class-main.php line 3499class/class-main.php line 3803class/class-wp-folder-option.php line 3382

wpmf_delete_folder

Delete a folder

Parameters :

WP_Term Folder, this term is not available anymore as it as been deleted

Return :

void

In files :

class/class-main.php line 3986class/class-main.php line 4364

wpmf_duplicate_attachment

Duplicate an attachment

Parameters :

integer Attachment IDinteger Target folder

Return :

void

In files :

class/class-duplicate-file.php line 118

wpmf_move_folder

Move a folder from media libraryThis hook is also used when role folder option is changed

Parameters :

integer Folder moved IDstring Destination folder IDarray Extra informations

Return :

void

In files :

class/class-main.php line 4552class/class-wp-folder-option.php line 2940

wpmf_update_folder_name

Update folder name

Parameters :

integer Folder IDstring Updated name

Return :

void

In files :

class/class-main.php line 3917class/class-folder-post-type.php line 500

wpmf_update_folder_name

Update folder name

Parameters :

integer Folder IDstring Updated name

Return :

void

In files :

class/class-main.php line 3917class/class-folder-post-type.php line 500

fallback_intermediate_image_sizes

Filters the image sizes generated for non-image mime types.

Parameters :

array $fallback_sizes An array of image size names.array $metadata Current attachment metadata.

Return :

void

In files :

class/class-helper.php line 312

import_term_meta_key

Filters the meta key for an imported piece of term meta.

Parameters :

string $meta_key Meta key.int $term_id ID of the newly created term.array $term Term data from the WXR import.

Return :

void

In files :

class/import/class-wp-import.php line 432

wp_import_existing_post

Filter ID of the existing post corresponding to post currently importing.Return 0 to force the post to be imported. Filter the ID to be something elseto override which existing post is mapped to the imported post.

Parameters :

int $post_exists Post ID, or 0 if post did not exist.array $post The post array to be inserted.

Return :

void

In files :

class/import/class-wp-import.php line 505

wp_import_term_meta

Filters the metadata attached to an imported term.

Parameters :

array $termmeta Array of term meta.int $term_id ID of the newly created term.array $term Term data from the WXR import.

Return :

void

In files :

class/import/class-wp-import.php line 416

wpmf_gallery_enable_download

Filter to enable/disable download image on gallery

Parameters :

boolean Enable/disable download image

Return :

boolean

In files :

class/class-display-gallery.php line 472

wpmf_gallery_query_args

Filter gallery query argument to get images.

Parameters :

array Gallery query arguments

Return :

array

In files :

class/class-display-gallery.php line 410

wpmf_get_categories_args

Filter to custom aguments for get all categories

Parameters :

array Agument

Return :

array

In files :

class/class-main.php line 2129

wpmf_limit_folders

Filter to set limit of the folder number loaded

Parameters :

integer Limit folder number

Return :

integer

In files :

class/class-main.php line 1620class/class-folder-post-type.php line 1769

wpmf_limit_folders

Filter to set limit of the folder number loaded

Parameters :

integer Limit folder number

Return :

integer

In files :

class/class-main.php line 1620class/class-folder-post-type.php line 1769

wpmf_set_file_title

Manipulate file title before saving it into database

Parameters :

string File title

Return :

string

In files :

class/class-main.php line 5377

wpmf_taxonomy_public

Filter to change public param wpmf-category taxonomy

Parameters :

boolean Toxonomy public status

Return :

boolean

In files :

wp-media-folder.php line 1559

wpmf_user_can

Filter check user capability to do an action

Parameters :

boolean The current user has the given capabilitystring Action name

Return :

boolean

In files :

wp-media-folder.php line 36class/class-replace-file.php line 53class/class-replace-file.php line 435class/class-main.php line 1043class/class-main.php line 1415class/class-main.php line 1454class/class-main.php line 1634class/class-main.php line 2524class/class-main.php line 2558class/class-main.php line 3360class/class-main.php line 3752class/class-main.php line 3864class/class-main.php line 4237class/class-main.php line 4289class/class-main.php line 4402class/class-main.php line 4498class/class-main.php line 4588class/class-main.php line 4870class/class-main.php line 5003class/class-main.php line 5194class/class-main.php line 5662class/class-main.php line 5709class/pages/settings/image_compression.php line 44class/pages/settings/image_compression.php line 98class/pages/settings/image_compression.php line 252class/pages/settings/image_compression.php line 288class/pages/settings/import_export.php line 159class/pages/settings/import_export.php line 332class/class-duplicate-file.php line 53class/class-folder-access.php line 41class/class-wp-folder-option.php line 263class/class-wp-folder-option.php line 871class/class-wp-folder-option.php line 1078class/class-wp-folder-option.php line 1129class/class-wp-folder-option.php line 1421class/class-wp-folder-option.php line 1508class/class-wp-folder-option.php line 2142class/class-wp-folder-option.php line 3350class/class-wp-folder-option.php line 4053class/class-wp-folder-option.php line 4153class/class-wp-folder-option.php line 4221class/class-wp-folder-option.php line 4334class/class-wp-folder-option.php line 4385class/class-wp-folder-option.php line 4433class/install-wizard/install-wizard.php line 54class/class-image-watermark.php line 252

Composer

composer logo Here is the solution to use our plugins as a composer dependency. You have to declare in your composer.json file the joomunited repository, please make sure to replace the YOUR_TOKEN in the url by your own token. You can find it under https://www.joomunited.com/my-account/my-membership under the Composer token accordion. {    "repositories":[       {          "type":"package",          "package":{             "name":"joomunited/wp-media-folder",             "version":"master",             "type":"wordpress-plugin",             "dist":{                "type":"zip",                "url":"https://www.joomunited.com/extra/download/wp-media-folder/YOUR_TOKEN",                "reference":"master"             }          }       }    ],    "require":{       "composer/installers":"~1.0",       "joomunited/wp-media-folder":"dev-master"    } } Please not that composer update command can't work on private repositories (for more explanation please refer to the composer documentation) Though, you can manually update the plugin to the latest version with this command: composer remove joomunited/wp-media-folder && composer clearcache && composer require joomunited/wp-media-folder:dev-master

Set Update key programmatically with WP CLI

Use the same key you used for the composer installation and execute this composer command to set the update token wp option update ju_user_token "YOUR_TOKEN"