Actions

mlfp_before_add_file

add_action(‘mlfp_before_add_file’, ‘process_before_add_file’, 10, 2);

Parameters

$new_filename – the name of the new file
$folder_id – the id of the destination folder

function process_before_add_file($new_filename, $folder_id) {

}

mlfp_process_new_file

add_action(‘mlfp_process_new_file’, ‘process_new_add_file’, 10, 2);

Parameters

$filename – the name of the file
$folder_id – the id of the parent folder

function process_new_add_file($filename, $folder_id) {

}

mlfp_after_add_file

add_action(‘mlfp_after_add_file’, ‘process_after_add_file’, 10, 2);

Parameters

$attach_id – the id of the attachment
$filename – the filename
$folder_id – the id of the parent folder

function process_after_add_file($attach_id, $filename, $folder_id) {

}

mlfp_before_folder_creation

add_action(‘mlfp_before_folder_creation’, ‘do_before_folder_creation’);

Parameters

$new_folder_path – path to new folder
$parent_folder_id – parent folder id
$new_folder_url – URL to the new folder

function do_before_folder_creation($new_folder_path, $parent_folder_id, $new_folder_url) {
}

mlfp_after_folder_creation

add_action(‘mlfp_after_folder_creation’, ‘do_after_folder_creation’);

Parameters

$new_folder_path – path to new folder
$parent_folder_id – parent folder id
$new_folder_url – URL to the new folder

function do_after_folder_creation($new_folder_path, $parent_folder_id, $new_folder_url) {

}

mlfp_before_file_move

add_action(‘mlfp_before_file_move’, ‘do_before_file_move’);

Parameters

$image_path – path to the image or file
$destination_name – path to the file in destination folder

function do_before_file_move($image_path, $destination_name) {

}

mlfp_after_file_move

add_action(‘mlfp_after_file_move’, ‘do_after_file_move’);

Parameters

$image_path – path to the image or file
$destination_name – path to the file in destination folder
$destination_url – new url of the image

function do_after_file_move($image_path, $destination_name, $destination_url) {

}

mlfp_before_file_copy

add_action(‘mlfp_before_file_copy’, ‘do_before_file_copy’);

Parameters

$image_path – path to the image or file
$destination_name – path to the file in destination folder

function do_before_file_copy($image_path, $destination_name) {

}

mlfp_after_file_copy

add_action(‘mlfp_after_file_copy’, ‘do_after_file_copy’);

Parameters

$image_path – path to the image or file
$destination_name – path to the file in destination folder
$destination_url – new URL of the file in the destination folder
$folder_id – new folder ID

function do_after_file_copy($image_path, $destination_name, $destination_url, $folder_id) {

}

mlfp_before_file_rename

add_action(‘mlfp_before_file_rename’, ‘do_before_file_rename’);

Parameters

$old_file_path – path to the old file name
$new_file_path – path to the new file name

function do_before_file_rename($old_file_path, $new_file_path) {

}

mlfp_after_file_rename

add_action(‘mlfp_after_file_rename’, ‘do_after_file_rename’);

Parameters

$old_file_path – path to the old file name
$new_file_path – path to the new file name

function do_after_file_rename(do_after_file_rename) {

}

mlfp_before_file_or_folder_delete

add_action(‘mlfp_before_file_or_folder_delete’, ‘do_before_file_or_folder_delete’);

Parameters

$delete_id – id of the file or folder to delete
$folder_path – path to the item to delete
$post_type (‘attachment’ or ‘mgmlp_media_folder’)

function do_before_file_or_folder_delete($delete_id, $folder_path, $post_type) {

}

mlfp_after_file_or_folder_delete

add_action(‘mlfp_after_file_or_folder_delete’, ‘do_after_file_or_folder_delete’);

Parameters

$old_file_path – path to the old file name
$new_file_path – path to the new file name
$post_type (‘attachment’ or ‘mgmlp_media_folder’)

function do_after_file_or_folder_delete($delete_id, $folder_path, $post_type) {

}

mlfp_before_folder_hide

add_action(‘mlfp_before_folder_hide’, ‘do_before_folder_hide’);

Parameters

$folder_id – ID of the folder to hide
$attached_file (relative path to the folder)

function do_before_folder_hide($folder_id, $attached_file) {

}

mlfp_after_folder_hide

add_action(‘mlfp_after_folder_hide’, ‘do_after_folder_hide’);

Parameters

$folder_id – ID of the folder to hide
$attached_file (relative path to the folder)

function do_after_folder_hide($folder_id, $attached_file) {

}

mlfp_before_add_category

add_action(‘mlfp_before_add_category’, ‘do_before_add_category’);

Parameters

$new_category – category to add

function do_before_add_category($new_category) {

}

mlfp_after_add_category

add_action(‘mlfp_after_add_category’, ‘do_after_add_category’);

Parameters

$new_category – category added
$term_id – new term ID
$term_taxonomy_id – term taxonomy ID

function do_before_add_category($new_category, $term_id, $term_taxonomy_id){

}

mlfp_before_sync_file

add_action(‘mlfp_before_sync_file’, ‘do_before_sync_file’);

Parameters

$new_attachment – file to import
$parent_folder – parent folder
$new_file_title – file title
$mlp_alt_text – alt text
$mlp_title_text – text title

function do_before_sync_file($new_attachment, $parent_folder, $new_file_title, $mlp_alt_text, $mlp_title_text) {

}

mlfp_after_sync_file

add_action(‘mlfp_after_sync_file’, ‘do_after_sync_file’);

Parameters

$new_attachment – file to import
$parent_folder – parent folder
$new_file_title – file title
$mlp_alt_text – alt text
$mlp_title_text – text title
$attach_id – ID of the imported file
$absolute_path – absolute path to the imported file
$file_url – URL to the imported file

function do_after_sync_file($new_attachment, $parent_folder, $new_file_title, $mlp_alt_text, $mlp_title_text, $attach_id, $absolute_path, $file_url) {

}

mlfp_before_thumbnail_regen

add_action(‘mlfp_before_thumbnail_regen’, ‘do_before_thumbnail_regen);

Parameters

$attachment_id – id of the image
$attachment_path – path to the image

function do_before_thumbnail_regen($attachment_id, $attachment_path) {

}

mlfp_after_thumbnail_regen

add_action(‘mlfp_after_thumbnail_regen’, ‘do_after_thumbnail_regen’);

Parameters

$attachment_id – id of the image
$attachment_path – path to the image
$metadata – metadata for regenerate file

function do_after_thumbnail_regen($attachment_id, $attachment_path, $metadata) {

}

mlfp_before_add_to_mg

add_action(‘mlfp_before_add_to_mg’, ‘do_before_add_to_mg’);

Parameters

$attachment_id – ID of file to add
$attachment – Post object of the attachment
$gallery_id – ID of the destination gallery
$menu_order – next available free spot at the end of the gallery

function do_before_add_to_mg($attachment_id, $attachment, $gallery_id, $menu_order) {

}

mlfp_after_add_to_mg

add_action(‘mlfp_after_add_to_mg’, ‘do_after_add_to_mg’);

Parameters

$attachment_id – ID of file to add
$attachment – Post object of the attachment
$gallery_id – ID of the destination gallery
$menu_order – next available free spot at the end of the gallery

function do_after_add_to_mg($attachment_id, $attachment, $gallery_id, $menu_order);

mlfp_before_add_to_nextgen

add_action(‘mlfp_before_add_to_nextgen’, ‘do_before_add_to_nextgen’);

Parameters

$attachment_id – ID of the file
$image_location – image URL
$image_path – path to the image
$gallery_id – destination gallery
$gallery_location – location of gallery images

function do_before_add_to_nextgen($attachment_id, $image_location, $image_path, $gallery_id, $gallery_location) {

}

mlfp_after_add_to_nextgen

add_action(‘mlfp_after_add_to_nextgen’, ‘do_after_add_to_nextgen’);

Parameters

$attachment_id – ID of the file
$image_location – image URL
$image_path – path to the image
$gallery_id – destination gallery
$gallery_location – location of gallery images
$image_id – ID of image in Nextgen

function after_add_to_nextgen($attachment_id, $image_location, $image_path, $gallery_id, $gallery_location, $image_id) {

}

mlfp_before_upload_to_cloud

add_action(‘mlfp_before_upload_to_cloud’, ‘do_before_upload_to_cloud’);

Parameters

$location – relative location of the file
$filename – path to the file
$next_id

function do_before_upload_to_cloud($location, $filename, $next_id) {

}

mlfp_after_upload_to_cloud

add_action(‘mlfp_after_upload_to_cloud’, ‘do_after_upload_to_cloud’);

Parameters

$location – relative location of the file
$filename – path to the file
$next_id – current image ID
$sizes – array of thumbnail sizes

function do_after_upload_to_cloud($location, $filename, $next_id, $sizes) {

}

mlfp_before_download_from_cloud

add_action(‘mlfp_before_download_from_cloud’, ‘do_before_download_from_cloud’);

Parameters

$location – relative location of the file
$source_file – destination path
$attach_id – ID of the file
$remove – Remove from cloud (true or false)
$get_thumbnails download thumbnail images (true or false)

function do_before_download_from_cloud($location, $source_file, $attach_id, $remove, $get_thumbnails) {

}

mlfp_after_download_from_cloud

add_action(‘mlfp_after_download_from_cloud’, ‘do_after_download_from_cloud’);

Parameters

$location – relative location of the file
$source_file – destination path
$attach_id – ID of the file
$remove – Remove from cloud (true or false)
$get_thumbnails download thumbnail images (true or false)

function do_after_download_from_cloud($location, $source_file, $attach_id, $remove, $get_thumbnails) {

}

Filters

mg_media_library_plus_post_type_args

add_filter(‘mg_media_library_plus_post_type_args’, ‘filter_type_args’);

Parameters

$args – post type paremeters

function filter_type_args($args)

$args = apply_filters(MGMLP_FILTER_POST_TYPE_ARGS, array(
‘public’ => false,
‘publicly_queryable’ => false,
‘show_ui’ => false,
‘show_in_nav_menus’ => false,
‘show_in_admin_bar’ => false,
‘show_in_menu’ => false,
‘query_var’ => true,
‘hierarchical’ => true,
‘supports’ => false,
‘exclude_from_search’ => true
));
return $args;
}

mgmlp_add_toolbar_buttons

add_filter(‘mgmlp_add_toolbar_buttons’, ‘add_toolbar_buttons’);

Parameters

$filter_output – button HTML code

function add_toolbar_buttons ($filter_output) {

return $filter_output;

}

mgmlp_add_toolbar_areas

add_filter(‘mgmlp_add_toolbar_areas’, ‘add_toolbar_area’);

Parameters
$filter_output

$filter_output – toolbar area HTML

function add_toolbar_area ($filter_output) {

return $filter_output;

}

mlfp_set_post_excerpt

(Adds text that can be used as the image caption when file is imported into Media Library Folders Pro during upload or sync)
add_filter(‘mlfp_set_post_excerpt’, ‘set_post_excerpt’);

Parameters
$post_caption – Text to be save in the post_excerpt field
$folder_name – name of the current folder

function set_post_excerpt ($post_caption, $folder_name) {

return $post_caption;

}

mlfp_filter_upload_destination

add_filter(‘mlfp_filter_upload_destination’, ‘filter_upload_destination’);

Parameters

$filename – the name of the file
$folder_id – the id of the parent folder

Returns

$folder_id

function filter_upload_destination($new_filename, $folder_id) {

return $folder_id;
}