MLAQuery

Class MLA (Media Library Assistant) Query provides database query support for MLA Ajax, Shortcode and Admin needs

package

Media Library Assistant

since 2.20

Methods

Add filters, run query, remove filters

_execute_list_table_query( $request) : object
static
since 0.30

Arguments

$request

Response

object

WP_Query object with query results

Builds the $default_columns array with translated source texts.

_localize_default_columns_array() 
static
since 1.71

Isolates keyword match results to word boundaries

_match_quoted_phrase( $needle,  $haystack) : boolean
static

Eliminates matches such as "man" in "woman".

since 2.11

Arguments

$needle

$haystack

Response

boolean

$needle is a word match within $haystack

Sanitize and expand query arguments from request variables

_prepare_list_table_query( $raw_request,  $offset,  $count) : array
static

Prepare the arguments for WP_Query. Modeled after wp_edit_attachments_query in wp-admin/post.php

since 0.1

Arguments

$raw_request

$offset

$count

Response

array

revised arguments suitable for WP_Query

Detects wildcard searches, i.e., containing an asterisk outside quotes

_wildcard_search_string( $search_string) : boolean
static

Defined as public because it's a callback from array_map().

since 2.13

Arguments

$search_string

Response

boolean

true if wildcard

Initialization function, similar to __construct()

initialize() 
static
since 0.1

Add Featured Image and inserted image/link references to an array of attachments

mla_attachment_array_fetch_references( &$attachments) : void
static

Searches all post and page content to see if the attachmenta are used as a Featured Image or inserted in the post as an image or link.

since 1.94

Arguments

$attachments

Get the total number of attachment posts

mla_count_list_table_items( $request,  $offset = NULL,  $count = NULL) : integer
static
since 0.30

Arguments

$request

$offset

$count

Response

integer

Number of attachment posts

Fetch custom field option value given a slug

mla_custom_field_option_value( $slug) : array
static
since 1.10

Arguments

$slug

Response

array

option value, e.g., array( 'name' => 'File Size', ... )

Returns information about an attachment's parent, if found

mla_fetch_attachment_parent_data( $parent_id) : array
static
since 0.1

Arguments

$parent_id

Response

array

Parent information; post_date, post_title and post_type

Find Featured Image and inserted image/link references to an attachment

mla_fetch_attachment_references( $ID,  $parent,  $add_references = true) : array
static

Searches all post and page content to see if the attachment is used as a Featured Image or inserted in the post as an image or link.

since 0.1

Arguments

$ID

$parent

$add_references

Response

array

Reference information; see $references array comments

Invalidates the $mla_galleries or $galleries array and cached values

mla_flush_mla_galleries( $option_name) : void
static
since 1.00

Arguments

$option_name

Return the names and display values of the sortable columns

mla_get_sortable_columns() : array
static
since 0.30

Response

array

name => array( orderby value, heading ) for sortable columns

Retrieve attachment objects for list table display

mla_query_list_table_items( $request,  $offset,  $count) : array
static

Supports prepare_items in class-mla-list-table.php. Modeled after wp_edit_attachments_query in wp-admin/post.php

since 0.1

Arguments

$request

$offset

$count

Response

array

attachment objects (posts) including parent data, meta data and references

Retrieve attachment objects for the WordPress Media Manager

mla_query_media_modal_items( $request,  $offset,  $count) : object
static

Supports month-year and taxonomy-term filters as well as the enhanced search box

since 1.20

Arguments

$request

$offset

$count

Response

object

WP_Query object with query results

Filters all clauses for shortcode queries, pre caching plugins

mla_query_posts_clauses_filter( $pieces) : array
static

This is for debug purposes only. Defined as public because it's a filter.

since 1.80

Arguments

$pieces

Response

array

query clauses after modification (none)

Filters all clauses for shortcode queries, post caching plugins

mla_query_posts_clauses_request_filter( $pieces) : array
static

This is for debug purposes only. Defined as public because it's a filter.

since 1.80

Arguments

$pieces

Response

array

query clauses after modification (none)

Adds a GROUPBY clause, if required

mla_query_posts_groupby_filter( $groupby_clause) : string
static

Taxonomy text queries and postmeta queries can return multiple results for the same ID. Defined as public because it's a filter.

since 1.90

Arguments

$groupby_clause

Response

string

updated query clause

Adds a JOIN clause, if required, to handle sorting/searching on custom fields or ALT Text

mla_query_posts_join_filter( $join_clause) : string
static

Defined as public because it's a filter.

since 0.30

Arguments

$join_clause

Response

string

query clause after "LEFT JOIN view ON post_id" item modification

Adds a ORDERBY clause, if required

mla_query_posts_orderby_filter( $orderby_clause) : string
static

Expands the range of sort options because the logic in WP_Query is limited. Defined as public because it's a filter.

since 0.30

Arguments

$orderby_clause

Response

string

updated query clause

Adds a keyword search to the WHERE clause, if required

mla_query_posts_search_filter( $search_string) : string
static

Defined as public because it's a filter.

since 0.60

Arguments

$search_string

Response

string

query clause after keyword search addition

Adds/modifies the WHERE clause for meta values, LIKE patterns and detached items

mla_query_posts_where_filter( $where_clause) : string
static

Modeled after _edit_attachments_query_helper in wp-admin/post.php. Defined as public because it's a filter.

since 0.1

Arguments

$where_clause

Response

string

query clause after modification

Disable Relevanssi - A Better Search, v3.2 by Mikko Saari Defined as public because it's a filter.

mla_query_relevanssi_admin_search_ok_filter( $admin_search_ok) : boolean
static
since 1.80

Arguments

$admin_search_ok

Response

boolean

Updated setting

Disable Relevanssi - A Better Search, v3.2 by Mikko Saari Defined as public because it's a filter.

mla_query_relevanssi_prevent_default_request_filter( $prevent) : boolean
static
since 2.25

Arguments

$prevent

Response

boolean

Updated setting

Filters all clauses for get_terms queries

mla_query_terms_clauses_filter(array $pieces, array $taxonomies, array $args) 
static

Defined as public because it's a filter.

since 2.13

Arguments

$pieces

array

Terms query SQL clauses.

$taxonomies

array

An array of taxonomies.

$args

array

An array of terms query arguments.

Replaces a WordPress function deprecated in v3.7

mla_search_terms_tidy( $term) : string
static

Defined as public because it's a callback from array_map().

since 1.51

Arguments

$term

Response

string

cleaned up search term

Constants

Provides a unique value for the ALT Text "Search Media" subquery

MLA_ALT_TEXT_SUBQUERY

The subquery is used to filter the Media/Assistant submenu table by ALT Text with the Search Media text box.

since

Provides a unique value for the File Name "Search Media" subquery

MLA_FILE_SUBQUERY

The subquery is used to filter the Media/Assistant submenu table by File Name with the Search Media text box.

since

Provides a unique suffix for the custom field "orderby" subquery

MLA_ORDERBY_SUBQUERY

The subquery is used to sort the Media/Assistant submenu table on ALT Text and custom field columns.

since

Provides a unique suffix for the "Table View custom:" SQL View

MLA_TABLE_VIEW_SUBQUERY

The SQL View is used to filter the Media/Assistant submenu table on custom field Table Views.

since

Properties

WordPress version test for $wpdb->esc_like() Vs esc_sql()

wp_4dot0_plus : boolean
static
since
var

Type(s)

boolean

Table column definitions

default_columns : array
static

This array defines table columns and titles where the key is the column slug (and class) and the value is the column's title text. If you need a checkbox for bulk actions, use the special slug "cb".

The 'cb' column is treated differently than the rest. If including a checkbox column in your table you must create a column_cb() method. If you don't need bulk actions or checkboxes, simply leave the 'cb' entry out of your array.

All of the columns are added to this array by MLA_List_Table::mla_admin_init_action.

since
var

Type(s)

array

Default values for hidden columns

default_hidden_columns : array
static

This array is used when the user-level option is not set, i.e., the user has not altered the selection of hidden columns.

The value on the right-hand side must match the column slug, e.g., array(0 => 'ID_parent, 1 => 'title_name').

Taxonomy and custom field columns are added to this array by MLA_List_Table::mla_admin_init_action.

since
var

Type(s)

array

Sortable column definitions

default_sortable_columns : array
static

This array defines the table columns that can be sorted. The array key is the column slug that needs to be sortable, and the value is database column to sort by. Often, the key and value will be the same, but this is not always the case (as the value is a column name from the database, not the list table).

The array value also contains a boolean which is 'true' if the initial sort order for the column is DESC/Descending.

Taxonomy and custom field columns are added to this array by MLAQuery::initialize.

since
var

Type(s)

array

Cache the results of mla_count_list_table_items for reuse in mla_query_list_table_items

mla_list_table_items : array
static
since
var

Type(s)

array

WP_Query filter "parameters"

query_parameters : array
static

This array defines parameters for the query's join, where and orderby filters. The parameters are set up in the _prepare_list_table_query function, and any further logic required to translate those values is contained in the filters.

Array index values are: use_alt_text_view, use_postmeta_view, use_orderby_view, alt_text_value, postmeta_key, postmeta_value, patterns, detached, orderby, order, mla-metavalue, debug (also in search_parameters)

since
var

Type(s)

array

WP_Query 'posts_search' filter "parameters"

search_parameters : array
static

This array defines parameters for the query's posts_search filter, which uses 'search_string' to add a clause to the query's WHERE clause. It is shared between the list_table-query functions here and the mla_get_shortcode_attachments function in class-mla-shortcodes.php. This array passes the relevant parameters to the filter.

Array index values are: ['mla_terms_search']['phrases'] ['mla_terms_search']['taxonomies'] ['mla_terms_search']['radio_phrases'] => AND/OR ['mla_terms_search']['radio_terms'] => AND/OR ['s'] => numeric for ID/parent search ['mla_search_fields'] => 'title', 'name', 'alt-text', 'excerpt', 'content', 'file' ,'terms' Note: 'alt-text' and 'file' are not supported in [mla_gallery] ['mla_search_connector'] => AND/OR ['sentence'] => entire string must match as one "keyword" ['exact'] => entire string must match entire field value ['debug'] => internal element, console/log/shortcode/none ['tax_terms_count'] => internal element, shared with JOIN and GROUP BY filters

since
var

Type(s)

array