fbpx

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 449

wpmf_add_attachment

Create an attachment when importing or syncing files from FTP
This hook is also used when a remote video is created

Parameters :

integer Created attachment ID
integer|array Target folder or array of target folders
array Extra informations

Return :

void

In files :

class/class-main.php line 3840
class/class-wp-folder-option.php line 308

wpmf_attachment_set_folder

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

Parameters :

integer Attachment ID
integer|array Target folder or array of target folders
array Extra informations

Return :

void

In files :

class/class-main.php line 459
class/class-main.php line 490
class/class-main.php line 1706
class/class-main.php line 2147
class/class-main.php line 2549
class/class-main.php line 2605
class/class-main.php line 2679
class/class-main.php line 3479
class/class-wp-folder-option.php line 3141

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 2404
class/class-main.php line 2472

wpmf_create_folder

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

Parameters :

integer Created folder ID
string Created folder name
integer Parent folder ID
array Extra informations

Return :

void

In files :

class/class-main.php line 1683
class/class-main.php line 2255
class/class-wp-folder-option.php line 431
class/class-wp-folder-option.php line 1722
class/class-wp-folder-option.php line 3038
class/class-wp-folder-option.php line 3072

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 2411
class/class-main.php line 2481

wpmf_duplicate_attachment

Duplicate an attachment

Parameters :

integer Attachment ID
integer Target folder

Return :

void

In files :

class/class-duplicate-file.php line 104

wpmf_move_folder

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

Parameters :

integer Folder moved ID
string Destination folder ID
array Extra informations

Return :

void

In files :

class/class-main.php line 2766
class/class-wp-folder-option.php line 2625

wpmf_update_folder_name

Update folder name

Parameters :

integer Folder ID
string Updated name

Return :

void

In files :

class/class-main.php line 2337

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 143

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 430

the_content_export

Filters the post content used for WXR exports.

Parameters :

string $post_content Content of the current post.

Return :

void

In files :

class/class-wp-folder-option.php line 831

the_excerpt_export

Filters the post excerpt used for WXR exports.

Parameters :

string $post_excerpt Excerpt for the current post.

Return :

void

In files :

class/class-wp-folder-option.php line 840

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 else
to 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 503

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 414

wpmf_import_allowed_filetypes

Filter the filetype allowed to be imported through ftp or folder import

Parameters :

array Filetypes allowed to be imported

Return :

array

In files :

class/class-wp-folder-option.php line 924
class/class-wp-folder-option.php line 1680

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 3593

wpmf_user_can

Filter check user capability to do an action

Parameters :

boolean The current user has the given capability
string Action name

Return :

boolean

In files :

wp-media-folder.php line 35
class/class-duplicate-file.php line 53
class/class-folder-access.php line 40
class/class-main.php line 615
class/class-main.php line 843
class/class-main.php line 881
class/class-main.php line 1560
class/class-main.php line 1594
class/class-main.php line 2225
class/class-main.php line 2291
class/class-main.php line 2364
class/class-main.php line 2648
class/class-main.php line 2720
class/class-main.php line 2802
class/class-main.php line 3099
class/class-main.php line 3232
class/class-main.php line 3417
class/class-main.php line 3678
class/class-main.php line 4087
class/class-main.php line 4134
class/class-replace-file.php line 44
class/class-replace-file.php line 207
class/class-wp-folder-option.php line 183
class/class-wp-folder-option.php line 522
class/class-wp-folder-option.php line 565
class/class-wp-folder-option.php line 910
class/class-wp-folder-option.php line 1004
class/class-wp-folder-option.php line 1609
class/class-wp-folder-option.php line 1936
class/class-wp-folder-option.php line 2090
class/class-wp-folder-option.php line 3001
class/class-wp-folder-option.php line 3291
class/class-wp-folder-option.php line 3374
class/class-wp-folder-option.php line 3421
class/class-wp-folder-option.php line 3505
class/class-wp-folder-option.php line 3556
class/class-wp-folder-option.php line 3604
class/class-image-watermark.php line 188
class/pages/settings/image_compression.php line 44
class/pages/settings/image_compression.php line 98
class/pages/settings/image_compression.php line 252
class/pages/settings/image_compression.php line 288
class/pages/settings/import_export.php line 134
class/pages/settings/import_export.php line 168
class/install-wizard/install-wizard.php line 54
jutranslation/jutranslation.php line 109

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