Class MLA (Media Library Assistant) Shortcodes defines the shortcodes available to MLA users

package Media Library Assistant
since 0.20

 Methods

Initialization function, similar to __construct()

initialize() : void

since 0.20

WordPress Shortcode; renders a complete list of all attachments and references to them

mla_attachment_list_shortcode() : void

since 0.1

Parses shortcode parameters and returns the gallery objects

mla_get_shortcode_attachments(int $post_parent, array $attr, boolean $return_found_rows) : array

since .50

Parameters

$post_parent

int

Post ID of the parent

$attr

array

Attributes of the shortcode

$return_found_rows

boolean

true to calculate and return ['found_posts'] as an array element

Returns

arrayList of attachments returned from WP_Query

Retrieve the terms in one or more taxonomies.

mla_get_terms(array $attr) : array

Alternative to WordPress get_terms() function that provides an accurate count of attachments associated with each term.

taxonomy - string containing one or more (comma-delimited) taxonomy names or an array of taxonomy names.

include - An array, comma- or space-delimited string of term ids to include in the return array.

exclude - An array, comma- or space-delimited string of term ids to exclude from the return array. If 'include' is non-empty, 'exclude' is ignored.

parent - term_id of the terms' immediate parent; 0 for top-level terms.

minimum - minimum number of attachments a term must have to be included.

number - maximum number of term objects to return. Terms are ordered by count, descending and then by term_id before this value is applied.

orderby - 'count', 'id', 'name', 'none', 'random', 'slug'

order - 'ASC', 'DESC'

preserve_case - 'true', 'false' to make orderby case-sensitive.

limit - final number of term objects to return, for pagination.

offset - number of term objects to skip, for pagination.

since 1.60

Parameters

$attr

array

taxonomies to search and query parameters

Returns

arrayarray of term objects, empty if none found

Filters all clauses for shortcode queries, pre caching plugins

mla_shortcode_query_posts_clauses_filter(array $pieces) : array

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

since 1.30

Parameters

$pieces

array

query clauses before modification

Returns

arrayquery clauses after modification (none)

Filters all clauses for shortcode queries, post caching plugins

mla_shortcode_query_posts_clauses_request_filter(array $pieces) : array

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

since 1.30

Parameters

$pieces

array

query clauses before modification

Returns

arrayquery clauses after modification (none)

Filters the ORDERBY clause for shortcode queries

mla_shortcode_query_posts_orderby_filter(string $orderby_clause) : string

This is an enhanced version of the code found in wp-includes/query.php, function get_posts. Defined as public because it's a filter.

since 1.20

Parameters

$orderby_clause

string

query clause before modification

Returns

stringquery clause after modification

Filters the WHERE clause for shortcode queries

mla_shortcode_query_posts_where_filter(string $where_clause) : string

Captures debug information. Adds whitespace to the post_type = 'attachment' phrase to circumvent subsequent Role Scoper modification of the clause. Handles post_parent "any" and "none" cases. Defined as public because it's a filter.

since 0.70

Parameters

$where_clause

string

query clause before modification

Returns

stringquery clause after modification

The MLA Tag Cloud support function.

mla_tag_cloud(array $attr) : string

This is an alternative to the WordPress wp_tag_cloud function, with additional options to customize the hyperlink behind each term.

since 1.60

Parameters

$attr

array

Attributes of the shortcode.

Returns

stringHTML content to display the tag cloud.

The MLA Tag Cloud shortcode.

mla_tag_cloud_shortcode(array $attr) : string

This is an interface to the mla_tag_cloud function.

since 1.60

Parameters

$attr

array

Attributes of the shortcode.

Returns

stringHTML content to display the tag cloud.

Handles pagnation output types 'previous_page', 'next_page', and 'paginate_links'

_process_pagination_output_types(array $output_parameters, string $markup_values, string $arguments, string $attr, integer $found_rows, string $output) : mixed

since 1.42

Parameters

$output_parameters

array

value(s) for mla_output_type parameter

$markup_values

string

template substitution values, e.g., ('instance' => '1', ... )

$arguments

string

merged default and passed shortcode parameter values

$attr

string

raw passed shortcode parameter values

$found_rows

integer

number of attachments in the gallery, without pagination

$output

string

output text so far, may include debug values

Returns

mixedfalse or string with HTML for pagination output types

Handles brace/bracket escaping and parses template for a shortcode parameter

_process_shortcode_parameter(string $text, string $markup_values) : string

since 1.14

Parameters

$text

string

raw shortcode parameter, e.g., "text {+field+} {brackets} \{braces\}"

$markup_values

string

template substitution values, e.g., ('instance' => '1', ... )

Returns

stringquery specification with HTML escape sequences and line breaks removed

Cleans up damage caused by the Visual Editor to the tax_query and meta_query specifications

_sanitize_query_specification(string $specification) : string

since 1.14

Parameters

$specification

string

query specification; PHP nested arrays

Returns

stringquery specification with HTML escape sequences and line breaks removed

Translates query parameters to a valid SQL order by clause.

_validate_sql_orderby(array $query_parameters) : string | bool

Accepts one or more valid columns, with or without ASC/DESC. Enhanced version of /wp-includes/formatting.php function sanitize_sql_orderby().

since 1.20

Parameters

$query_parameters

array

Validated query parameters

Returns

stringboolReturns the orderby clause if present, false otherwise.

 Properties

 

Accumulates debug messages

$mla_debug_messages : string

since 0.60
   

Turn debug collection and display on or off

$mla_debug : boolean

since 0.70
 

Data selection parameters for the WP_Query in [mla_gallery]

$mla_get_shortcode_attachments_parameters : array

since 1.30
 

Data selection parameters for [mla_tag_cloud]

$mla_get_terms_parameters : array

since 1.60
 

WP_Query filter "parameters"

$query_parameters : array

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

Array index values are: orderby, post_parent

since 1.13