Class MLA (Media Library Assistant) provides several enhancements to the handling
of images and files held in the WordPress Media Library.
Methods
Initialization function, similar to __construct()
initialize() : void
This function contains add_action and add_filter calls
to set up the Ajax handlers, enqueue JavaScript and CSS files, and
set up the Assistant submenu.
Add contextual help tabs to all the MLA pages
mla_add_help_tab() : void
Load the plugin's Style Sheet and Javascript files
mla_admin_enqueue_scripts_action(string $page_hook) : void
Parameters
$page_hook
string
Name of the page being loaded
Load the plugin's Ajax handler or process Edit Media update actions
mla_admin_init_action() : void
Print optional in-lne styles for Media/Assistant submenu table
mla_admin_print_styles_action()
Get the edit Authors dropdown box, if user has suitable permissions
mla_authors_dropdown(integer $author, string $name, string $class) : string | false
Parameters
$author
integer
Optional User ID of the current author, default 0
$name
string
Optional HTML name attribute, default 'post_author'
$class
string
Optional HTML class attribute, default 'authors'
Returns
string
false
HTML markup for the dropdown field or False
Clear the Media/Assistant submenu Filter-by variables
mla_clear_filter_by(array $preserves) : void
Parameters
$preserves
array
Filters to be retained
Add a debug message to the collection
mla_debug_add(string $message, integer $debug_level)
Parameters
$message
string
Message text
$debug_level
integer
Optional. Debug category.
Get debug information without clearing the buffer
mla_debug_content(string $format, string $glue) : boolean
Parameters
$format
string
Return data type: 'string' (default) or 'array'
$glue
string
Join array elements with '\n' or '
<
p>' (default)
Returns
boolean
true if success else false
Get/Set debug information collection output file for mode = 'log'
mla_debug_file(string $file) : string
Note that WP_CONTENT_DIR will be pre-pended to the value, and a slash
will be added to the front of the value if necessary.
Parameters
$file
string
Optional. The (optional path and) file name, relative to WP_CONTENT_DIR, or false/empty string to clear the value.
Returns
string
The previous file value, i.e., before the update, relative to WP_CONTENT_DIR
Flush debug information and clear buffer
mla_debug_flush(string $destination, boolean $stop_collecting) : string
Parameters
$destination
string
Destination: 'buffer' (default), 'console', 'log' or 'none'
$stop_collecting
boolean
true (default) to stop, false to continue collection
Returns
string
debug content if $destination == 'buffer' else empty string
Get/Set debug information collection mode
mla_debug_mode(string $mode) : string
Parameters
$mode
string
Optional. New collection mode: 'none' (default), 'buffer', 'console' or 'log'
Returns
string
The previous mode value, i.e., before the update
Ajax handler to fetch candidates for the "Set Parent" popup window
mla_find_posts_ajax_action() : void
Adapted from wp_ajax_find_posts in /wp-admin/includes/ajax-actions.php.
Adds filters for post type and pagination.
Ajax handler for inline editing
mla_inline_edit_ajax_action() : void
Adapted for Quick Edit from wp_ajax_inline_save in /wp-admin/includes/ajax-actions.php
Displays name conflict error messages at the top of the Dashboard
mla_name_conflict_reporting_action()
Cleanup menus for Edit Tags/Categories page
mla_parent_file_filter(array $parent_file) : string
Fixes the submenu bolding when going to the Edit Media screen.
Parameters
$parent_file
array
The top-level menu page
Returns
string
The updated top-level menu page
Load a plugin text domain and alternate debug file
mla_plugins_loaded_action() : void
The "add_action" for this function is in mla-plugin-loader.php, because the "initialize"
function above doesn't run in time.
Defined as public because it's an action.
Prepare Bulk Edit field-level updates
mla_prepare_bulk_edits(integer $post_id, array $request, array $custom_field_map) : array
Parameters
$post_id
integer
Current post ID
$request
array
Form elements, e.g., from $_REQUEST
$custom_field_map
array
Form id to field name mapping
Returns
array
Non-empty form elements
Process bulk action for one or more attachments
mla_process_bulk_action(string $bulk_action, array $request) : array
Parameters
$bulk_action
string
Bulk action slug: delete, edit, restore, trash, custom action
$request
array
Form elements, e.g., from $_REQUEST
Returns
array
messages and page content: ( 'message', 'body', 'unchanged', 'success', 'failure', 'item_results' )
Render the "Assistant" subpage in the Media section, using the list_table package
mla_render_admin_page() : void
Only show screen options on the table-list screen
mla_screen_options_show_screen_filter(boolean $show_screen, string $this_screen) : boolean
Parameters
$show_screen
boolean
True to display "Screen Options", false to suppress them
$this_screen
string
Name of the page being loaded
Returns
boolean
True to display "Screen Options", false to suppress them
Ajax handler to set post_parent for a single attachment
mla_set_parent_ajax_action() : void
Adapted from wp_ajax_inline_save in /wp-admin/includes/ajax-actions.php
Save the "Entries per page" option set by this user
mla_set_screen_option_filter(mixed $status, string $option, string $value) : string | void
Parameters
$status
mixed
false or value returned by previous filter
$option
string
Name of the option being changed
$value
string
New value of the option
Returns
string
void
New value if this is our option, otherwise nothing
Ajax handler for bulk editing and mapping
_bulk_edit_ajax_handler() : void
Compose a Post Type Options list with current selection
_compose_post_type_select(array $templates, string $selection) : string
since |
1.90 |
uses |
\global\$mla_option_templates |
Parameters
$templates
array
template parts
$selection
string
current selection or 'all' (default)
Returns
string
HTML markup with select field options
Get the current action selected from the bulk actions dropdown
_current_bulk_action() : string | false
Returns
string
false
The action name or False if no action was selected
Write a debug message to the appropriate log file
_debug_log(string $message)
Parameters
$message
string
Message text
Delete a single item permanently
_delete_single_item(array $post_id) : array
Parameters
$post_id
array
The form POST data
Returns
array
success/failure message and NULL content
Process bulk edit area fields, which may contain a Content Template
_process_bulk_value(integer $post_id, string $bulk_value) : string
Parameters
$post_id
integer
Current post ID
$bulk_value
string
Field value as entered
Returns
string
Empty, or new value for the field
Process secure file download
_process_mla_download_file() : void
Requires _wpnonce, mla_download_file and mla_download_type in $_REQUEST; mla_download_disposition is optional.
Restore a single item from the Trash
_restore_single_item(integer $post_id) : array
Parameters
$post_id
integer
The WordPress Post ID of the attachment item
Returns
array
success/failure message and NULL content
Move a single item to Trash
_trash_single_item(integer $post_id) : array
Parameters
$post_id
integer
The WordPress Post ID of the attachment item
Returns
array
success/failure message and NULL content
Properties
Debug information output file for mode = 'log'
$mla_debug_file : string
Accumulates debug messages
$mla_debug_messages : string
Debug information collection mode
$mla_debug_mode : string
Collection mode: 'buffer', 'console', 'log' or 'none' (default).
Accumulates error messages from name conflict tests
$mla_language_support_error_messages
Holds screen ids to match help text to corresponding screen
$page_hooks : array
Constants
Slug for adding plugin submenu
ADMIN_PAGE_SLUG : string
Current version number
CURRENT_MLA_VERSION : string
Object name for localizing JavaScript - MLA List Table
JAVASCRIPT_INLINE_EDIT_OBJECT : string
Slug for localizing and enqueueing JavaScript - MLA List Table
JAVASCRIPT_INLINE_EDIT_SLUG : string
Action name; gives a context for the nonce
MLA_ADMIN_NONCE_ACTION : string
Nonce name; uniquely identifies the nonce
MLA_ADMIN_NONCE_NAME : string
mla_admin_action value for setting an item's parent object
MLA_ADMIN_SET_PARENT : string
mla_admin_action value for mapping Custom Field metadata
MLA_ADMIN_SINGLE_CUSTOM_FIELD_MAP : string
mla_admin_action value for permanently deleting a single item
MLA_ADMIN_SINGLE_DELETE : string
mla_admin_action value to display a single item for editing
MLA_ADMIN_SINGLE_EDIT_DISPLAY : string
Used by class-mla-view-list-table.php and class-mla-upload-list-table.php
mla_admin_action value for updating a single item
MLA_ADMIN_SINGLE_EDIT_UPDATE : string
Used by class-mla-view-list-table.php and class-mla-upload-list-table.php
mla_admin_action value for mapping IPTC/EXIF metadata
MLA_ADMIN_SINGLE_MAP : string
mla_admin_action value for restoring a single item from the trash
MLA_ADMIN_SINGLE_RESTORE : string
mla_admin_action value for moving a single item to the trash
MLA_ADMIN_SINGLE_TRASH : string
mla_admin_action value for searching taxonomy terms
MLA_ADMIN_TERMS_SEARCH : string
Constant to log Ajax debug activity
MLA_DEBUG_CATEGORY_AJAX : integer
Current date for Development Version, empty for production versions
MLA_DEVELOPMENT_VERSION : string
Slug for registering and enqueueing plugin style sheet
STYLESHEET_SLUG : string