Version Description
- Fix: For the Media/Assistant Bulk Edit feature, AJAX errors have been corrected.
Download this release
Release Info
Developer | dglingren |
Plugin | Media Library Assistant |
Version | 3.01 |
Comparing to | |
See all releases |
Code changes from version 2.99 to 3.01
- examples/plugins/mla-hooks-example.php +25 -69
- examples/plugins/mla-item-transfer-pretty-links.php +8 -3
- examples/plugins/mla-list-table-hooks-example.php +228 -197
- examples/plugins/mla-media-modal-hooks-example.php +23 -3
- examples/plugins/mla-multisite-extensions.php +73 -5
- examples/plugins/mla-preset-terms-example.php +193 -0
- examples/plugins/mla-simple-mapping-hooks-example.php +10 -5
- examples/plugins/mla-substitution-parameter-hooks-example.php +35 -6
- examples/plugins/mla-ui-elements-example/admin-settings-page.tpl +42 -10
- examples/plugins/mla-ui-elements-example/mla-ui-elements-example.php +198 -97
- includes/class-mla-core-options.php +8 -7
- includes/class-mla-core.php +28 -1
- includes/class-mla-data-pdf.php +27 -21
- includes/class-mla-data-query.php +4 -1
- includes/class-mla-data-source.php +37 -9
- includes/class-mla-data.php +1 -2
- includes/class-mla-edit-media.php +13 -7
- includes/class-mla-file-downloader.php +2 -0
- includes/class-mla-list-table.php +3 -3
- includes/class-mla-main.php +25 -14
- includes/class-mla-media-modal-ajax.php +3 -0
- includes/class-mla-polylang-support.php +1 -1
- includes/class-mla-settings-documentation-tab.php +1 -1
- includes/class-mla-settings.php +3 -2
- includes/class-mla-shortcode-support.php +57 -12
- includes/class-mla-wpml-support.php +1 -1
- index.php +2 -2
- js/mla-media-modal-scripts.js +12 -8
- js/mla-media-modal-scripts.min.js +1 -1
- readme.txt +37 -24
- tpls/documentation-settings-tab.tpl +69 -21
examples/plugins/mla-hooks-example.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* and illustrates some of the techniques you can use to customize the gallery display.
|
17 |
*
|
18 |
* @package MLA Gallery Hooks Example
|
19 |
-
* @version 1.
|
20 |
*/
|
21 |
|
22 |
/*
|
@@ -24,7 +24,7 @@ Plugin Name: MLA Gallery Hooks Example
|
|
24 |
Plugin URI: http://davidlingren.com/
|
25 |
Description: Provides examples of hooking the filters provided by the [mla_gallery] shortcode
|
26 |
Author: David Lingren
|
27 |
-
Version: 1.
|
28 |
Author URI: http://davidlingren.com/
|
29 |
|
30 |
Copyright 2013 - 2017 David Lingren
|
@@ -61,9 +61,7 @@ class MLAGalleryHooksExample {
|
|
61 |
* @return void
|
62 |
*/
|
63 |
public static function initialize() {
|
64 |
-
|
65 |
-
* The filters are only useful for front-end posts/pages; exit if in the admin section
|
66 |
-
*/
|
67 |
if ( is_admin() )
|
68 |
return;
|
69 |
|
@@ -146,9 +144,7 @@ class MLAGalleryHooksExample {
|
|
146 |
* @return array updated shortcode attributes
|
147 |
*/
|
148 |
public static function mla_gallery_raw_attributes( $shortcode_attributes ) {
|
149 |
-
|
150 |
-
* Uncomment the error_log statements in any of the filters to see what's passed in
|
151 |
-
*/
|
152 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_raw_attributes $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 );
|
153 |
|
154 |
/*
|
@@ -160,9 +156,7 @@ class MLAGalleryHooksExample {
|
|
160 |
global $post;
|
161 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_raw_attributes $post->ID = ' . var_export( $post->ID, true ), 0 );
|
162 |
|
163 |
-
|
164 |
-
* For this example, we delete the selected file.
|
165 |
-
*/
|
166 |
if ( isset( $shortcode_attributes['my_filter'] ) && 'allow file deletion' == $shortcode_attributes['my_filter'] ) {
|
167 |
if ( isset( $_REQUEST['attachment_ID'] ) ) {
|
168 |
$id = (integer) $_REQUEST['attachment_ID'];
|
@@ -202,14 +196,10 @@ class MLAGalleryHooksExample {
|
|
202 |
* @return array updated shortcode attributes
|
203 |
*/
|
204 |
public static function mla_gallery_attributes( $shortcode_attributes ) {
|
205 |
-
|
206 |
-
* Uncomment the error_log statements in any of the filters to see what's passed in
|
207 |
-
*/
|
208 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_attributes $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 );
|
209 |
|
210 |
-
|
211 |
-
* Save the attributes for use in the later filters
|
212 |
-
*/
|
213 |
self::$shortcode_attributes = $shortcode_attributes;
|
214 |
|
215 |
unset( $shortcode_attributes['my_custom_sql'] );
|
@@ -245,9 +235,7 @@ class MLAGalleryHooksExample {
|
|
245 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_initial_content $shortcode_content = ' . var_export( $shortcode_content, true ), 0 );
|
246 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_initial_content $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 );
|
247 |
|
248 |
-
|
249 |
-
* Save the attributes for use in the later filters
|
250 |
-
*/
|
251 |
self::$shortcode_content = $shortcode_content;
|
252 |
|
253 |
return $shortcode_content;
|
@@ -610,9 +598,7 @@ class MLAGalleryHooksExample {
|
|
610 |
$query[] = "AND p.post_status = 'inherit'";
|
611 |
$query[] = "GROUP BY p.ID";
|
612 |
|
613 |
-
|
614 |
-
* ORDER BY clause
|
615 |
-
*/
|
616 |
if ( ! empty( $my_query_vars['orderby'] ) ) {
|
617 |
$orderby = strtolower( $my_query_vars['orderby'] );
|
618 |
} else {
|
@@ -769,9 +755,7 @@ class MLAGalleryHooksExample {
|
|
769 |
|
770 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_wp_query_object self::$wp_query_properties = ' . var_export( self::$wp_query_properties, true ), 0 );
|
771 |
|
772 |
-
|
773 |
-
* Unlike Filters, Actions never return anything
|
774 |
-
*/
|
775 |
return;
|
776 |
} // mla_gallery_wp_query_object
|
777 |
|
@@ -894,9 +878,7 @@ class MLAGalleryHooksExample {
|
|
894 |
//error_log( 'MLAGalleryHooksExample::use_mla_gallery_style $use_style_template = ' . var_export( $use_style_template, true ), 0 );
|
895 |
//error_log( 'MLAGalleryHooksExample::use_mla_gallery_style $style_template_name = ' . var_export( $style_template_name, true ), 0 );
|
896 |
|
897 |
-
|
898 |
-
* Filters must return the first argument passed in, unchanged or updated
|
899 |
-
*/
|
900 |
return $use_style_template;
|
901 |
} // use_mla_gallery_style
|
902 |
|
@@ -917,9 +899,7 @@ class MLAGalleryHooksExample {
|
|
917 |
public static function mla_gallery_style_values( $style_values ) {
|
918 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_style_values $style_values = ' . var_export( $style_values, true ), 0 );
|
919 |
|
920 |
-
|
921 |
-
* You also have access to the PHP Super Globals, e.g., $_REQUEST, $_SERVER
|
922 |
-
*/
|
923 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_style_values $_REQUEST = ' . var_export( $_REQUEST, true ), 0 );
|
924 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_style_values $_SERVER[ REQUEST_URI ] = ' . var_export( $_SERVER['REQUEST_URI'], true ), 0 );
|
925 |
|
@@ -1023,9 +1003,7 @@ class MLAGalleryHooksExample {
|
|
1023 |
public static function mla_gallery_open_template( $open_template ) {
|
1024 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_open_template $open_template = ' . var_export( $open_template, true ), 0 );
|
1025 |
|
1026 |
-
|
1027 |
-
* Check for a display message
|
1028 |
-
*/
|
1029 |
if ( isset( self::$shortcode_attributes['gallery_open_message'] ) ) {
|
1030 |
$open_template = '<p><strong>' . self::$shortcode_attributes['gallery_open_message'] . '</strong></p>' . $open_template;
|
1031 |
}
|
@@ -1201,9 +1179,7 @@ class MLAGalleryHooksExample {
|
|
1201 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_item_values terms = ' . var_export( $item_values['terms:attachment_category'], true ), 0 );
|
1202 |
}
|
1203 |
|
1204 |
-
|
1205 |
-
* For this first example, we will reformat the 'date' value as d/m/Y.
|
1206 |
-
*/
|
1207 |
if ( 'format date' == self::$shortcode_attributes['my_filter'] ) {
|
1208 |
|
1209 |
/*
|
@@ -1229,9 +1205,7 @@ class MLAGalleryHooksExample {
|
|
1229 |
return $item_values;
|
1230 |
}
|
1231 |
|
1232 |
-
|
1233 |
-
* The second example adds a formatted file size element to the existing caption.
|
1234 |
-
*/
|
1235 |
if ( 'file size' == self::$shortcode_attributes['my_filter'] ) {
|
1236 |
|
1237 |
/*
|
@@ -1253,15 +1227,11 @@ class MLAGalleryHooksExample {
|
|
1253 |
$file_size = number_format( $file_size );
|
1254 |
}
|
1255 |
|
1256 |
-
|
1257 |
-
* Compose a new caption, adding the file size.
|
1258 |
-
*/
|
1259 |
return self::_update_caption( $item_values, sprintf( '%1$s<br>Size: %2$s', $item_values['caption'], $file_size ) );
|
1260 |
}
|
1261 |
|
1262 |
-
|
1263 |
-
* Our third example changes taxonomy terms into links to term-specific archive pages.
|
1264 |
-
*/
|
1265 |
if ( 'term gallery' == self::$shortcode_attributes['my_filter'] ) {
|
1266 |
/*
|
1267 |
* Use the "my_href" parameter to link to a static page,
|
@@ -1302,9 +1272,7 @@ class MLAGalleryHooksExample {
|
|
1302 |
return $item_values;
|
1303 |
}
|
1304 |
|
1305 |
-
|
1306 |
-
* For the fourth example, we compose a URL to allow file deletion and add it to the caption.
|
1307 |
-
*/
|
1308 |
if ( 'allow file deletion' == self::$shortcode_attributes['my_filter'] ) {
|
1309 |
$id = (integer) $item_values['attachment_ID'];
|
1310 |
if ( current_user_can( 'delete_post', $id ) ) {
|
@@ -1316,9 +1284,7 @@ class MLAGalleryHooksExample {
|
|
1316 |
}
|
1317 |
}
|
1318 |
|
1319 |
-
|
1320 |
-
* For the fifth example, we compose a caption with "Inserted in" links.
|
1321 |
-
*/
|
1322 |
if ( 'show post inserts' == self::$shortcode_attributes['my_filter'] ) {
|
1323 |
// You can use MLAShortcodes::mla_get_data_source() to get anything available.
|
1324 |
$my_setting = array(
|
@@ -1366,9 +1332,7 @@ class MLAGalleryHooksExample {
|
|
1366 |
if ( 'all custom' != self::$shortcode_attributes['my_filter'] )
|
1367 |
return $item_values; // leave them unchanged
|
1368 |
|
1369 |
-
|
1370 |
-
* Preserve the existing caption, if present
|
1371 |
-
*/
|
1372 |
$my_caption = '';
|
1373 |
if ( ! empty( $item_values['caption'] ) )
|
1374 |
$my_caption .= $item_values['caption'] . "<br />\r\n";
|
@@ -1391,7 +1355,7 @@ class MLAGalleryHooksExample {
|
|
1391 |
* Some of the values you might find useful are:
|
1392 |
* _wp_attached_file, _wp_attachment_metadata, and _wp_attachment_image_alt
|
1393 |
*/
|
1394 |
-
if ( '_' == $post_meta_key
|
1395 |
continue;
|
1396 |
|
1397 |
/*
|
@@ -1413,15 +1377,11 @@ class MLAGalleryHooksExample {
|
|
1413 |
}
|
1414 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_item_values $custom_fields = ' . var_export( $custom_fields, true ), 0 );
|
1415 |
|
1416 |
-
|
1417 |
-
* Don't alter the caption if there are no custom fields to display
|
1418 |
-
*/
|
1419 |
if ( empty( $custom_fields ) )
|
1420 |
return $item_values;
|
1421 |
|
1422 |
-
|
1423 |
-
* Add the definition list to the caption
|
1424 |
-
*/
|
1425 |
$my_caption .= "<dl class=\"custom_field\">\r\n";
|
1426 |
foreach ( $custom_fields as $key => $value ) {
|
1427 |
$my_caption .= "<dt class=\"name\">{$key}</dt>\r\n";
|
@@ -1429,9 +1389,7 @@ class MLAGalleryHooksExample {
|
|
1429 |
} // foreach custom field
|
1430 |
$my_caption .= "</dl>";
|
1431 |
|
1432 |
-
|
1433 |
-
* Update the $item_values and pass them back from the filter.
|
1434 |
-
*/
|
1435 |
$item_values = self::_update_caption( $item_values, $my_caption );
|
1436 |
return $item_values;
|
1437 |
} // mla_gallery_item_values
|
@@ -1570,8 +1528,6 @@ class MLAGalleryHooksExample {
|
|
1570 |
|
1571 |
} // Class MLAGalleryHooksExample
|
1572 |
|
1573 |
-
|
1574 |
-
* Install the filters at an early opportunity
|
1575 |
-
*/
|
1576 |
add_action('init', 'MLAGalleryHooksExample::initialize');
|
1577 |
?>
|
16 |
* and illustrates some of the techniques you can use to customize the gallery display.
|
17 |
*
|
18 |
* @package MLA Gallery Hooks Example
|
19 |
+
* @version 1.16
|
20 |
*/
|
21 |
|
22 |
/*
|
24 |
Plugin URI: http://davidlingren.com/
|
25 |
Description: Provides examples of hooking the filters provided by the [mla_gallery] shortcode
|
26 |
Author: David Lingren
|
27 |
+
Version: 1.16
|
28 |
Author URI: http://davidlingren.com/
|
29 |
|
30 |
Copyright 2013 - 2017 David Lingren
|
61 |
* @return void
|
62 |
*/
|
63 |
public static function initialize() {
|
64 |
+
// The filters are only useful for front-end posts/pages; exit if in the admin section
|
|
|
|
|
65 |
if ( is_admin() )
|
66 |
return;
|
67 |
|
144 |
* @return array updated shortcode attributes
|
145 |
*/
|
146 |
public static function mla_gallery_raw_attributes( $shortcode_attributes ) {
|
147 |
+
// Uncomment the error_log statements in any of the filters to see what's passed in
|
|
|
|
|
148 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_raw_attributes $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 );
|
149 |
|
150 |
/*
|
156 |
global $post;
|
157 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_raw_attributes $post->ID = ' . var_export( $post->ID, true ), 0 );
|
158 |
|
159 |
+
// For this example, we delete the selected file.
|
|
|
|
|
160 |
if ( isset( $shortcode_attributes['my_filter'] ) && 'allow file deletion' == $shortcode_attributes['my_filter'] ) {
|
161 |
if ( isset( $_REQUEST['attachment_ID'] ) ) {
|
162 |
$id = (integer) $_REQUEST['attachment_ID'];
|
196 |
* @return array updated shortcode attributes
|
197 |
*/
|
198 |
public static function mla_gallery_attributes( $shortcode_attributes ) {
|
199 |
+
// Uncomment the error_log statements in any of the filters to see what's passed in
|
|
|
|
|
200 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_attributes $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 );
|
201 |
|
202 |
+
// Save the attributes for use in the later filters
|
|
|
|
|
203 |
self::$shortcode_attributes = $shortcode_attributes;
|
204 |
|
205 |
unset( $shortcode_attributes['my_custom_sql'] );
|
235 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_initial_content $shortcode_content = ' . var_export( $shortcode_content, true ), 0 );
|
236 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_initial_content $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 );
|
237 |
|
238 |
+
// Save the attributes for use in the later filters
|
|
|
|
|
239 |
self::$shortcode_content = $shortcode_content;
|
240 |
|
241 |
return $shortcode_content;
|
598 |
$query[] = "AND p.post_status = 'inherit'";
|
599 |
$query[] = "GROUP BY p.ID";
|
600 |
|
601 |
+
// ORDER BY clause
|
|
|
|
|
602 |
if ( ! empty( $my_query_vars['orderby'] ) ) {
|
603 |
$orderby = strtolower( $my_query_vars['orderby'] );
|
604 |
} else {
|
755 |
|
756 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_wp_query_object self::$wp_query_properties = ' . var_export( self::$wp_query_properties, true ), 0 );
|
757 |
|
758 |
+
// Unlike Filters, Actions never return anything
|
|
|
|
|
759 |
return;
|
760 |
} // mla_gallery_wp_query_object
|
761 |
|
878 |
//error_log( 'MLAGalleryHooksExample::use_mla_gallery_style $use_style_template = ' . var_export( $use_style_template, true ), 0 );
|
879 |
//error_log( 'MLAGalleryHooksExample::use_mla_gallery_style $style_template_name = ' . var_export( $style_template_name, true ), 0 );
|
880 |
|
881 |
+
// Filters must return the first argument passed in, unchanged or updated
|
|
|
|
|
882 |
return $use_style_template;
|
883 |
} // use_mla_gallery_style
|
884 |
|
899 |
public static function mla_gallery_style_values( $style_values ) {
|
900 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_style_values $style_values = ' . var_export( $style_values, true ), 0 );
|
901 |
|
902 |
+
// You also have access to the PHP Super Globals, e.g., $_REQUEST, $_SERVER
|
|
|
|
|
903 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_style_values $_REQUEST = ' . var_export( $_REQUEST, true ), 0 );
|
904 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_style_values $_SERVER[ REQUEST_URI ] = ' . var_export( $_SERVER['REQUEST_URI'], true ), 0 );
|
905 |
|
1003 |
public static function mla_gallery_open_template( $open_template ) {
|
1004 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_open_template $open_template = ' . var_export( $open_template, true ), 0 );
|
1005 |
|
1006 |
+
// Check for a display message
|
|
|
|
|
1007 |
if ( isset( self::$shortcode_attributes['gallery_open_message'] ) ) {
|
1008 |
$open_template = '<p><strong>' . self::$shortcode_attributes['gallery_open_message'] . '</strong></p>' . $open_template;
|
1009 |
}
|
1179 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_item_values terms = ' . var_export( $item_values['terms:attachment_category'], true ), 0 );
|
1180 |
}
|
1181 |
|
1182 |
+
// For this first example, we will reformat the 'date' value as d/m/Y.
|
|
|
|
|
1183 |
if ( 'format date' == self::$shortcode_attributes['my_filter'] ) {
|
1184 |
|
1185 |
/*
|
1205 |
return $item_values;
|
1206 |
}
|
1207 |
|
1208 |
+
// The second example adds a formatted file size element to the existing caption.
|
|
|
|
|
1209 |
if ( 'file size' == self::$shortcode_attributes['my_filter'] ) {
|
1210 |
|
1211 |
/*
|
1227 |
$file_size = number_format( $file_size );
|
1228 |
}
|
1229 |
|
1230 |
+
// Compose a new caption, adding the file size.
|
|
|
|
|
1231 |
return self::_update_caption( $item_values, sprintf( '%1$s<br>Size: %2$s', $item_values['caption'], $file_size ) );
|
1232 |
}
|
1233 |
|
1234 |
+
// Our third example changes taxonomy terms into links to term-specific archive pages.
|
|
|
|
|
1235 |
if ( 'term gallery' == self::$shortcode_attributes['my_filter'] ) {
|
1236 |
/*
|
1237 |
* Use the "my_href" parameter to link to a static page,
|
1272 |
return $item_values;
|
1273 |
}
|
1274 |
|
1275 |
+
// For the fourth example, we compose a URL to allow file deletion and add it to the caption.
|
|
|
|
|
1276 |
if ( 'allow file deletion' == self::$shortcode_attributes['my_filter'] ) {
|
1277 |
$id = (integer) $item_values['attachment_ID'];
|
1278 |
if ( current_user_can( 'delete_post', $id ) ) {
|
1284 |
}
|
1285 |
}
|
1286 |
|
1287 |
+
// For the fifth example, we compose a caption with "Inserted in" links.
|
|
|
|
|
1288 |
if ( 'show post inserts' == self::$shortcode_attributes['my_filter'] ) {
|
1289 |
// You can use MLAShortcodes::mla_get_data_source() to get anything available.
|
1290 |
$my_setting = array(
|
1332 |
if ( 'all custom' != self::$shortcode_attributes['my_filter'] )
|
1333 |
return $item_values; // leave them unchanged
|
1334 |
|
1335 |
+
// Preserve the existing caption, if present
|
|
|
|
|
1336 |
$my_caption = '';
|
1337 |
if ( ! empty( $item_values['caption'] ) )
|
1338 |
$my_caption .= $item_values['caption'] . "<br />\r\n";
|
1355 |
* Some of the values you might find useful are:
|
1356 |
* _wp_attached_file, _wp_attachment_metadata, and _wp_attachment_image_alt
|
1357 |
*/
|
1358 |
+
if ( '_' == $post_meta_key[0] )
|
1359 |
continue;
|
1360 |
|
1361 |
/*
|
1377 |
}
|
1378 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_item_values $custom_fields = ' . var_export( $custom_fields, true ), 0 );
|
1379 |
|
1380 |
+
// Don't alter the caption if there are no custom fields to display
|
|
|
|
|
1381 |
if ( empty( $custom_fields ) )
|
1382 |
return $item_values;
|
1383 |
|
1384 |
+
// Add the definition list to the caption
|
|
|
|
|
1385 |
$my_caption .= "<dl class=\"custom_field\">\r\n";
|
1386 |
foreach ( $custom_fields as $key => $value ) {
|
1387 |
$my_caption .= "<dt class=\"name\">{$key}</dt>\r\n";
|
1389 |
} // foreach custom field
|
1390 |
$my_caption .= "</dl>";
|
1391 |
|
1392 |
+
// Update the $item_values and pass them back from the filter.
|
|
|
|
|
1393 |
$item_values = self::_update_caption( $item_values, $my_caption );
|
1394 |
return $item_values;
|
1395 |
} // mla_gallery_item_values
|
1528 |
|
1529 |
} // Class MLAGalleryHooksExample
|
1530 |
|
1531 |
+
// Install the filters at an early opportunity
|
|
|
|
|
1532 |
add_action('init', 'MLAGalleryHooksExample::initialize');
|
1533 |
?>
|
examples/plugins/mla-item-transfer-pretty-links.php
CHANGED
@@ -9,8 +9,12 @@
|
|
9 |
* opened on 8/19/2017 by "lwcorp".
|
10 |
* https://wordpress.org/support/topic/how-about-mla_gallery-listmask/
|
11 |
*
|
|
|
|
|
|
|
|
|
12 |
* @package MLA Item Transfer Pretty Links
|
13 |
-
* @version 1.
|
14 |
*/
|
15 |
|
16 |
/*
|
@@ -18,7 +22,7 @@ Plugin Name: MLA Item Transfer Pretty Links
|
|
18 |
Plugin URI: http://davidlingren.com/
|
19 |
Description: Converts "Transfer by Item Name" links to pretty links, adds URL rewrite rule to convert them back.
|
20 |
Author: David Lingren
|
21 |
-
Version: 1.
|
22 |
|
23 |
Author URI: http://davidlingren.com/
|
24 |
|
@@ -55,7 +59,7 @@ class MLAItemTransferPrettyLinks {
|
|
55 |
*
|
56 |
* @var string
|
57 |
*/
|
58 |
-
const CURRENT_VERSION = '1.
|
59 |
|
60 |
/**
|
61 |
* Slug prefix for registering and enqueueing submenu pages, style sheets and scripts
|
@@ -264,6 +268,7 @@ class MLAItemTransferPrettyLinks {
|
|
264 |
echo "\t\t" . '<form action="' . admin_url( 'options-general.php?page=' . self::SLUG_PREFIX . 'settings' ) . '" method="post" class="' . self::SLUG_PREFIX . 'settings-form-class" id="' . self::SLUG_PREFIX . 'settings-form-id">' . "\n";
|
265 |
echo "\t\t" . ' <p class="submit" style="padding-bottom: 0;">' . "\n";
|
266 |
echo "\t\t" . ' <table width=99%>' . "\n";
|
|
|
267 |
|
268 |
echo "\t\t" . ' <tr><td colspan=2>Enter the "pretty link" elements for your site, then click Save Settings.</td></tr>' . "\n";
|
269 |
echo "\t\t" . ' <tr><td colspan=2>Make sure the labels do not conflict with other WordPress elements, e.g., Custom Post Types.</td></tr>' . "\n";
|
9 |
* opened on 8/19/2017 by "lwcorp".
|
10 |
* https://wordpress.org/support/topic/how-about-mla_gallery-listmask/
|
11 |
*
|
12 |
+
* Enhanced (settings screen notes) for support topic "Cannot open PDFs"
|
13 |
+
* opened on 5/10/2022 by "gerdski".
|
14 |
+
* https://wordpress.org/support/topic/cannot-open-pdfs/
|
15 |
+
*
|
16 |
* @package MLA Item Transfer Pretty Links
|
17 |
+
* @version 1.02
|
18 |
*/
|
19 |
|
20 |
/*
|
22 |
Plugin URI: http://davidlingren.com/
|
23 |
Description: Converts "Transfer by Item Name" links to pretty links, adds URL rewrite rule to convert them back.
|
24 |
Author: David Lingren
|
25 |
+
Version: 1.02
|
26 |
|
27 |
Author URI: http://davidlingren.com/
|
28 |
|
59 |
*
|
60 |
* @var string
|
61 |
*/
|
62 |
+
const CURRENT_VERSION = '1.02';
|
63 |
|
64 |
/**
|
65 |
* Slug prefix for registering and enqueueing submenu pages, style sheets and scripts
|
268 |
echo "\t\t" . '<form action="' . admin_url( 'options-general.php?page=' . self::SLUG_PREFIX . 'settings' ) . '" method="post" class="' . self::SLUG_PREFIX . 'settings-form-class" id="' . self::SLUG_PREFIX . 'settings-form-id">' . "\n";
|
269 |
echo "\t\t" . ' <p class="submit" style="padding-bottom: 0;">' . "\n";
|
270 |
echo "\t\t" . ' <table width=99%>' . "\n";
|
271 |
+
echo "\t\t" . ' <tr><td colspan=2>The <code>mla_named_transfer=true</code> parameter implements the “simple” approach described in the Settings/Media Library Assistant Documentation tab. The example plugin adds the “more complex” alternative, transforming the links from the <code>admin-ajax.php</code> format to something like:<br /> <br /><code>http://www.mysite.com/mla-transfer/view/my-item-slug<br />http://www.mysite.com/mla-transfer/download/my-item-slug</code><br /> <br />The example plugin adds a Settings/MLA Pretty Links page that allows you to change the “mla-transfer”, “download” and “view” portions of the pretty links. It will transform any [mla_gallery] shortcode containing a <code>mla_named_transfer=true</code> parameter.<br /> <br /></td></tr>' . "\n";
|
272 |
|
273 |
echo "\t\t" . ' <tr><td colspan=2>Enter the "pretty link" elements for your site, then click Save Settings.</td></tr>' . "\n";
|
274 |
echo "\t\t" . ' <tr><td colspan=2>Make sure the labels do not conflict with other WordPress elements, e.g., Custom Post Types.</td></tr>' . "\n";
|
examples/plugins/mla-list-table-hooks-example.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Provides an example of hooking
|
4 |
*
|
5 |
* @package MLA List Table Hooks Example
|
6 |
-
* @version 1.
|
7 |
*/
|
8 |
|
9 |
/*
|
10 |
Plugin Name: MLA List Table Hooks Example
|
11 |
Plugin URI: http://davidlingren.com/
|
12 |
-
Description: Provides an example of hooking
|
13 |
Author: David Lingren
|
14 |
-
Version: 1.
|
15 |
Author URI: http://davidlingren.com/
|
16 |
|
17 |
-
Copyright 2014 -
|
18 |
|
19 |
This program is free software; you can redistribute it and/or modify
|
20 |
it under the terms of the GNU General Public License as published by
|
@@ -98,19 +98,24 @@ class MLAListTableHooksExample {
|
|
98 |
|
99 |
add_filter( 'mla_list_table_single_action', 'MLAListTableHooksExample::mla_list_table_single_action', 10, 3 );
|
100 |
add_filter( 'mla_list_table_custom_single_action', 'MLAListTableHooksExample::mla_list_table_custom_single_action', 10, 3 );
|
101 |
-
add_action( 'mla_list_table_clear_filter_by', 'MLAListTableHooksExample::mla_list_table_clear_filter_by' );
|
102 |
add_filter( 'mla_list_table_new_instance', 'MLAListTableHooksExample::mla_list_table_new_instance', 10, 1 );
|
|
|
103 |
add_filter( 'mla_list_table_inline_values', 'MLAListTableHooksExample::mla_list_table_inline_values', 10, 1 );
|
104 |
-
add_filter( 'mla_list_table_inline_template', 'MLAListTableHooksExample::
|
105 |
add_filter( 'mla_list_table_inline_parse', 'MLAListTableHooksExample::mla_list_table_inline_parse', 10, 3 );
|
106 |
|
|
|
|
|
|
|
|
|
107 |
add_filter( 'mla_list_table_inline_blank_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
108 |
add_filter( 'mla_list_table_inline_initial_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
109 |
add_filter( 'mla_list_table_inline_preset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
110 |
|
111 |
-
add_filter( 'mla_list_table_inline_blank_template', 'MLAListTableHooksExample::
|
112 |
-
add_filter( 'mla_list_table_inline_initial_template', 'MLAListTableHooksExample::
|
113 |
-
add_filter( 'mla_list_table_inline_preset_template', 'MLAListTableHooksExample::
|
114 |
|
115 |
// Defined in /media-library-assistant/includes/class-mla-list-table.php
|
116 |
add_filter( 'mla_list_table_get_columns', 'MLAListTableHooksExample::mla_list_table_get_columns', 10, 1 );
|
@@ -139,13 +144,17 @@ class MLAListTableHooksExample {
|
|
139 |
add_filter( 'mla_upload_bulk_edit_form_template', 'MLAListTableHooksExample::mla_upload_bulk_edit_form_template', 10, 1 );
|
140 |
add_filter( 'mla_upload_bulk_edit_form_parse', 'MLAListTableHooksExample::mla_upload_bulk_edit_form_parse', 10, 3 );
|
141 |
|
|
|
|
|
|
|
|
|
142 |
add_filter( 'mla_upload_bulk_edit_form_blank_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
143 |
add_filter( 'mla_upload_bulk_edit_form_initial_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
144 |
add_filter( 'mla_upload_bulk_edit_form_preset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
145 |
|
146 |
-
add_filter( 'mla_upload_bulk_edit_form_blank_template', 'MLAListTableHooksExample::
|
147 |
-
add_filter( 'mla_upload_bulk_edit_form_initial_template', 'MLAListTableHooksExample::
|
148 |
-
add_filter( 'mla_upload_bulk_edit_form_preset_template', 'MLAListTableHooksExample::
|
149 |
}
|
150 |
|
151 |
/**
|
@@ -167,6 +176,7 @@ class MLAListTableHooksExample {
|
|
167 |
* Filter the list table Bulk Actions drop-down
|
168 |
*
|
169 |
* This filter gives you an opportunity to filter the list table Bulk Actions drop-down.
|
|
|
170 |
*
|
171 |
* @since 1.00
|
172 |
*
|
@@ -227,67 +237,6 @@ class MLAListTableHooksExample {
|
|
227 |
return $sortable_columns;
|
228 |
} // manage_media_page_mla_menu_sortable_columns
|
229 |
|
230 |
-
/**
|
231 |
-
* Records the list of active search fields
|
232 |
-
*
|
233 |
-
* @since 1.00
|
234 |
-
*
|
235 |
-
* @var array
|
236 |
-
*/
|
237 |
-
private static $search_fields = array();
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Process the list of fields for keywords search
|
241 |
-
*
|
242 |
-
* This filter gives you an opportunity to add or remove any of the MLA standard fields for Search Media.
|
243 |
-
*
|
244 |
-
* @since 1.00
|
245 |
-
*
|
246 |
-
* @param array $active_fields Fields that will be searched.
|
247 |
-
* @param array $all_fields All of the fields that can be searched.
|
248 |
-
*/
|
249 |
-
public static function mla_list_table_search_filter_fields( $active_fields, $all_fields ) {
|
250 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $active_fields = ' . var_export( $active_fields, true ), 0 );
|
251 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $all_fields = ' . var_export( $all_fields, true ), 0 );
|
252 |
-
|
253 |
-
if ( in_array( 'name', $active_fields ) ) {
|
254 |
-
/* Uncomment next line to add File URL (guid) to the list of active search fields
|
255 |
-
when the "Name" box below the Search Media text box is checked */
|
256 |
-
//$active_fields[] = 'guid';
|
257 |
-
}
|
258 |
-
|
259 |
-
// Uncomment next line to ALWAYS add File URL (guid) to the list of active search fields
|
260 |
-
//$active_fields[] = 'guid';
|
261 |
-
self::$search_fields = $active_fields;
|
262 |
-
|
263 |
-
return $active_fields;
|
264 |
-
} // mla_list_table_search_filter_fields
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Process the inner WHERE clause for keywords search
|
268 |
-
*
|
269 |
-
* This filter gives you an opportunity to modify or add to the inner WHERE clause for Search Media.
|
270 |
-
*
|
271 |
-
* @since 1.00
|
272 |
-
*
|
273 |
-
* @param string $inner_clause Current SQL inner WHERE clause.
|
274 |
-
* @param string $inner_connector AND/OR connector between the search field clauses.
|
275 |
-
* @param string $wpdb_posts Name of the POSTS database table.
|
276 |
-
* @param string $sql_term Keyword value for the search.
|
277 |
-
*/
|
278 |
-
public static function mla_list_table_search_filter_inner_clause( $inner_clause, $inner_connector, $wpdb_posts, $sql_term ) {
|
279 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $inner_clause = ' . var_export( $inner_clause, true ), 0 );
|
280 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $inner_connector = ' . var_export( $inner_connector, true ), 0 );
|
281 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $wpdb_posts = ' . var_export( $wpdb_posts, true ), 0 );
|
282 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $sql_term = ' . var_export( $sql_term, true ), 0 );
|
283 |
-
|
284 |
-
if ( in_array( 'guid', self::$search_fields ) ) {
|
285 |
-
$inner_clause .= "{$inner_connector}({$wpdb_posts}.guid LIKE {$sql_term})";
|
286 |
-
}
|
287 |
-
|
288 |
-
return $inner_clause;
|
289 |
-
} // mla_list_table_search_filter_inner_clause
|
290 |
-
|
291 |
/**
|
292 |
* Pre-process the Edit Taxonomy submenu table columns
|
293 |
*
|
@@ -350,6 +299,104 @@ class MLAListTableHooksExample {
|
|
350 |
return $filter_content;
|
351 |
} // mla_taxonomy_column_final
|
352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
/**
|
354 |
* Process the "where-used" reference reporting results
|
355 |
*
|
@@ -433,25 +480,6 @@ class MLAListTableHooksExample {
|
|
433 |
//error_log( 'MLAListTableHooksExample::mla_updated_single_item $result = ' . var_export( $result, true ), 0 );
|
434 |
} // mla_updated_single_item
|
435 |
|
436 |
-
/**
|
437 |
-
* Pre-process an MLA_List_Table admin action
|
438 |
-
*
|
439 |
-
* This filter gives you an opportunity to pre-process an MLA_List_Table item-level action,
|
440 |
-
* standard or custom, before the MLA handler. This filter is called before anything is output
|
441 |
-
* for the Media/Assistant submenu, so you can redirect to another admin screen if desired.
|
442 |
-
*
|
443 |
-
* @since 1.03
|
444 |
-
*
|
445 |
-
* @param boolean $process_action true, to let MLA process the requested action.
|
446 |
-
* @param string $mla_admin_action The requested action.
|
447 |
-
* @param integer $mla_item_ID Zero (0), or the affected attachment.
|
448 |
-
*/
|
449 |
-
public static function mla_list_table_admin_action( $process_action, $mla_admin_action, $mla_item_ID ) {
|
450 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_admin_action $mla_admin_action = ' . var_export( $mla_admin_action, true ), 0 );
|
451 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_admin_action $mla_item_ID = ' . var_export( $mla_item_ID, true ), 0 );
|
452 |
-
return $process_action;
|
453 |
-
} // mla_list_table_admin_action
|
454 |
-
|
455 |
/**
|
456 |
* Load the MLA_List_Table dropdown help menu template
|
457 |
*
|
@@ -473,6 +501,25 @@ class MLAListTableHooksExample {
|
|
473 |
return $template_array;
|
474 |
} // mla_list_table_help_template
|
475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
/**
|
477 |
* Process an MLA_List_Table custom admin action
|
478 |
*
|
@@ -490,6 +537,21 @@ class MLAListTableHooksExample {
|
|
490 |
//error_log( 'MLAListTableHooksExample::mla_list_table_custom_admin_action $mla_item_ID = ' . var_export( $mla_item_ID, true ), 0 );
|
491 |
} // mla_list_table_custom_admin_action
|
492 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
/**
|
494 |
* Process an MLA_List_Table inline action, i.e., Quick Edit
|
495 |
*
|
@@ -739,70 +801,83 @@ class MLAListTableHooksExample {
|
|
739 |
} // mla_list_table_inline_values
|
740 |
|
741 |
/**
|
742 |
-
* MLA_List_Table
|
743 |
*
|
744 |
-
* This filter gives you a chance to modify and extend the
|
745 |
-
* for the
|
746 |
*
|
747 |
-
* @since 1.
|
748 |
*
|
749 |
-
* @param
|
750 |
*/
|
751 |
-
public static function
|
752 |
-
//error_log( 'MLAListTableHooksExample::
|
753 |
-
|
754 |
-
|
755 |
-
* You can use the 'filter_root' element to distinguish among :
|
756 |
-
* mla_list_table_inline_blank_values,
|
757 |
-
* mla_list_table_inline_initial_values,
|
758 |
-
* mla_list_table_inline_preset_values
|
759 |
-
*/
|
760 |
-
//error_log( "MLAListTableHooksExample::mla_list_table_bulk_values filter_root = {$item_values['filter_root']}", 0 );
|
761 |
-
|
762 |
-
return $item_values;
|
763 |
-
} // mla_list_table_bulk_values
|
764 |
|
765 |
/**
|
766 |
-
* MLA_List_Table inline edit
|
767 |
-
*
|
768 |
-
* This filter gives you a chance to modify and extend the template used
|
769 |
-
* for the Quick and Bulk Edit forms.
|
770 |
*
|
771 |
* @since 1.00
|
772 |
*
|
|
|
|
|
|
|
|
|
773 |
* @param string $item_template Template used to generate the HTML markup
|
774 |
* @param array $item_values [ parameter_name => parameter_value ] pairs
|
775 |
*/
|
776 |
-
public static function
|
777 |
-
//error_log( 'MLAListTableHooksExample::
|
|
|
|
|
|
|
|
|
778 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
779 |
/*
|
780 |
-
* You can use the 'filter_root'
|
781 |
-
*
|
782 |
-
*
|
783 |
-
*
|
784 |
*/
|
785 |
-
//error_log( "MLAListTableHooksExample::
|
786 |
|
787 |
-
return $
|
788 |
-
} //
|
789 |
|
790 |
/**
|
791 |
-
* MLA_List_Table item bulk edit
|
792 |
*
|
793 |
-
* This filter gives you a chance to modify and extend the
|
794 |
* for the three Bulk Edit form fieldsets.
|
795 |
*
|
796 |
* @since 1.10
|
797 |
*
|
798 |
-
* @param array $
|
799 |
*/
|
800 |
-
public static function
|
801 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_bulk_values $
|
802 |
|
803 |
/*
|
804 |
* You can use the 'filter_root' element to distinguish among :
|
805 |
-
*
|
|
|
|
|
|
|
|
|
|
|
806 |
*/
|
807 |
//error_log( "MLAListTableHooksExample::mla_list_table_bulk_values filter_root = {$item_values['filter_root']}", 0 );
|
808 |
|
@@ -810,23 +885,33 @@ class MLAListTableHooksExample {
|
|
810 |
} // mla_list_table_bulk_values
|
811 |
|
812 |
/**
|
813 |
-
* MLA_List_Table
|
814 |
*
|
815 |
-
*
|
|
|
816 |
*
|
817 |
-
*
|
818 |
-
* markup used for the Quick and Bulk Edit forms.
|
819 |
*
|
820 |
-
* @param
|
821 |
-
* @param string $item_template Template used to generate the HTML markup
|
822 |
* @param array $item_values [ parameter_name => parameter_value ] pairs
|
823 |
*/
|
824 |
-
public static function
|
825 |
-
//error_log( 'MLAListTableHooksExample::
|
826 |
-
//error_log( 'MLAListTableHooksExample::
|
827 |
-
|
828 |
-
|
829 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
|
831 |
/**
|
832 |
* Filter the MLA_List_Table columns
|
@@ -1022,43 +1107,6 @@ class MLAListTableHooksExample {
|
|
1022 |
return $items;
|
1023 |
} // mla_list_table_prepare_items_the_items
|
1024 |
|
1025 |
-
/**
|
1026 |
-
* Filter the WP_Query request parameters for the prepare_items query
|
1027 |
-
*
|
1028 |
-
* Gives you an opportunity to change the terms of the prepare_items query
|
1029 |
-
* after they are processed by the "Prepare List Table Query" handler.
|
1030 |
-
*
|
1031 |
-
* @since 1.03
|
1032 |
-
*
|
1033 |
-
* @param array $request WP_Query request prepared by "Prepare List Table Query"
|
1034 |
-
*/
|
1035 |
-
public static function mla_list_table_query_final_terms( $request ) {
|
1036 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_query_final_terms $request = ' . var_export( $request, true ), 0 );
|
1037 |
-
|
1038 |
-
return $request;
|
1039 |
-
} // mla_list_table_query_final_terms
|
1040 |
-
|
1041 |
-
/**
|
1042 |
-
* Replace the prepare_items WP_Query object with your own results
|
1043 |
-
*
|
1044 |
-
* Gives you an opportunity to substitute the results of the prepare_items query
|
1045 |
-
* with alternative results of your own.
|
1046 |
-
*
|
1047 |
-
* @since 1.03
|
1048 |
-
*
|
1049 |
-
* @param object $wp_query_object NULL, indicating no results substitution
|
1050 |
-
* @param array $request WP_Query request prepared by "Prepare List Table Query"
|
1051 |
-
*/
|
1052 |
-
public static function mla_list_table_query_custom_items( $wp_query_object, $request ) {
|
1053 |
-
//error_log( 'MLAListTableHooksExample::mla_media_modal_query_custom_items $request = ' . var_export( $request, true ), 0 );
|
1054 |
-
|
1055 |
-
/*
|
1056 |
-
* You can replace the NULL $wp_query_object with a new WP_Query( $request )
|
1057 |
-
* object using your own $request parameters
|
1058 |
-
*/
|
1059 |
-
return $wp_query_object;
|
1060 |
-
} // mla_media_modal_query_custom_items
|
1061 |
-
|
1062 |
/**
|
1063 |
* Inspect or modify the results of prepare_items()
|
1064 |
*
|
@@ -1095,21 +1143,6 @@ class MLAListTableHooksExample {
|
|
1095 |
return $actions;
|
1096 |
} // mla_list_table_build_rollover_actions
|
1097 |
|
1098 |
-
/**
|
1099 |
-
* Define the fields for inline (Quick) editing
|
1100 |
-
*
|
1101 |
-
* This filter gives you an opportunity to name the fields passed to the
|
1102 |
-
* JavaScript functions for Quick editing.
|
1103 |
-
*
|
1104 |
-
* @since 1.00
|
1105 |
-
*
|
1106 |
-
* @param array $fields The field names for inline data.
|
1107 |
-
*/
|
1108 |
-
public static function mla_list_table_inline_fields( $fields ) {
|
1109 |
-
//error_log( 'MLAListTableHooksExample::mla_list_table_inline_fields $fields = ' . var_export( $fields, true ), 0 );
|
1110 |
-
return $fields;
|
1111 |
-
} // mla_list_table_inline_fields
|
1112 |
-
|
1113 |
/**
|
1114 |
* Filter the data for inline (Quick and Bulk) editing
|
1115 |
*
|
@@ -1192,8 +1225,6 @@ class MLAListTableHooksExample {
|
|
1192 |
} // mla_upload_bulk_edit_form_parse
|
1193 |
} // Class MLAListTableHooksExample
|
1194 |
|
1195 |
-
|
1196 |
-
* Install the filters at an early opportunity
|
1197 |
-
*/
|
1198 |
add_action('init', 'MLAListTableHooksExample::initialize');
|
1199 |
?>
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Provides an example of hooking all actions and filters provided for the Media/Assistant Submenu Screen
|
4 |
*
|
5 |
* @package MLA List Table Hooks Example
|
6 |
+
* @version 1.12
|
7 |
*/
|
8 |
|
9 |
/*
|
10 |
Plugin Name: MLA List Table Hooks Example
|
11 |
Plugin URI: http://davidlingren.com/
|
12 |
+
Description: Provides an example of hooking all actions and filters provided for the Media/Assistant Submenu Screen
|
13 |
Author: David Lingren
|
14 |
+
Version: 1.12
|
15 |
Author URI: http://davidlingren.com/
|
16 |
|
17 |
+
Copyright 2014 - 2022 David Lingren
|
18 |
|
19 |
This program is free software; you can redistribute it and/or modify
|
20 |
it under the terms of the GNU General Public License as published by
|
98 |
|
99 |
add_filter( 'mla_list_table_single_action', 'MLAListTableHooksExample::mla_list_table_single_action', 10, 3 );
|
100 |
add_filter( 'mla_list_table_custom_single_action', 'MLAListTableHooksExample::mla_list_table_custom_single_action', 10, 3 );
|
101 |
+
add_action( 'mla_list_table_clear_filter_by', 'MLAListTableHooksExample::mla_list_table_clear_filter_by', 10, 0 );
|
102 |
add_filter( 'mla_list_table_new_instance', 'MLAListTableHooksExample::mla_list_table_new_instance', 10, 1 );
|
103 |
+
|
104 |
add_filter( 'mla_list_table_inline_values', 'MLAListTableHooksExample::mla_list_table_inline_values', 10, 1 );
|
105 |
+
add_filter( 'mla_list_table_inline_template', 'MLAListTableHooksExample::mla_list_table_bulk_template', 10, 1 );
|
106 |
add_filter( 'mla_list_table_inline_parse', 'MLAListTableHooksExample::mla_list_table_inline_parse', 10, 3 );
|
107 |
|
108 |
+
add_filter( 'mla_list_table_inline_blank_fieldset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_fieldset_values', 10, 2 );
|
109 |
+
add_filter( 'mla_list_table_inline_initial_fieldset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_fieldset_values', 10, 2 );
|
110 |
+
add_filter( 'mla_list_table_inline_preset_fieldset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_fieldset_values', 10, 2 );
|
111 |
+
|
112 |
add_filter( 'mla_list_table_inline_blank_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
113 |
add_filter( 'mla_list_table_inline_initial_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
114 |
add_filter( 'mla_list_table_inline_preset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
115 |
|
116 |
+
add_filter( 'mla_list_table_inline_blank_template', 'MLAListTableHooksExample::mla_list_table_inline_bulk_template', 10, 2 );
|
117 |
+
add_filter( 'mla_list_table_inline_initial_template', 'MLAListTableHooksExample::mla_list_table_inline_bulk_template', 10, 2 );
|
118 |
+
add_filter( 'mla_list_table_inline_preset_template', 'MLAListTableHooksExample::mla_list_table_inline_bulk_template', 10, 2 );
|
119 |
|
120 |
// Defined in /media-library-assistant/includes/class-mla-list-table.php
|
121 |
add_filter( 'mla_list_table_get_columns', 'MLAListTableHooksExample::mla_list_table_get_columns', 10, 1 );
|
144 |
add_filter( 'mla_upload_bulk_edit_form_template', 'MLAListTableHooksExample::mla_upload_bulk_edit_form_template', 10, 1 );
|
145 |
add_filter( 'mla_upload_bulk_edit_form_parse', 'MLAListTableHooksExample::mla_upload_bulk_edit_form_parse', 10, 3 );
|
146 |
|
147 |
+
add_filter( 'mla_upload_bulk_edit_form_blank_fieldset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_fieldset_values', 10, 2 );
|
148 |
+
add_filter( 'mla_upload_bulk_edit_form_initial_fieldset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_fieldset_values', 10, 2 );
|
149 |
+
add_filter( 'mla_upload_bulk_edit_form_preset_fieldset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_fieldset_values', 10, 2 );
|
150 |
+
|
151 |
add_filter( 'mla_upload_bulk_edit_form_blank_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
152 |
add_filter( 'mla_upload_bulk_edit_form_initial_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
153 |
add_filter( 'mla_upload_bulk_edit_form_preset_values', 'MLAListTableHooksExample::mla_list_table_inline_bulk_values', 10, 1 );
|
154 |
|
155 |
+
add_filter( 'mla_upload_bulk_edit_form_blank_template', 'MLAListTableHooksExample::mla_list_table_inline_bulk_template', 10, 2 );
|
156 |
+
add_filter( 'mla_upload_bulk_edit_form_initial_template', 'MLAListTableHooksExample::mla_list_table_inline_bulk_template', 10, 2 );
|
157 |
+
add_filter( 'mla_upload_bulk_edit_form_preset_template', 'MLAListTableHooksExample::mla_list_table_inline_bulk_template', 10, 2 );
|
158 |
}
|
159 |
|
160 |
/**
|
176 |
* Filter the list table Bulk Actions drop-down
|
177 |
*
|
178 |
* This filter gives you an opportunity to filter the list table Bulk Actions drop-down.
|
179 |
+
* This WordPress filter can currently only be used to remove bulk actions.
|
180 |
*
|
181 |
* @since 1.00
|
182 |
*
|
237 |
return $sortable_columns;
|
238 |
} // manage_media_page_mla_menu_sortable_columns
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
/**
|
241 |
* Pre-process the Edit Taxonomy submenu table columns
|
242 |
*
|
299 |
return $filter_content;
|
300 |
} // mla_taxonomy_column_final
|
301 |
|
302 |
+
/**
|
303 |
+
* Filter the WP_Query request parameters for the prepare_items query
|
304 |
+
*
|
305 |
+
* Gives you an opportunity to change the terms of the prepare_items query
|
306 |
+
* after they are processed by the "Prepare List Table Query" handler.
|
307 |
+
*
|
308 |
+
* @since 1.03
|
309 |
+
*
|
310 |
+
* @param array $request WP_Query request prepared by "Prepare List Table Query"
|
311 |
+
*/
|
312 |
+
public static function mla_list_table_query_final_terms( $request ) {
|
313 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_query_final_terms $request = ' . var_export( $request, true ), 0 );
|
314 |
+
|
315 |
+
return $request;
|
316 |
+
} // mla_list_table_query_final_terms
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Replace the prepare_items WP_Query object with your own results
|
320 |
+
*
|
321 |
+
* Gives you an opportunity to substitute the results of the prepare_items query
|
322 |
+
* with alternative results of your own.
|
323 |
+
*
|
324 |
+
* @since 1.03
|
325 |
+
*
|
326 |
+
* @param object $wp_query_object NULL, indicating no results substitution
|
327 |
+
* @param array $request WP_Query request prepared by "Prepare List Table Query"
|
328 |
+
*/
|
329 |
+
public static function mla_list_table_query_custom_items( $wp_query_object, $request ) {
|
330 |
+
//error_log( 'MLAListTableHooksExample::mla_media_modal_query_custom_items $request = ' . var_export( $request, true ), 0 );
|
331 |
+
|
332 |
+
/*
|
333 |
+
* You can replace the NULL $wp_query_object with a new WP_Query( $request )
|
334 |
+
* object using your own $request parameters
|
335 |
+
*/
|
336 |
+
return $wp_query_object;
|
337 |
+
} // mla_media_modal_query_custom_items
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Records the list of active search fields
|
341 |
+
*
|
342 |
+
* @since 1.00
|
343 |
+
*
|
344 |
+
* @var array
|
345 |
+
*/
|
346 |
+
private static $search_fields = array();
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Process the list of fields for keywords search
|
350 |
+
*
|
351 |
+
* This filter gives you an opportunity to add or remove any of the MLA standard fields for Search Media.
|
352 |
+
*
|
353 |
+
* @since 1.00
|
354 |
+
*
|
355 |
+
* @param array $active_fields Fields that will be searched.
|
356 |
+
* @param array $all_fields All of the fields that can be searched.
|
357 |
+
*/
|
358 |
+
public static function mla_list_table_search_filter_fields( $active_fields, $all_fields ) {
|
359 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $active_fields = ' . var_export( $active_fields, true ), 0 );
|
360 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $all_fields = ' . var_export( $all_fields, true ), 0 );
|
361 |
+
|
362 |
+
if ( in_array( 'name', $active_fields ) ) {
|
363 |
+
/* Uncomment next line to add File URL (guid) to the list of active search fields
|
364 |
+
when the "Name" box below the Search Media text box is checked */
|
365 |
+
//$active_fields[] = 'guid';
|
366 |
+
}
|
367 |
+
|
368 |
+
// Uncomment next line to ALWAYS add File URL (guid) to the list of active search fields
|
369 |
+
//$active_fields[] = 'guid';
|
370 |
+
self::$search_fields = $active_fields;
|
371 |
+
|
372 |
+
return $active_fields;
|
373 |
+
} // mla_list_table_search_filter_fields
|
374 |
+
|
375 |
+
/**
|
376 |
+
* Process the inner WHERE clause for keywords search
|
377 |
+
*
|
378 |
+
* This filter gives you an opportunity to modify or add to the inner WHERE clause for Search Media.
|
379 |
+
*
|
380 |
+
* @since 1.00
|
381 |
+
*
|
382 |
+
* @param string $inner_clause Current SQL inner WHERE clause.
|
383 |
+
* @param string $inner_connector AND/OR connector between the search field clauses.
|
384 |
+
* @param string $wpdb_posts Name of the POSTS database table.
|
385 |
+
* @param string $sql_term Keyword value for the search.
|
386 |
+
*/
|
387 |
+
public static function mla_list_table_search_filter_inner_clause( $inner_clause, $inner_connector, $wpdb_posts, $sql_term ) {
|
388 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $inner_clause = ' . var_export( $inner_clause, true ), 0 );
|
389 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $inner_connector = ' . var_export( $inner_connector, true ), 0 );
|
390 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $wpdb_posts = ' . var_export( $wpdb_posts, true ), 0 );
|
391 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_search_filter_fields $sql_term = ' . var_export( $sql_term, true ), 0 );
|
392 |
+
|
393 |
+
if ( in_array( 'guid', self::$search_fields ) ) {
|
394 |
+
$inner_clause .= "{$inner_connector}({$wpdb_posts}.guid LIKE {$sql_term})";
|
395 |
+
}
|
396 |
+
|
397 |
+
return $inner_clause;
|
398 |
+
} // mla_list_table_search_filter_inner_clause
|
399 |
+
|
400 |
/**
|
401 |
* Process the "where-used" reference reporting results
|
402 |
*
|
480 |
//error_log( 'MLAListTableHooksExample::mla_updated_single_item $result = ' . var_export( $result, true ), 0 );
|
481 |
} // mla_updated_single_item
|
482 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
/**
|
484 |
* Load the MLA_List_Table dropdown help menu template
|
485 |
*
|
501 |
return $template_array;
|
502 |
} // mla_list_table_help_template
|
503 |
|
504 |
+
/**
|
505 |
+
* Pre-process an MLA_List_Table admin action
|
506 |
+
*
|
507 |
+
* This filter gives you an opportunity to pre-process an MLA_List_Table item-level action,
|
508 |
+
* standard or custom, before the MLA handler. This filter is called before anything is output
|
509 |
+
* for the Media/Assistant submenu, so you can redirect to another admin screen if desired.
|
510 |
+
*
|
511 |
+
* @since 1.03
|
512 |
+
*
|
513 |
+
* @param boolean $process_action true, to let MLA process the requested action.
|
514 |
+
* @param string $mla_admin_action The requested action.
|
515 |
+
* @param integer $mla_item_ID Zero (0), or the affected attachment.
|
516 |
+
*/
|
517 |
+
public static function mla_list_table_admin_action( $process_action, $mla_admin_action, $mla_item_ID ) {
|
518 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_admin_action $mla_admin_action = ' . var_export( $mla_admin_action, true ), 0 );
|
519 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_admin_action $mla_item_ID = ' . var_export( $mla_item_ID, true ), 0 );
|
520 |
+
return $process_action;
|
521 |
+
} // mla_list_table_admin_action
|
522 |
+
|
523 |
/**
|
524 |
* Process an MLA_List_Table custom admin action
|
525 |
*
|
537 |
//error_log( 'MLAListTableHooksExample::mla_list_table_custom_admin_action $mla_item_ID = ' . var_export( $mla_item_ID, true ), 0 );
|
538 |
} // mla_list_table_custom_admin_action
|
539 |
|
540 |
+
/**
|
541 |
+
* Define the fields for inline (Quick) editing
|
542 |
+
*
|
543 |
+
* This filter gives you an opportunity to name the fields passed to the
|
544 |
+
* JavaScript functions for Quick editing.
|
545 |
+
*
|
546 |
+
* @since 1.00
|
547 |
+
*
|
548 |
+
* @param array $fields The field names for inline data.
|
549 |
+
*/
|
550 |
+
public static function mla_list_table_inline_fields( $fields ) {
|
551 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_inline_fields $fields = ' . var_export( $fields, true ), 0 );
|
552 |
+
return $fields;
|
553 |
+
} // mla_list_table_inline_fields
|
554 |
+
|
555 |
/**
|
556 |
* Process an MLA_List_Table inline action, i.e., Quick Edit
|
557 |
*
|
801 |
} // mla_list_table_inline_values
|
802 |
|
803 |
/**
|
804 |
+
* MLA_List_Table inline edit template
|
805 |
*
|
806 |
+
* This filter gives you a chance to modify and extend the template used
|
807 |
+
* for the Quick and Bulk Edit forms.
|
808 |
*
|
809 |
+
* @since 1.00
|
810 |
*
|
811 |
+
* @param string $item_template Template used to generate the HTML markup
|
812 |
*/
|
813 |
+
public static function mla_list_table_inline_template( $item_template ) {
|
814 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_inline_template $item_template = ' . var_export( $item_template, true ), 0 );
|
815 |
+
return $item_template;
|
816 |
+
} // mla_list_table_inline_template
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
817 |
|
818 |
/**
|
819 |
+
* MLA_List_Table inline edit parse
|
|
|
|
|
|
|
820 |
*
|
821 |
* @since 1.00
|
822 |
*
|
823 |
+
* This filter gives you a final chance to modify and extend the HTML
|
824 |
+
* markup used for the Quick and Bulk Edit forms.
|
825 |
+
*
|
826 |
+
* @param string $html_markup HTML markup returned by the template parser
|
827 |
* @param string $item_template Template used to generate the HTML markup
|
828 |
* @param array $item_values [ parameter_name => parameter_value ] pairs
|
829 |
*/
|
830 |
+
public static function mla_list_table_inline_parse( $html_markup, $item_template, $item_values ) {
|
831 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_inline_parse $html_markup = ' . var_export( $html_markup, true ), 0 );
|
832 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_inline_parse $item_template = ' . var_export( $item_template, true ), 0 );
|
833 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_inline_parse $item_values = ' . var_export( $item_values, true ), 0 );
|
834 |
+
return $html_markup;
|
835 |
+
} // mla_list_table_inline_parse
|
836 |
|
837 |
+
/**
|
838 |
+
* MLA_List_Table item bulk edit fieldset values
|
839 |
+
*
|
840 |
+
* This filter gives you a chance to modify the raw data used to populate
|
841 |
+
* the Bulk Edit on Upload form.
|
842 |
+
*
|
843 |
+
* @since 1.12
|
844 |
+
*
|
845 |
+
* @param array $fieldset_values data values to populate the form
|
846 |
+
* @param string $filter_root identify the blank, initial and preset fieldsets
|
847 |
+
*/
|
848 |
+
public static function mla_list_table_inline_bulk_fieldset_values( $fieldset_values, $filter_root ) {
|
849 |
/*
|
850 |
+
* You can use the 'filter_root' argument to distinguish among :
|
851 |
+
* mla_list_table_inline_blank_fieldset_values,
|
852 |
+
* mla_list_table_inline_initial_fieldset_values,
|
853 |
+
* mla_list_table_inline_preset_fieldset_values
|
854 |
*/
|
855 |
+
//error_log( __LINE__ . " MLAListTableHooksExample::mla_list_table_bulk_fieldset_values( {$filter_root} ) \$fieldset_values = " . var_export( $fieldset_values, true ), 0 );
|
856 |
|
857 |
+
return $fieldset_values;
|
858 |
+
} // mla_list_table_bulk_fieldset_values
|
859 |
|
860 |
/**
|
861 |
+
* MLA_List_Table item bulk edit substitution values
|
862 |
*
|
863 |
+
* This filter gives you a chance to modify and extend the substitution values
|
864 |
* for the three Bulk Edit form fieldsets.
|
865 |
*
|
866 |
* @since 1.10
|
867 |
*
|
868 |
+
* @param array $item_values [ parameter_name => parameter_value ] pairs
|
869 |
*/
|
870 |
+
public static function mla_list_table_inline_bulk_values( $item_values ) {
|
871 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_bulk_values $item_values = ' . var_export( $item_values, true ), 0 );
|
872 |
|
873 |
/*
|
874 |
* You can use the 'filter_root' element to distinguish among :
|
875 |
+
* 'mla_upload_bulk_edit_form_blank',
|
876 |
+
* 'mla_upload_bulk_edit_form_initial',
|
877 |
+
* 'mla_upload_bulk_edit_form_preset',
|
878 |
+
* 'mla_list_table_inline_blank',
|
879 |
+
* 'mla_list_table_inline_initial',
|
880 |
+
* 'mla_list_table_inline_preset'
|
881 |
*/
|
882 |
//error_log( "MLAListTableHooksExample::mla_list_table_bulk_values filter_root = {$item_values['filter_root']}", 0 );
|
883 |
|
885 |
} // mla_list_table_bulk_values
|
886 |
|
887 |
/**
|
888 |
+
* MLA_List_Table item bulk edit fieldset template
|
889 |
*
|
890 |
+
* This filter gives you a chance to modify and extend the template used
|
891 |
+
* for the three Bulk Edit form fieldsets.
|
892 |
*
|
893 |
+
* @since 1.10
|
|
|
894 |
*
|
895 |
+
* @param array $item_template Template used to generate the HTML markup
|
|
|
896 |
* @param array $item_values [ parameter_name => parameter_value ] pairs
|
897 |
*/
|
898 |
+
public static function mla_list_table_inline_bulk_template( $item_template, $item_values ) {
|
899 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_bulk_values $item_template = ' . var_export( $item_template, true ), 0 );
|
900 |
+
//error_log( 'MLAListTableHooksExample::mla_list_table_bulk_values $item_values = ' . var_export( $item_values, true ), 0 );
|
901 |
+
|
902 |
+
/*
|
903 |
+
* You can use the 'filter_root' element to distinguish among :
|
904 |
+
* 'mla_upload_bulk_edit_form_blank',
|
905 |
+
* 'mla_upload_bulk_edit_form_initial',
|
906 |
+
* 'mla_upload_bulk_edit_form_preset',
|
907 |
+
* 'mla_list_table_inline_blank',
|
908 |
+
* 'mla_list_table_inline_initial',
|
909 |
+
* 'mla_list_table_inline_preset'
|
910 |
+
*/
|
911 |
+
//error_log( "MLAListTableHooksExample::mla_list_table_bulk_template filter_root = {$item_values['filter_root']}", 0 );
|
912 |
+
|
913 |
+
return $item_template;
|
914 |
+
} // mla_list_table_bulk_template
|
915 |
|
916 |
/**
|
917 |
* Filter the MLA_List_Table columns
|
1107 |
return $items;
|
1108 |
} // mla_list_table_prepare_items_the_items
|
1109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1110 |
/**
|
1111 |
* Inspect or modify the results of prepare_items()
|
1112 |
*
|
1143 |
return $actions;
|
1144 |
} // mla_list_table_build_rollover_actions
|
1145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1146 |
/**
|
1147 |
* Filter the data for inline (Quick and Bulk) editing
|
1148 |
*
|
1225 |
} // mla_upload_bulk_edit_form_parse
|
1226 |
} // Class MLAListTableHooksExample
|
1227 |
|
1228 |
+
// Install the filters at an early opportunity
|
|
|
|
|
1229 |
add_action('init', 'MLAListTableHooksExample::initialize');
|
1230 |
?>
|
examples/plugins/mla-media-modal-hooks-example.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* - items assigned to a taxonomy term can be excluded from the "Query Attachments" results
|
8 |
*
|
9 |
* @package MLA Media Modal Hooks Example
|
10 |
-
* @version 1.
|
11 |
*/
|
12 |
|
13 |
/*
|
@@ -15,10 +15,10 @@ Plugin Name: MLA Media Modal Hooks Example
|
|
15 |
Plugin URI: http://davidlingren.com/
|
16 |
Description: Provides examples of the filters provided by the "Media Manager Enhancements" feature
|
17 |
Author: David Lingren
|
18 |
-
Version: 1.
|
19 |
Author URI: http://davidlingren.com/
|
20 |
|
21 |
-
Copyright 2014-
|
22 |
|
23 |
This program is free software; you can redistribute it and/or modify
|
24 |
it under the terms of the GNU General Public License as published by
|
@@ -87,6 +87,7 @@ class MLAMediaModalExample {
|
|
87 |
add_filter( 'mla_media_modal_end_update_compat_fields', 'MLAMediaModalExample::mla_media_modal_end_update_compat_fields', 10, 3 );
|
88 |
add_filter( 'mla_media_modal_query_initial_terms', 'MLAMediaModalExample::mla_media_modal_query_initial_terms', 10, 2 );
|
89 |
add_filter( 'mla_media_modal_query_filtered_terms', 'MLAMediaModalExample::mla_media_modal_query_filtered_terms', 10, 2 );
|
|
|
90 |
|
91 |
/*
|
92 |
* Defined in /media-library-assistant/includes/class-mla-data.php
|
@@ -399,6 +400,25 @@ class MLAMediaModalExample {
|
|
399 |
return $query;
|
400 |
} // mla_media_modal_query_filtered_terms
|
401 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
/**
|
403 |
* MLA Edit Media "Query Attachments" final terms Filter
|
404 |
*
|
7 |
* - items assigned to a taxonomy term can be excluded from the "Query Attachments" results
|
8 |
*
|
9 |
* @package MLA Media Modal Hooks Example
|
10 |
+
* @version 1.03
|
11 |
*/
|
12 |
|
13 |
/*
|
15 |
Plugin URI: http://davidlingren.com/
|
16 |
Description: Provides examples of the filters provided by the "Media Manager Enhancements" feature
|
17 |
Author: David Lingren
|
18 |
+
Version: 1.03
|
19 |
Author URI: http://davidlingren.com/
|
20 |
|
21 |
+
Copyright 2014-2022 David Lingren
|
22 |
|
23 |
This program is free software; you can redistribute it and/or modify
|
24 |
it under the terms of the GNU General Public License as published by
|
87 |
add_filter( 'mla_media_modal_end_update_compat_fields', 'MLAMediaModalExample::mla_media_modal_end_update_compat_fields', 10, 3 );
|
88 |
add_filter( 'mla_media_modal_query_initial_terms', 'MLAMediaModalExample::mla_media_modal_query_initial_terms', 10, 2 );
|
89 |
add_filter( 'mla_media_modal_query_filtered_terms', 'MLAMediaModalExample::mla_media_modal_query_filtered_terms', 10, 2 );
|
90 |
+
add_filter( 'mla_media_modal_query_items', 'MLAMediaModalExample::mla_media_modal_query_items', 10, 5 );
|
91 |
|
92 |
/*
|
93 |
* Defined in /media-library-assistant/includes/class-mla-data.php
|
400 |
return $query;
|
401 |
} // mla_media_modal_query_filtered_terms
|
402 |
|
403 |
+
/**
|
404 |
+
* MLA Media Modal Query Items
|
405 |
+
*
|
406 |
+
* Gives you an opportunity to Record or modify
|
407 |
+
* the results of the "mla_query_media_modal_items" query.
|
408 |
+
*
|
409 |
+
* @since 1.03
|
410 |
+
*
|
411 |
+
* @param object $attachments_query WP_Query results, passed by reference
|
412 |
+
* @param array $query query parameters passed to WP_Query
|
413 |
+
* @param array $raw_query query parameters passed in to function
|
414 |
+
* @param integer $offset parameter_name => parameter_value pairs
|
415 |
+
* @param integer $count parameter_name => parameter_value pairs
|
416 |
+
*/
|
417 |
+
public static function mla_media_modal_query_items( $attachments_query, $query, $raw_query, $offset, $count ) {
|
418 |
+
//error_log( __LINE__ . " MLAMediaModalExample::mla_media_modal_query_items( {$offset}, {$count} ) query = " . var_export( $query, true ), 0 );
|
419 |
+
//error_log( __LINE__ . " MLAMediaModalExample::mla_media_modal_query_items( {$offset}, {$count} ) raw_query = " . var_export( $raw_query, true ), 0 );
|
420 |
+
//error_log( __LINE__ . " MLAMediaModalExample::mla_media_modal_query_items( {$attachments_query->post_count}, {$attachments_query->found_posts} ) query_vars = " . var_export( $attachments_query->query_vars, true ), 0 );
|
421 |
+
} // mla_media_modal_query_items
|
422 |
/**
|
423 |
* MLA Edit Media "Query Attachments" final terms Filter
|
424 |
*
|
examples/plugins/mla-multisite-extensions.php
CHANGED
@@ -12,19 +12,23 @@
|
|
12 |
* opened on 7/12/2017 by "jeynon (@jeynon)".
|
13 |
* https://wordpress.org/support/topic/using-shortcodes-to-retrieve-media-from-another-sites-media-library/
|
14 |
*
|
|
|
|
|
|
|
|
|
15 |
* @package MLA Multisite Extensions
|
16 |
-
* @version 1.
|
17 |
*/
|
18 |
|
19 |
/*
|
20 |
Plugin Name: MLA Multisite Extensions
|
21 |
Plugin URI: http://davidlingren.com/
|
22 |
-
Description: Adds Multisite filters to MLA shortcodes
|
23 |
Author: David Lingren
|
24 |
-
Version: 1.
|
25 |
Author URI: http://davidlingren.com/
|
26 |
|
27 |
-
Copyright 2017 David Lingren
|
28 |
|
29 |
This program is free software; you can redistribute it and/or modify
|
30 |
it under the terms of the GNU General Public License as published by
|
@@ -61,6 +65,9 @@ class MLAMultisiteExtensions {
|
|
61 |
add_filter( 'mla_gallery_the_attachments', 'MLAMultisiteExtensions::mla_gallery_the_attachments', 10, 2 );
|
62 |
add_filter( 'mla_gallery_item_initial_values', 'MLAMultisiteExtensions::mla_gallery_item_initial_values', 10, 2 );
|
63 |
add_filter( 'mla_gallery_item_values', 'MLAMultisiteExtensions::mla_gallery_item_values', 10, 1 );
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
@@ -255,7 +262,7 @@ class MLAMultisiteExtensions {
|
|
255 |
} else {
|
256 |
unset( self::$shortcode_attributes['site_id'] );
|
257 |
}
|
258 |
-
}
|
259 |
|
260 |
return $all_query_parameters;
|
261 |
} // mla_gallery_query_arguments
|
@@ -571,6 +578,67 @@ class MLAMultisiteExtensions {
|
|
571 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_item_values $item_values = ' . var_export( $item_values, true ), 0 );
|
572 |
return $item_values;
|
573 |
} // mla_gallery_item_values
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
574 |
} // MLAMultisiteExtensions
|
575 |
|
576 |
// Install the shortcode at an early opportunity
|
12 |
* opened on 7/12/2017 by "jeynon (@jeynon)".
|
13 |
* https://wordpress.org/support/topic/using-shortcodes-to-retrieve-media-from-another-sites-media-library/
|
14 |
*
|
15 |
+
* Enhanced for support topic "MLA and Multisite Global Media plugin"
|
16 |
+
* opened on 2/15/2022 by "rughjm (@rughjm)".
|
17 |
+
* https://wordpress.org/support/topic/mla-and-multisite-global-media-plugin/
|
18 |
+
*
|
19 |
* @package MLA Multisite Extensions
|
20 |
+
* @version 1.05
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
Plugin Name: MLA Multisite Extensions
|
25 |
Plugin URI: http://davidlingren.com/
|
26 |
+
Description: Adds Multisite filters to MLA shortcodes and supports the "Multisite Global Media" plugin
|
27 |
Author: David Lingren
|
28 |
+
Version: 1.05
|
29 |
Author URI: http://davidlingren.com/
|
30 |
|
31 |
+
Copyright 2017-2022 David Lingren
|
32 |
|
33 |
This program is free software; you can redistribute it and/or modify
|
34 |
it under the terms of the GNU General Public License as published by
|
65 |
add_filter( 'mla_gallery_the_attachments', 'MLAMultisiteExtensions::mla_gallery_the_attachments', 10, 2 );
|
66 |
add_filter( 'mla_gallery_item_initial_values', 'MLAMultisiteExtensions::mla_gallery_item_initial_values', 10, 2 );
|
67 |
add_filter( 'mla_gallery_item_values', 'MLAMultisiteExtensions::mla_gallery_item_values', 10, 1 );
|
68 |
+
|
69 |
+
// Filter for detecting the Multisite Global Media plugin
|
70 |
+
add_action( 'mla_media_modal_query_filtered_terms', 'MLAMultisiteExtensions::mla_media_modal_query_filtered_terms', 10, 2 );
|
71 |
}
|
72 |
|
73 |
/**
|
262 |
} else {
|
263 |
unset( self::$shortcode_attributes['site_id'] );
|
264 |
}
|
265 |
+
} // isset( self::$shortcode_attributes['site_id'] )
|
266 |
|
267 |
return $all_query_parameters;
|
268 |
} // mla_gallery_query_arguments
|
578 |
//error_log( 'MLAGalleryHooksExample::mla_gallery_item_values $item_values = ' . var_export( $item_values, true ), 0 );
|
579 |
return $item_values;
|
580 |
} // mla_gallery_item_values
|
581 |
+
|
582 |
+
/**
|
583 |
+
* MLA Media Modal Query Filtered Terms
|
584 |
+
*
|
585 |
+
* @since 1.05
|
586 |
+
*
|
587 |
+
* @param array $query query parameters to be passed to WP_Query
|
588 |
+
* @param array $raw_query query parameters passed in to function
|
589 |
+
*
|
590 |
+
* @return array updated query parameters
|
591 |
+
*/
|
592 |
+
public static function mla_media_modal_query_filtered_terms( $query, $raw_query ) {
|
593 |
+
//error_log( __LINE__ . " MLAMultisiteExtensions::mla_media_modal_query_filtered_terms() query = " . var_export( $query, true ), 0 );
|
594 |
+
//error_log( __LINE__ . " MLAMultisiteExtensions::mla_media_modal_query_filtered_terms() raw_query = " . var_export( $raw_query, true ), 0 );
|
595 |
+
|
596 |
+
if ( !empty( $raw_query['global_media'] ) ) {
|
597 |
+
switch_to_blog( (integer) apply_filters( 'global_media.site_id', 1 ) );
|
598 |
+
add_action( 'mla_media_modal_query_items', 'MLAMultisiteExtensions::mla_media_modal_query_items', 10, 5 );
|
599 |
+
}
|
600 |
+
|
601 |
+
return $query;
|
602 |
+
} // mla_media_modal_query_filtered_terms
|
603 |
+
|
604 |
+
/**
|
605 |
+
* MLA Media Modal Query Items
|
606 |
+
*
|
607 |
+
* @since 1.05
|
608 |
+
*
|
609 |
+
* @param object $attachments_query WP_Query results, passed by reference
|
610 |
+
* @param array $query query parameters passed to WP_Query
|
611 |
+
* @param array $raw_query query parameters passed in to function
|
612 |
+
* @param integer $offset parameter_name => parameter_value pairs
|
613 |
+
* @param integer $count parameter_name => parameter_value pairs
|
614 |
+
*/
|
615 |
+
public static function mla_media_modal_query_items( $attachments_query, $query, $raw_query, $offset, $count ) {
|
616 |
+
//error_log( __LINE__ . " MLAMultisiteExtensions::mla_media_modal_query_items( {$offset}, {$count} ) query = " . var_export( $query, true ), 0 );
|
617 |
+
//error_log( __LINE__ . " MLAMultisiteExtensions::mla_media_modal_query_items( {$offset}, {$count} ) raw_query = " . var_export( $raw_query, true ), 0 );
|
618 |
+
//error_log( __LINE__ . " MLAMultisiteExtensions::mla_media_modal_query_items( {$attachments_query->post_count}, {$attachments_query->found_posts} ) query_vars = " . var_export( $attachments_query->query_vars, true ), 0 );
|
619 |
+
|
620 |
+
$posts_in = array();
|
621 |
+
foreach ( $attachments_query->posts as $post ) {
|
622 |
+
$posts_in[] = (string) $post->ID;
|
623 |
+
}
|
624 |
+
|
625 |
+
$_POST['query'] = array(
|
626 |
+
'global_media' => 'true',
|
627 |
+
'order' => 'ASC',
|
628 |
+
'orderby' => 'post__in',
|
629 |
+
'post__in' => $posts_in,
|
630 |
+
'posts_per_page' => '-1',
|
631 |
+
'post_mime_type' => 'image',
|
632 |
+
's' => '',
|
633 |
+
);
|
634 |
+
|
635 |
+
$_REQUEST['query'] = $_POST['query'];
|
636 |
+
//error_log( __LINE__ . " MLAMultisiteExtensions::mla_media_modal_query_items( {$offset}, {$count} ) query = " . var_export( $_REQUEST['query'], true ), 0 );
|
637 |
+
restore_current_blog();
|
638 |
+
|
639 |
+
// Control never returns from this action, which sends the JSON response and dies.
|
640 |
+
do_action( "wp_ajax_query-attachments" );
|
641 |
+
} // mla_media_modal_query_items
|
642 |
} // MLAMultisiteExtensions
|
643 |
|
644 |
// Install the shortcode at an early opportunity
|
examples/plugins/mla-preset-terms-example.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Adds "Preset Terms" rollover action to Media/Assistant rollover actions, redirecting to Media/Add New (Upload New Media) screen
|
4 |
+
*
|
5 |
+
* In this example, the "Preset Terms" rollover action is detected and, if found,
|
6 |
+
* copies the taxonomy terms from the associated item to populate the controls on
|
7 |
+
* the Media/Add New (Upload New Media) screen.
|
8 |
+
*
|
9 |
+
* This example plugin uses two of the many filters available in the Media/Assistant submenu screen
|
10 |
+
* and illustrates a technique you can use to customize the submenu rollover actions.
|
11 |
+
*
|
12 |
+
* Created for support topic "Cloning category/tags settings from uploades file to upload page."
|
13 |
+
* opened on 11/17/2021 by "poolfactory".
|
14 |
+
* https://wordpress.org/support/topic/cloning-category-tags-settings-from-uploades-file-to-upload-page/
|
15 |
+
*
|
16 |
+
* @package MLA Preset Terms Example
|
17 |
+
* @version 1.00
|
18 |
+
*/
|
19 |
+
|
20 |
+
/*
|
21 |
+
Plugin Name: MLA Preset Terms Example
|
22 |
+
Plugin URI: http://davidlingren.com/
|
23 |
+
Description: Adds "Preset Terms" to Media/Assistant rollover actions, redirecting to Media/Add New (Upload New Media) screen with terms copied from the selected item
|
24 |
+
Author: David Lingren
|
25 |
+
Version: 1.00
|
26 |
+
Author URI: http://davidlingren.com/
|
27 |
+
|
28 |
+
Copyright 2022 David Lingren
|
29 |
+
|
30 |
+
This program is free software; you can redistribute it and/or modify
|
31 |
+
it under the terms of the GNU General Public License as published by
|
32 |
+
the Free Software Foundation; either version 2 of the License, or
|
33 |
+
(at your option) any later version.
|
34 |
+
|
35 |
+
This program is distributed in the hope that it will be useful,
|
36 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
37 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
38 |
+
GNU General Public License for more details.
|
39 |
+
|
40 |
+
You can get a copy of the GNU General Public License by writing to the
|
41 |
+
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
42 |
+
*/
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Class MLA Preset Terms Example adds a "Preset Terms" action to
|
46 |
+
* Media/Assistant rollover actions.
|
47 |
+
*
|
48 |
+
* @package MLA Preset Terms Example
|
49 |
+
* @since 1.00
|
50 |
+
*/
|
51 |
+
class MLAPresetTermsExample {
|
52 |
+
/**
|
53 |
+
* Initialization function, similar to __construct()
|
54 |
+
*
|
55 |
+
* @since 1.00
|
56 |
+
*/
|
57 |
+
public static function initialize() {
|
58 |
+
// The filters are only useful in the admin section
|
59 |
+
if ( !is_admin() ) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
add_filter( 'mla_list_table_build_rollover_actions', 'MLAPresetTermsExample::mla_list_table_build_rollover_actions', 10, 3 );
|
64 |
+
|
65 |
+
// This action is run before any Media/Assistant output is generated
|
66 |
+
add_action( 'mla_list_table_custom_admin_action', 'MLAPresetTermsExample::mla_list_table_custom_admin_action', 10, 2 ); // sanitize_text_field( wp_unslash( $_REQUEST['mla_admin_action'] ) ), $mla_item_id );
|
67 |
+
|
68 |
+
add_filter( 'mla_upload_bulk_edit_form_initial_fieldset_values', 'MLAPresetTermsExample::mla_upload_bulk_edit_form_fieldset_values', 10, 2 );
|
69 |
+
//add_filter( 'mla_upload_bulk_edit_form_preset_fieldset_values', 'MLAPresetTermsExample::mla_upload_bulk_edit_form_fieldset_values', 10, 2 );
|
70 |
+
add_filter( 'mla_upload_bulk_edit_form_initial_values', 'MLAPresetTermsExample::mla_upload_bulk_edit_form_values', 10, 1 );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Add Preset Terms to the list of item "Rollover" actions
|
75 |
+
*
|
76 |
+
* @since 1.00
|
77 |
+
*
|
78 |
+
* @param array $actions The list of item "Rollover" actions.
|
79 |
+
* @param object $item The current Media Library item.
|
80 |
+
* @param string $column The List Table column slug.
|
81 |
+
*/
|
82 |
+
public static function mla_list_table_build_rollover_actions( $actions, $item, $column ) {
|
83 |
+
//error_log( __LINE__ . " MLAPresetTermsExample::mla_list_table_build_rollover_actions( {$item->ID}, {$column} ) \$actions = " . var_export( $actions, true ), 0 );
|
84 |
+
//error_log( __LINE__ . " MLAPresetTermsExample::mla_list_table_build_rollover_actions ( {$item->ID}, {$column} ) \$item = " . var_export( $item, true ), 0 );
|
85 |
+
|
86 |
+
$query_args = array( 'page' => MLACore::ADMIN_PAGE_SLUG, 'mla_admin_action' => 'preset_terms', 'mla_item_ID' => $item->ID );
|
87 |
+
$actions['presetterms'] = '<a href="' . add_query_arg( $query_args, MLACore::mla_nonce_url( 'upload.php', MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ) . '" title="Copy terms for Upload">Preset Terms</a>';
|
88 |
+
|
89 |
+
return $actions;
|
90 |
+
} // mla_list_table_build_rollover_actions
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Process the Preset Terms rollover action
|
94 |
+
*
|
95 |
+
* @since 1.00
|
96 |
+
*
|
97 |
+
* @param string $mla_admin_action The requested action.
|
98 |
+
* @param integer $mla_item_ID Zero (0), or the affected attachment.
|
99 |
+
*/
|
100 |
+
public static function mla_list_table_custom_admin_action( $mla_admin_action, $mla_item_ID ) {
|
101 |
+
error_log( __LINE__ . " MLAPresetTermsExample::mla_list_table_custom_admin_action( {$mla_admin_action}, {$mla_item_ID} ) \$_REQUEST = " . var_export( $_REQUEST, true ), 0 );
|
102 |
+
|
103 |
+
if ( ( 'preset_terms' === $mla_admin_action ) && ( 'mla-menu' === $_REQUEST['page'] ) ) {
|
104 |
+
$query_args = array( 'mla_preset_terms_ID' => $mla_item_ID );
|
105 |
+
wp_redirect( add_query_arg( $query_args, admin_url( 'media-new.php' ) ), 302 );
|
106 |
+
exit;
|
107 |
+
}
|
108 |
+
} // mla_list_table_custom_admin_action
|
109 |
+
|
110 |
+
/**
|
111 |
+
* MLAEdit bulk edit on upload fieldset values
|
112 |
+
*
|
113 |
+
* This filter gives you a chance to modify the raw data used to populate
|
114 |
+
* the Bulk Edit on Upload form.
|
115 |
+
*
|
116 |
+
* @since 1.00
|
117 |
+
*
|
118 |
+
* @param array $fieldset_values data values to populate the form
|
119 |
+
* @param string $filter_root identify the blank, initial and preset fieldsets
|
120 |
+
*/
|
121 |
+
public static function mla_upload_bulk_edit_form_fieldset_values( $fieldset_values, $filter_root ) {
|
122 |
+
//error_log( __LINE__ . ' MLAPresetTermsExample::mla_upload_bulk_edit_form_fieldset_values $_REQUEST = ' . var_export( $_REQUEST, true ), 0 );
|
123 |
+
//error_log( __LINE__ . " MLAPresetTermsExample::mla_upload_bulk_edit_form_fieldset_values( {$filter_root} ) \$fieldset_values = " . var_export( $fieldset_values, true ), 0 );
|
124 |
+
|
125 |
+
if ( isset( $_REQUEST['mla_preset_terms_ID'] ) && ( 'mla_upload_bulk_edit_form_initial' === $filter_root ) ) {
|
126 |
+
$mla_preset_terms_ID = (integer) $_REQUEST['mla_preset_terms_ID'];
|
127 |
+
} else {
|
128 |
+
return $fieldset_values;
|
129 |
+
}
|
130 |
+
|
131 |
+
$tax_input = array();
|
132 |
+
$taxonomies = get_object_taxonomies( 'attachment', 'objects' );
|
133 |
+
|
134 |
+
foreach ( $taxonomies as $tax_name => $tax_object ) {
|
135 |
+
if ( $tax_object->show_ui && MLACore::mla_taxonomy_support( $tax_name, 'quick-edit' ) ) {
|
136 |
+
$terms = get_object_term_cache( $mla_preset_terms_ID, $tax_name );
|
137 |
+
if ( false === $terms ) {
|
138 |
+
$terms = wp_get_object_terms( $mla_preset_terms_ID, $tax_name );
|
139 |
+
wp_cache_add( $mla_preset_terms_ID, $terms, $tax_name . '_relationships' );
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( is_wp_error( $terms ) || empty( $terms ) ) {
|
143 |
+
$terms = array();
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( $tax_object->hierarchical || MLACore::mla_taxonomy_support( $tax_name, 'flat-checklist' ) ) {
|
147 |
+
foreach( $terms as $term ) {
|
148 |
+
$tax_input[ $tax_name ][] = $term->term_id;
|
149 |
+
}
|
150 |
+
} else {
|
151 |
+
$term_array = array();
|
152 |
+
foreach( $terms as $term ) {
|
153 |
+
$term_array[] = $term->name;
|
154 |
+
}
|
155 |
+
$tax_input[ $tax_name ] = implode( ',', $term_array );
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
//error_log( __LINE__ . ' MLAPresetTermsExample::mla_upload_bulk_edit_form_fieldset_values $tax_input = ' . var_export( $tax_input, true ), 0 );
|
160 |
+
|
161 |
+
$tax_action = array();
|
162 |
+
foreach ( $tax_input as $tax_name => $term_assignments ) {
|
163 |
+
$tax_action[ $tax_name ] = 'add';
|
164 |
+
}
|
165 |
+
//error_log( __LINE__ . ' MLAPresetTermsExample::mla_upload_bulk_edit_form_fieldset_values $tax_action = ' . var_export( $tax_action, true ), 0 );
|
166 |
+
|
167 |
+
$fieldset_values['tax_input'] = $tax_input;
|
168 |
+
$fieldset_values['tax_action'] = $tax_action;
|
169 |
+
|
170 |
+
return $fieldset_values;
|
171 |
+
} // mla_upload_bulk_edit_form_fieldset_values
|
172 |
+
|
173 |
+
/**
|
174 |
+
* MLAEdit bulk edit on upload item values
|
175 |
+
*
|
176 |
+
* This filter gives you a chance to modify and extend the substitution values
|
177 |
+
* for the Bulk Edit on Upload form.
|
178 |
+
*
|
179 |
+
* @since 1.00
|
180 |
+
*
|
181 |
+
* @param array $item_values [ parameter_name => parameter_value ] pairs
|
182 |
+
*/
|
183 |
+
public static function mla_upload_bulk_edit_form_values( $item_values ) {
|
184 |
+
//error_log( __LINE__ . ' MLAPresetTermsExample::mla_upload_bulk_edit_form_values $_REQUEST = ' . var_export( $_REQUEST, true ), 0 );
|
185 |
+
//error_log( __LINE__ . ' MLAPresetTermsExample::mla_upload_bulk_edit_form_values $item_values = ' . var_export( $item_values, true ), 0 );
|
186 |
+
|
187 |
+
return $item_values;
|
188 |
+
} // mla_upload_bulk_edit_form_values
|
189 |
+
} // Class MLAPresetTermsExample
|
190 |
+
|
191 |
+
// Install the filters at an early opportunity
|
192 |
+
add_action('init', 'MLAPresetTermsExample::initialize');
|
193 |
+
?>
|
examples/plugins/mla-simple-mapping-hooks-example.php
CHANGED
@@ -21,12 +21,16 @@
|
|
21 |
* opened on 8/4/2016 by "ciano":
|
22 |
* https://wordpress.org/support/topic/replacing-sort-order-attribute
|
23 |
*
|
24 |
-
* Enhanced for support topic "Plugin
|
25 |
* opened on 12/7/2020 by "ernstwg":
|
26 |
* https://wordpress.org/support/topic/plugin-mla-simple-mapping-hooks-example/
|
27 |
*
|
|
|
|
|
|
|
|
|
28 |
* @package MLA Simple Mapping Hooks Example
|
29 |
-
* @version 1.
|
30 |
*/
|
31 |
|
32 |
/*
|
@@ -34,10 +38,10 @@ Plugin Name: MLA Simple Mapping Hooks Example
|
|
34 |
Plugin URI: http://davidlingren.com/
|
35 |
Description: Populates custom fields based on a regular expression; updates menu_order; cleans up Title and ALT Text
|
36 |
Author: David Lingren
|
37 |
-
Version: 1.
|
38 |
Author URI: http://davidlingren.com/
|
39 |
|
40 |
-
Copyright 2014 -
|
41 |
|
42 |
This program is free software; you can redistribute it and/or modify
|
43 |
it under the terms of the GNU General Public License as published by
|
@@ -77,7 +81,8 @@ class MLASimpleMappingHooksExample {
|
|
77 |
$is_wplr_sync = isset( $_SERVER['REQUEST_URI'] ) && false !== strpos( $_SERVER['REQUEST_URI'], '/?wplr-sync-api' ); // phpcs:ignore
|
78 |
|
79 |
// The filters are only useful in the admin section or during WP/LR Sync; exit if in the "front-end" posts/pages.
|
80 |
-
|
|
|
81 |
/*
|
82 |
* This filter is applied in class-mla-options.php functions
|
83 |
* mla_evaluate_iptc_exif_mapping and mla_evaluate_custom_field_mapping
|
21 |
* opened on 8/4/2016 by "ciano":
|
22 |
* https://wordpress.org/support/topic/replacing-sort-order-attribute
|
23 |
*
|
24 |
+
* Enhanced for support topic "Plugin 'MLA Simple Mapping Hooks Example'"
|
25 |
* opened on 12/7/2020 by "ernstwg":
|
26 |
* https://wordpress.org/support/topic/plugin-mla-simple-mapping-hooks-example/
|
27 |
*
|
28 |
+
* Enhanced for support topic "Using MLA Plugin 'Simple Mapping Hooks'"
|
29 |
+
* opened on 3/2/2022 by "ernstwg":
|
30 |
+
* https://wordpress.org/support/topic/using-mla-plugin-simple-mapping-hooks/
|
31 |
+
*
|
32 |
* @package MLA Simple Mapping Hooks Example
|
33 |
+
* @version 1.05
|
34 |
*/
|
35 |
|
36 |
/*
|
38 |
Plugin URI: http://davidlingren.com/
|
39 |
Description: Populates custom fields based on a regular expression; updates menu_order; cleans up Title and ALT Text
|
40 |
Author: David Lingren
|
41 |
+
Version: 1.05
|
42 |
Author URI: http://davidlingren.com/
|
43 |
|
44 |
+
Copyright 2014 - 2022 David Lingren
|
45 |
|
46 |
This program is free software; you can redistribute it and/or modify
|
47 |
it under the terms of the GNU General Public License as published by
|
81 |
$is_wplr_sync = isset( $_SERVER['REQUEST_URI'] ) && false !== strpos( $_SERVER['REQUEST_URI'], '/?wplr-sync-api' ); // phpcs:ignore
|
82 |
|
83 |
// The filters are only useful in the admin section or during WP/LR Sync; exit if in the "front-end" posts/pages.
|
84 |
+
// Test disabled - is_admin() returns false for images inserted in Gutenberg blocks, etc.
|
85 |
+
if ( true || is_admin() || $is_wplr_sync ) {
|
86 |
/*
|
87 |
* This filter is applied in class-mla-options.php functions
|
88 |
* mla_evaluate_iptc_exif_mapping and mla_evaluate_custom_field_mapping
|
examples/plugins/mla-substitution-parameter-hooks-example.php
CHANGED
@@ -13,6 +13,7 @@
|
|
13 |
* - a "current_term:" prefix accesses the term named in a $_REQUEST variable
|
14 |
* e.g. {+current_term:taxonomy.default_value(term_field)+}
|
15 |
* - a "ucwords" custom format value uppercases the first character of each word in a string
|
|
|
16 |
*
|
17 |
* Created for support topic "Parent category tag"
|
18 |
* opened on 5/20/2016 by "Levy":
|
@@ -50,8 +51,12 @@
|
|
50 |
* opened on 8/1/2020 by "perchera":
|
51 |
* https://wordpress.org/support/topic/auto-alt-text-from-field-in-exif-or-iptc/
|
52 |
*
|
|
|
|
|
|
|
|
|
53 |
* @package MLA Substitution Parameter Hooks Example
|
54 |
-
* @version 1.
|
55 |
*/
|
56 |
|
57 |
/*
|
@@ -59,7 +64,7 @@ Plugin Name: MLA Substitution Parameter Hooks Example
|
|
59 |
Plugin URI: http://davidlingren.com/
|
60 |
Description: Adds "parent_terms:", "page_terms:", "parent:", "author:", "conditional:", "wp_query_vars" and "current_term" Field-level Substitution Parameters and "ucwords" custom format value
|
61 |
Author: David Lingren
|
62 |
-
Version: 1.
|
63 |
Author URI: http://davidlingren.com/
|
64 |
|
65 |
Copyright 2016-2020 David Lingren
|
@@ -101,12 +106,13 @@ class MLASubstitutionParameterExample {
|
|
101 |
*/
|
102 |
public static function initialize() {
|
103 |
// Defined in /media-library-assistant/includes/class-mla-data.php
|
104 |
-
|
105 |
add_filter( 'mla_expand_custom_prefix', 'MLASubstitutionParameterExample::mla_expand_custom_prefix', 10, 8 );
|
106 |
add_filter( 'mla_apply_custom_format', 'MLASubstitutionParameterExample::mla_apply_custom_format', 10, 2 );
|
107 |
|
108 |
// Defined in /media-library-assistant/includes/class-mla-data-source.php
|
109 |
-
|
|
|
110 |
|
111 |
/*
|
112 |
* Additional hooks defined in "MLA Custom Field and IPTC/EXIF Mapping Actions and Filters (Hooks)".
|
@@ -183,6 +189,12 @@ class MLASubstitutionParameterExample {
|
|
183 |
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_data_source( {$candidate}, {$post_id} ) query = " . var_export( $query, true ), 0 );
|
184 |
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_data_source( {$candidate}, {$post_id} ) markup_values = " . var_export( $markup_values, true ), 0 );
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
return $custom_value;
|
187 |
} // mla_expand_custom_data_source
|
188 |
|
@@ -469,8 +481,10 @@ class MLASubstitutionParameterExample {
|
|
469 |
|
470 |
if ( property_exists( $author, $value['value'] ) ) {
|
471 |
$custom_value = $author->{$value['value']};
|
|
|
472 |
} else {
|
473 |
$custom_value = $author->get( $value['value'] );
|
|
|
474 |
}
|
475 |
|
476 |
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_prefix( {$key}, {$post_id} ) custom_value = " . var_export( $custom_value, true ), 0 );
|
@@ -597,8 +611,23 @@ class MLASubstitutionParameterExample {
|
|
597 |
* @param array _wp_attachment_metadata, default NULL (use current postmeta database value)
|
598 |
*/
|
599 |
public static function mla_evaluate_custom_data_source( $custom_value, $post_id, $category, $data_value, $attachment_metadata ) {
|
600 |
-
//error_log( __LINE__ . " MLASubstitutionParameterExample::
|
601 |
-
//error_log( __LINE__ . " MLASubstitutionParameterExample::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
|
603 |
return $custom_value;
|
604 |
} // mla_evaluate_custom_data_source
|
13 |
* - a "current_term:" prefix accesses the term named in a $_REQUEST variable
|
14 |
* e.g. {+current_term:taxonomy.default_value(term_field)+}
|
15 |
* - a "ucwords" custom format value uppercases the first character of each word in a string
|
16 |
+
* - a "computed_orientation" custom data source derives "Landscape" or "Portrait" from image height and width values
|
17 |
*
|
18 |
* Created for support topic "Parent category tag"
|
19 |
* opened on 5/20/2016 by "Levy":
|
51 |
* opened on 8/1/2020 by "perchera":
|
52 |
* https://wordpress.org/support/topic/auto-alt-text-from-field-in-exif-or-iptc/
|
53 |
*
|
54 |
+
* Enhanced for support topic "Perform Comparison (If Then Else Logic) when Mapping Metadata to Custom Field"
|
55 |
+
* opened on 2/27/2022 by "tplunkett87":
|
56 |
+
* https://wordpress.org/support/topic/perform-calculation-when-mapping-metadata-to-custom-field/
|
57 |
+
*
|
58 |
* @package MLA Substitution Parameter Hooks Example
|
59 |
+
* @version 1.14
|
60 |
*/
|
61 |
|
62 |
/*
|
64 |
Plugin URI: http://davidlingren.com/
|
65 |
Description: Adds "parent_terms:", "page_terms:", "parent:", "author:", "conditional:", "wp_query_vars" and "current_term" Field-level Substitution Parameters and "ucwords" custom format value
|
66 |
Author: David Lingren
|
67 |
+
Version: 1.14
|
68 |
Author URI: http://davidlingren.com/
|
69 |
|
70 |
Copyright 2016-2020 David Lingren
|
106 |
*/
|
107 |
public static function initialize() {
|
108 |
// Defined in /media-library-assistant/includes/class-mla-data.php
|
109 |
+
add_filter( 'mla_expand_custom_data_source', 'MLASubstitutionParameterExample::mla_expand_custom_data_source', 10, 9 );
|
110 |
add_filter( 'mla_expand_custom_prefix', 'MLASubstitutionParameterExample::mla_expand_custom_prefix', 10, 8 );
|
111 |
add_filter( 'mla_apply_custom_format', 'MLASubstitutionParameterExample::mla_apply_custom_format', 10, 2 );
|
112 |
|
113 |
// Defined in /media-library-assistant/includes/class-mla-data-source.php
|
114 |
+
add_filter( 'mla_evaluate_custom_data_source', 'MLASubstitutionParameterExample::mla_evaluate_custom_data_source', 10, 5 );
|
115 |
+
|
116 |
|
117 |
/*
|
118 |
* Additional hooks defined in "MLA Custom Field and IPTC/EXIF Mapping Actions and Filters (Hooks)".
|
189 |
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_data_source( {$candidate}, {$post_id} ) query = " . var_export( $query, true ), 0 );
|
190 |
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_data_source( {$candidate}, {$post_id} ) markup_values = " . var_export( $markup_values, true ), 0 );
|
191 |
|
192 |
+
if ( 'computed_orientation' === $candidate ) {
|
193 |
+
if ( isset( $markup_values['width'] ) && isset( $markup_values['height'] ) && 0 < $markup_values['height'] ) {
|
194 |
+
return ( ( $markup_values['width'] / $markup_values['height'] ) > 1.0 ) ? 'Landscape' : 'Portrait';
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
return $custom_value;
|
199 |
} // mla_expand_custom_data_source
|
200 |
|
481 |
|
482 |
if ( property_exists( $author, $value['value'] ) ) {
|
483 |
$custom_value = $author->{$value['value']};
|
484 |
+
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_prefix( {$key}, {$post_id} ) property custom_value = " . var_export( $custom_value, true ), 0 );
|
485 |
} else {
|
486 |
$custom_value = $author->get( $value['value'] );
|
487 |
+
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_prefix( {$key}, {$post_id} ) get custom_value = " . var_export( $custom_value, true ), 0 );
|
488 |
}
|
489 |
|
490 |
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_expand_custom_prefix( {$key}, {$post_id} ) custom_value = " . var_export( $custom_value, true ), 0 );
|
611 |
* @param array _wp_attachment_metadata, default NULL (use current postmeta database value)
|
612 |
*/
|
613 |
public static function mla_evaluate_custom_data_source( $custom_value, $post_id, $category, $data_value, $attachment_metadata ) {
|
614 |
+
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_evaluate_custom_data_source( {$post_id}, {$category} ) data_value = " . var_export( $data_value, true ), 0 );
|
615 |
+
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_evaluate_custom_data_source( {$post_id} ) attachment_metadata = " . var_export( $attachment_metadata, true ), 0 );
|
616 |
+
|
617 |
+
if ( 'computed_orientation' === $data_value['data_source'] ) {
|
618 |
+
if ( !is_array( $attachment_metadata ) ) {
|
619 |
+
if ( 0 < $post_id ) {
|
620 |
+
$attachment_metadata = get_metadata( 'post', $post_id, '_wp_attachment_metadata', true );
|
621 |
+
} else {
|
622 |
+
$attachment_metadata = array();
|
623 |
+
}
|
624 |
+
}
|
625 |
+
//error_log( __LINE__ . " MLASubstitutionParameterExample::mla_evaluate_custom_data_source( {$post_id} ) attachment_metadata = " . var_export( $attachment_metadata, true ), 0 );
|
626 |
+
|
627 |
+
if ( isset( $attachment_metadata['width'] ) && isset( $attachment_metadata['height'] ) && 0 < $attachment_metadata['height'] ) {
|
628 |
+
return ( ( $attachment_metadata['width'] / $attachment_metadata['height'] ) > 1.0 ) ? 'Landscape' : 'Portrait';
|
629 |
+
}
|
630 |
+
}
|
631 |
|
632 |
return $custom_value;
|
633 |
} // mla_evaluate_custom_data_source
|
examples/plugins/mla-ui-elements-example/admin-settings-page.tpl
CHANGED
@@ -272,6 +272,9 @@ For gallery pagination links, the term list parameters (e.g., "tax_input") are r
|
|
272 |
If the <code>$_REQUEST['tax_input']</code> element is present the selected terms are added to the <code>[mla_term_list]</code> shortcode parameters so the list output reflects them. They can also be accessed in an <code>[mla_gallery]</code> shortcode with the `request:` substitution parameter prefix.
|
273 |
</p>
|
274 |
<p>
|
|
|
|
|
|
|
275 |
If you are not getting the results you expect carefully inspecting the results of parsing the specification and generating the query can be a valuable exercise. You can add the <code>muie_debug=true</code> or <code>muie_debug=log</code> parameters to the <code>[mla_gallery]</code> shortcode, run a test and inspect the log file or the screen messages for more information about what's going on.
|
276 |
<a name="add_filters_to"></a>
|
277 |
</p>
|
@@ -294,7 +297,10 @@ If you add "add_filters_to={taxonomy_slug}" to an [mla_gallery] shortcode this p
|
|
294 |
</p>
|
295 |
<h3>default_empty_gallery, for [mla_gallery]</h3>
|
296 |
<p>
|
297 |
-
If you add "default_empty_gallery=true" an [mla_gallery] shortcode the initial gallery display will show no items, until a selection is made from the other controls.
|
|
|
|
|
|
|
298 |
<a name="muie_terms_search"></a>
|
299 |
</p>
|
300 |
<p>
|
@@ -305,15 +311,19 @@ If you add "default_empty_gallery=true" an [mla_gallery] shortcode the initial g
|
|
305 |
The <code>[muie_terms_search]</code> shortcode generates a text box for passing the "mla_terms_phrases" parameter to an <code>[mla_gallery]</code> shortcode. You can add parameters to this shortcode to pass the other terms search parameters as well:
|
306 |
</p>
|
307 |
<ul class="mla-doc-toc-list">
|
|
|
|
|
308 |
<li>mla_terms_taxonomies</li>
|
309 |
<li>mla_phrase_delimiter</li>
|
310 |
-
<li>mla_term_delimiter</li>
|
311 |
<li>mla_phrase_connector</li>
|
312 |
<li>mla_term_delimiter</li>
|
313 |
<li>mla_term_connector</li>
|
314 |
</ul>
|
315 |
<p>
|
316 |
-
The shortcode is meant to be placed in an HTML form that lets the user enter criteria to filter a gallery display.
|
|
|
|
|
|
|
317 |
<a name="muie_keyword_search"></a>
|
318 |
</p>
|
319 |
<p>
|
@@ -324,14 +334,21 @@ The shortcode is meant to be placed in an HTML form that lets the user enter cri
|
|
324 |
The <code>[muie_keyword_search]</code> shortcode generates a text box for passing the "s" parameter to an <code>[mla_gallery]</code> shortcode. You can add parameters to this shortcode to pass the other keyword search parameters as well:
|
325 |
</p>
|
326 |
<ul class="mla-doc-toc-list">
|
|
|
|
|
327 |
<li>mla_search_fields</li>
|
328 |
<li>mla_search_connector</li>
|
329 |
-
<li>mla_term_delimiter</li>
|
330 |
<li>sentence</li>
|
331 |
<li>exact</li>
|
332 |
</ul>
|
333 |
<p>
|
334 |
-
The shortcode is meant to be placed in an HTML form that lets the user enter criteria to filter a gallery display.
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
<a name="muie_orderby"></a>
|
336 |
</p>
|
337 |
<p>
|
@@ -487,15 +504,15 @@ The data source for an archive must be a text database field that contains a val
|
|
487 |
</tr>
|
488 |
<tr>
|
489 |
<td class="mla-doc-table-label">custom</td>
|
490 |
-
<td>a custom field value. The custom field must contain a text value with a date format recognized by the database SQL date query functions.</td>
|
491 |
</tr>
|
492 |
<tr>
|
493 |
<td class="mla-doc-table-label">archive_key</td>
|
494 |
-
<td>for the "custom" archive source, the name of the custom field to be used for the query.</td>
|
495 |
</tr>
|
496 |
</table>
|
497 |
<p>
|
498 |
-
The four values from the wp_posts table are in a valid date format. For custom fields, a
|
499 |
</p>
|
500 |
<table>
|
501 |
<tr>
|
@@ -1169,7 +1186,7 @@ The first two shortcodes in the example use the alternative "enclosing shortcode
|
|
1169 |
The <code>[muie_terms_search]</code> shortcode generates a text box that accepts one or more phrases to be matched to part or all of a term name in the Att. Tags taxonomy. Phrases are separated by spaces and if two or more phrases are entered any one of them will yield a match. The value entered in the text box is passed to <code>[mla_gallery]</code> as <code>mla_terms_phrases</code>. The <code>mla_terms_taxonomies</code>, <code>mla_term_delimiter</code> and <code>mla_phrase_connector</code> parameters are passed to <code>[mla_gallery]</code> as well.
|
1170 |
</p>
|
1171 |
<p>
|
1172 |
-
The <code>[muie_keyword_search]</code> shortcode generates a text box that accepts one or more keywords to be matched to part or all of the Title, Caption (excerpt) or Description (content) fields. If two or more keywords are entered any one of them will yield a match. The value entered in the text box is passed to <code>[mla_gallery]</code> as <code>s</code>. The <code>mla_search_fields</code> and <code>
|
1173 |
</p>
|
1174 |
<p>
|
1175 |
The <code>[muie_per_page]</code> shortcode generates a text box that accepts the number of posts per page to be displayed in the gallery. The value entered in the text box is passed to <code>[mla_gallery]</code> as <code>muie_per_page</code> and it will be converted to <code>posts_per_page</code>. The initial gallery display will not be limited unless you also add an explicit <code>posts_per_page</code> parameter to <code>[mla_gallery]</code>; as the above example shows, its value should match the default value entered in <code>[muie_per_page]</code>.
|
@@ -1204,6 +1221,7 @@ The default output is a dropdown control you can add to an HTML "search form". Y
|
|
1204 |
<br /> <br />
|
1205 |
The above example also limits the display to the ten most recent values and adds a count of the number of items selected by each value to the display.
|
1206 |
</p>
|
|
|
1207 |
<p>
|
1208 |
The MUIE Archive List shortcode is designed to work with the <code>[mla_gallery]</code> shortcode to display galleries filtered by a date value. To link the archive list to the gallery simply add <code>archive_parameter_name=muie_current_archive</code> to your <code>[mla_gallery]</code> shortcode. Here is a simple example combining an archive search form with a gallery display:
|
1209 |
<br /> <br />
|
@@ -1231,6 +1249,20 @@ The above example displays all of the image items in the Media Library when the
|
|
1231 |
<br /> <br />
|
1232 |
Note the double backslash characters in the template; they prevent the template processor from interpreting the parentheses as a "Conditional" element. Two are required because of the way WordPress processes shortcode parameters.
|
1233 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1234 |
<p>
|
1235 |
As described in the "Archive List Data Selection Parameters" section above you can filter the archive list to show the dates present in a subset of your Media Library items. For example, here is a taxonomy term-specific variation on the archive search form:
|
1236 |
<br /> <br />
|
@@ -1246,8 +1278,8 @@ As described in the "Archive List Data Selection Parameters" section above you c
|
|
1246 |
<br /> <br />
|
1247 |
This example will initially show all items assigned to <code>attachment_category=abc</code> and the dropdown control will show only those dates that have one or more items assigned to the term. Selecting an archive value will combine the term filter and the date filter for the gallery display.
|
1248 |
</p>
|
|
|
1249 |
<p>
|
1250 |
-
</p>
|
1251 |
Finally, here is an example that shows how you can combine <code>[muie_archive_list]</code> with the other MUIE elements to create a powerful multi-criteria search application. In this example the <code>tax_input={+template:({+request:tax_input,array+})+}</code> parameter added to the <code>[muie_archive_list]</code> shortcode links the archive list to whatever taxonomy term is selected in the <code>[mla_term_list]</code> shortcode:
|
1252 |
<br /> <br />
|
1253 |
<code>
|
272 |
If the <code>$_REQUEST['tax_input']</code> element is present the selected terms are added to the <code>[mla_term_list]</code> shortcode parameters so the list output reflects them. They can also be accessed in an <code>[mla_gallery]</code> shortcode with the `request:` substitution parameter prefix.
|
273 |
</p>
|
274 |
<p>
|
275 |
+
If you use the "mla_control_name" to replace the default <code>tax_input[[+taxonomy+]][]</code> name attribute, term selections will still be copied to the <code>$_REQUEST['tax_input']</code> element and the <code>muie_filters['tax_input']</code> query attribute. You can disable this behavoir by coding "use_filters=local".
|
276 |
+
</p>
|
277 |
+
<p>
|
278 |
If you are not getting the results you expect carefully inspecting the results of parsing the specification and generating the query can be a valuable exercise. You can add the <code>muie_debug=true</code> or <code>muie_debug=log</code> parameters to the <code>[mla_gallery]</code> shortcode, run a test and inspect the log file or the screen messages for more information about what's going on.
|
279 |
<a name="add_filters_to"></a>
|
280 |
</p>
|
297 |
</p>
|
298 |
<h3>default_empty_gallery, for [mla_gallery]</h3>
|
299 |
<p>
|
300 |
+
If you add "default_empty_gallery=true" to an [mla_gallery] shortcode the initial gallery display will show no items, until a selection is made from the other controls.
|
301 |
+
</p>
|
302 |
+
<p>
|
303 |
+
If you also add an "mla_control_name" parameter to the shortcode with a comma-separated list of one or more control names, the presence of any non-empty control name elements in the request will cause the "empty gallery" test to fail and will display the gallery.
|
304 |
<a name="muie_terms_search"></a>
|
305 |
</p>
|
306 |
<p>
|
311 |
The <code>[muie_terms_search]</code> shortcode generates a text box for passing the "mla_terms_phrases" parameter to an <code>[mla_gallery]</code> shortcode. You can add parameters to this shortcode to pass the other terms search parameters as well:
|
312 |
</p>
|
313 |
<ul class="mla-doc-toc-list">
|
314 |
+
<li>muie_terms_parameter</li>
|
315 |
+
<li>muie_attributes</li>
|
316 |
<li>mla_terms_taxonomies</li>
|
317 |
<li>mla_phrase_delimiter</li>
|
|
|
318 |
<li>mla_phrase_connector</li>
|
319 |
<li>mla_term_delimiter</li>
|
320 |
<li>mla_term_connector</li>
|
321 |
</ul>
|
322 |
<p>
|
323 |
+
The shortcode is meant to be placed in an HTML form that lets the user enter criteria to filter a gallery display. If you require multiple shortcodes on the same page you can use the <code>muie_terms_parameter</code> parameter to give them unique names. Be sure to add a <code>muie_terms_parameter</code> parameter with the same name to every <code>[mla_gallery]</code> shortcode that uses the results of this shortcode.
|
324 |
+
</p>
|
325 |
+
<p>
|
326 |
+
You can use the <code>muie_attributes</code> parameter to replace the default <code>type=text</code> and/or <code>size=20</code> attributes or to add attributes such as <code>placeholder="Enter some terms"</code>. separate multiple attributes with spaces and quote any value containing spaces.
|
327 |
<a name="muie_keyword_search"></a>
|
328 |
</p>
|
329 |
<p>
|
334 |
The <code>[muie_keyword_search]</code> shortcode generates a text box for passing the "s" parameter to an <code>[mla_gallery]</code> shortcode. You can add parameters to this shortcode to pass the other keyword search parameters as well:
|
335 |
</p>
|
336 |
<ul class="mla-doc-toc-list">
|
337 |
+
<li>muie_keyword_parameter</li>
|
338 |
+
<li>muie_attributes</li>
|
339 |
<li>mla_search_fields</li>
|
340 |
<li>mla_search_connector</li>
|
|
|
341 |
<li>sentence</li>
|
342 |
<li>exact</li>
|
343 |
</ul>
|
344 |
<p>
|
345 |
+
The shortcode is meant to be placed in an HTML form that lets the user enter criteria to filter a gallery display. If you require multiple shortcodes on the same page you can use the <code>muie_keyword_parameter</code> parameter to give them unique names. Be sure to add a <code>muie_keyword_parameter</code> parameter with the same name to every <code>[mla_gallery]</code> shortcode that uses the results of this shortcode.
|
346 |
+
</p>
|
347 |
+
<p>
|
348 |
+
The <code>mla_search_fields</code>, <code>mla_search_connector</code>, <code>sentence</code> and <code>exact</code> parameters are passed to <code>[mla_gallery]</code> as well.
|
349 |
+
</p>
|
350 |
+
<p>
|
351 |
+
You can use the <code>muie_attributes</code> parameter to replace the default <code>type=text</code> and/or <code>size=20</code> attributes or to add attributes such as <code>placeholder="Enter some keywords"</code>. separate multiple attributes with spaces and quote any value containing spaces.
|
352 |
<a name="muie_orderby"></a>
|
353 |
</p>
|
354 |
<p>
|
504 |
</tr>
|
505 |
<tr>
|
506 |
<td class="mla-doc-table-label">custom</td>
|
507 |
+
<td style="padding-bottom: 2em;">a custom field value. The custom field must contain a text value with a date format recognized by the database SQL date query functions.</td>
|
508 |
</tr>
|
509 |
<tr>
|
510 |
<td class="mla-doc-table-label">archive_key</td>
|
511 |
+
<td>for the "custom" archive source, this separate parameter gives the name of the custom field to be used for the query. For example, you can code something like <code>archive_source=custom archive_key="Date Taken"</code> where “Date Taken” is the name of a custom field you have created.</td>
|
512 |
</tr>
|
513 |
</table>
|
514 |
<p>
|
515 |
+
The four values from the wp_posts table are in a valid date format. For custom fields, a variety of common formats are acceptable. For example, you can use a mapping rule to source the custom field from:
|
516 |
</p>
|
517 |
<table>
|
518 |
<tr>
|
1186 |
The <code>[muie_terms_search]</code> shortcode generates a text box that accepts one or more phrases to be matched to part or all of a term name in the Att. Tags taxonomy. Phrases are separated by spaces and if two or more phrases are entered any one of them will yield a match. The value entered in the text box is passed to <code>[mla_gallery]</code> as <code>mla_terms_phrases</code>. The <code>mla_terms_taxonomies</code>, <code>mla_term_delimiter</code> and <code>mla_phrase_connector</code> parameters are passed to <code>[mla_gallery]</code> as well.
|
1187 |
</p>
|
1188 |
<p>
|
1189 |
+
The <code>[muie_keyword_search]</code> shortcode generates a text box that accepts one or more keywords to be matched to part or all of the Title, Caption (excerpt) or Description (content) fields. If two or more keywords are entered any one of them will yield a match. The value entered in the text box is passed to <code>[mla_gallery]</code> as <code>s</code>. The <code>mla_search_fields</code>, <code>mla_search_connector</code>, <code>sentence</code> and <code>exact</code> parameters are passed to <code>[mla_gallery]</code> as well.
|
1190 |
</p>
|
1191 |
<p>
|
1192 |
The <code>[muie_per_page]</code> shortcode generates a text box that accepts the number of posts per page to be displayed in the gallery. The value entered in the text box is passed to <code>[mla_gallery]</code> as <code>muie_per_page</code> and it will be converted to <code>posts_per_page</code>. The initial gallery display will not be limited unless you also add an explicit <code>posts_per_page</code> parameter to <code>[mla_gallery]</code>; as the above example shows, its value should match the default value entered in <code>[muie_per_page]</code>.
|
1221 |
<br /> <br />
|
1222 |
The above example also limits the display to the ten most recent values and adds a count of the number of items selected by each value to the display.
|
1223 |
</p>
|
1224 |
+
<h4>Archive List and MLA Gallery combinations</h4>
|
1225 |
<p>
|
1226 |
The MUIE Archive List shortcode is designed to work with the <code>[mla_gallery]</code> shortcode to display galleries filtered by a date value. To link the archive list to the gallery simply add <code>archive_parameter_name=muie_current_archive</code> to your <code>[mla_gallery]</code> shortcode. Here is a simple example combining an archive search form with a gallery display:
|
1227 |
<br /> <br />
|
1249 |
<br /> <br />
|
1250 |
Note the double backslash characters in the template; they prevent the template processor from interpreting the parentheses as a "Conditional" element. Two are required because of the way WordPress processes shortcode parameters.
|
1251 |
</p>
|
1252 |
+
<h4>Filtering the MLA Gallery directly</h4>
|
1253 |
+
<p>You can use the <code>[mla_gallery]</code> parameters by themselves to filter a gallery display by date values. This is particularly useful when you want to filter based on a date held in a custom field, which the core WordPress date parameters and date query do not support. For example, if you have a custom field named "Publication Date" and want to display what was published in 2020 you can code something like:
|
1254 |
+
<br /> <br />
|
1255 |
+
<code>[mla_gallery post_parent=all archive_parameter_name=muie_current_archive muie_current_archive="custom:Publication Date,Y(2020)"]
|
1256 |
+
</code>
|
1257 |
+
<br /> <br />
|
1258 |
+
Note the use of <code>post_parent=all</code> to overide the default display of items attached to the current post/page. You can use the <code>current_timestamp</code>, <code>current_datetime</code> and <code>current_getdate</code> field-level data sources to, for example, return items published in the current month. Code something like:
|
1259 |
+
<br /> <br />
|
1260 |
+
<code>[mla_gallery post_parent=all archive_parameter_name=muie_current_archive muie_current_archive="custom:Publication Date,M({+current_datetime,date( 'Ym' )+})"]
|
1261 |
+
</code>
|
1262 |
+
<br /> <br />
|
1263 |
+
By adjusting the format code you can specify any of the four archive types: daily 'Ymd', weekly 'YW', monthly 'Ym', yearly 'Y'.
|
1264 |
+
</p>
|
1265 |
+
<h4>Filtered Archive List and MLA Gallery combinations</h4>
|
1266 |
<p>
|
1267 |
As described in the "Archive List Data Selection Parameters" section above you can filter the archive list to show the dates present in a subset of your Media Library items. For example, here is a taxonomy term-specific variation on the archive search form:
|
1268 |
<br /> <br />
|
1278 |
<br /> <br />
|
1279 |
This example will initially show all items assigned to <code>attachment_category=abc</code> and the dropdown control will show only those dates that have one or more items assigned to the term. Selecting an archive value will combine the term filter and the date filter for the gallery display.
|
1280 |
</p>
|
1281 |
+
<h4>Combining an Archive List with other criteria</h4>
|
1282 |
<p>
|
|
|
1283 |
Finally, here is an example that shows how you can combine <code>[muie_archive_list]</code> with the other MUIE elements to create a powerful multi-criteria search application. In this example the <code>tax_input={+template:({+request:tax_input,array+})+}</code> parameter added to the <code>[muie_archive_list]</code> shortcode links the archive list to whatever taxonomy term is selected in the <code>[mla_term_list]</code> shortcode:
|
1284 |
<br /> <br />
|
1285 |
<code>
|
examples/plugins/mla-ui-elements-example/mla-ui-elements-example.php
CHANGED
@@ -5,53 +5,6 @@
|
|
5 |
*
|
6 |
* Detailed information is in the Settings/MLA UI Elements Documentation tab.
|
7 |
*
|
8 |
-
* In this example:
|
9 |
-
*
|
10 |
-
* 1. If you add "use_filters=true" to an [mla_term_list] shortcode this plugin will retain the
|
11 |
-
* selected terms when the page is refreshed and pass them back into the shortcode.
|
12 |
-
*
|
13 |
-
* 2. If you add "add_filters_to=any" to an [mla_gallery] shortcode this plugin will retain
|
14 |
-
* settings for terms search, keyword search, taxonomy queries and posts_per_page when the
|
15 |
-
* page is refreshed or pagination moves to a new page.
|
16 |
-
*
|
17 |
-
* 3. If you add "add_filters_to=<taxonomy_slug>" to an [mla_gallery] shortcode this plugin will
|
18 |
-
* do the actions in 2. and will also match the taxonomy_slug to a simple taxonomy query (if
|
19 |
-
* present) and add that query to the taxonomy queries. If the simple query is 'muie-no-terms',
|
20 |
-
* it will be ignored.
|
21 |
-
*
|
22 |
-
* 4. If you add "default_empty_gallery=true" an [mla_gallery] shortcode the initial gallery display
|
23 |
-
* will show no items, until a selection is made from the other controls.
|
24 |
-
*
|
25 |
-
* 5. The [muie_archive_list] lets you construct lists and controls for filtering a gallery on the
|
26 |
-
* values of date variables in the items' post row or a custom field.
|
27 |
-
*
|
28 |
-
* 6. Shortcodes are provided to generate text box controls and retain their settings when the
|
29 |
-
* page is refreshed or pagination moves to a new page:
|
30 |
-
*
|
31 |
-
* [muie_terms_search] generates a terms search text box
|
32 |
-
* [muie_keyword_search] generates a keyword search text box
|
33 |
-
* [muie_orderby] generates an order by dropdown control
|
34 |
-
* [muie_order] generates ascending/descending radio buttons
|
35 |
-
* [muie_per_page] generates an items per page text box
|
36 |
-
* [muie_assigned_items_count] returns the number of items assigned to any term(s) in the
|
37 |
-
* selected taxonomy
|
38 |
-
*
|
39 |
-
* 7. With a bit of work you can add a tag cloud that works with these filters. Here's an example
|
40 |
-
* you can adapt for your application:
|
41 |
-
*
|
42 |
-
* <style type='text/css'>
|
43 |
-
* #mla-tag-cloud .mla_current_item {
|
44 |
-
* color:#FF0000;
|
45 |
-
* font-weight:bold}
|
46 |
-
* </style>
|
47 |
-
* <span id=mla-tag-cloud>
|
48 |
-
* <strong>Tag Cloud</strong>
|
49 |
-
* [mla_tag_cloud taxonomy=attachment_tag number=20 current_item="{+request:current_item+}" mla_link_href="{+currentlink_url+}&tax_input{{+query:taxonomy+}}{}={+slug+}&muie_per_page={+template:({+request:muie_per_page+}|5)+}" link_class="{+current_item_class+}"]
|
50 |
-
* </span>
|
51 |
-
*
|
52 |
-
* This example plugin uses three of the many filters available in the [mla_gallery] and [mla_term_list] shortcodes
|
53 |
-
* and illustrates some of the techniques you can use to customize the gallery display and term list controls.
|
54 |
-
*
|
55 |
* Created for support topic "How do I provide a front-end search of my media items using Custom Fields?"
|
56 |
* opened on 4/15/2016 by "direys".
|
57 |
* https://wordpress.org/support/topic/how-do-i-provide-a-front-end-search-of-my-media-items-using-custom-fields
|
@@ -92,8 +45,16 @@
|
|
92 |
* opened on 5/18/2021 by "heb51".
|
93 |
* https://wordpress.org/support/topic/checklist-behaviour-my_custom_sql-muie_terms_search/
|
94 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
* @package MLA UI Elements Example
|
96 |
-
* @version 2.
|
97 |
*/
|
98 |
|
99 |
/*
|
@@ -101,10 +62,10 @@ Plugin Name: MLA UI Elements Example
|
|
101 |
Plugin URI: http://davidlingren.com/
|
102 |
Description: Provides shortcodes to improve user experience for [mla_term_list], [mla_tag_cloud] and [mla_gallery] shortcodes. Adds [muie_archive_list] for date-based archive lists.
|
103 |
Author: David Lingren
|
104 |
-
Version: 2.
|
105 |
Author URI: http://davidlingren.com/
|
106 |
|
107 |
-
Copyright 2016-
|
108 |
|
109 |
This program is free software; you can redistribute it and/or modify
|
110 |
it under the terms of the GNU General Public License as published by
|
@@ -135,7 +96,7 @@ class MLAUIElementsExample {
|
|
135 |
*
|
136 |
* @var integer
|
137 |
*/
|
138 |
-
const PLUGIN_VERSION = '2.
|
139 |
|
140 |
/**
|
141 |
* Constant to log this plugin's debug activity
|
@@ -216,6 +177,7 @@ class MLAUIElementsExample {
|
|
216 |
|
217 |
add_filter( 'mla_term_list_attributes', 'MLAUIElementsExample::mla_term_list_attributes', 10, 1 );
|
218 |
add_filter( 'mla_gallery_attributes', 'MLAUIElementsExample::mla_gallery_attributes', 10, 1 );
|
|
|
219 |
|
220 |
// Add the custom shortcode for generating "sticky" term search text box
|
221 |
add_shortcode( 'muie_terms_search', 'MLAUIElementsExample::muie_terms_search' );
|
@@ -269,8 +231,11 @@ class MLAUIElementsExample {
|
|
269 |
*/
|
270 |
public static function mla_term_list_attributes( $shortcode_attributes ) {
|
271 |
// Exit if this is not a "filtered" term list
|
272 |
-
$use_filters = !empty( $shortcode_attributes['use_filters'] )
|
273 |
unset( $shortcode_attributes['use_filters'] );
|
|
|
|
|
|
|
274 |
if ( !$use_filters ) {
|
275 |
return $shortcode_attributes;
|
276 |
}
|
@@ -309,6 +274,8 @@ class MLAUIElementsExample {
|
|
309 |
// Handle default 'tax_input[[+taxonomy+]][]' values
|
310 |
if ( $index = strpos( $mla_control_name, '[]' ) ) {
|
311 |
$mla_control_name = substr( $mla_control_name, 0, $index );
|
|
|
|
|
312 |
}
|
313 |
}
|
314 |
|
@@ -325,37 +292,44 @@ class MLAUIElementsExample {
|
|
325 |
}
|
326 |
}
|
327 |
|
328 |
-
|
329 |
if ( $mla_control_name && !empty( $_REQUEST[ $mla_control_name ] ) ) {
|
330 |
self::$mla_control_names[ $mla_control_name ] = $_REQUEST[ $mla_control_name ];
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
foreach( $input as $input_element ) {
|
338 |
-
$value = explode( '.', $input_element );
|
339 |
-
|
340 |
-
if ( 2 === count( $value ) ) {
|
341 |
-
$taxonomy = $value[0];
|
342 |
-
$_REQUEST['tax_input'][ $taxonomy ][] = $value[1];
|
343 |
} else {
|
344 |
-
$
|
345 |
}
|
346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
}
|
348 |
-
|
349 |
// If nothing is set for this taxonomy we're done
|
350 |
-
if ( empty( $
|
351 |
if ( $muie_debug ) {
|
352 |
-
MLACore::mla_debug_add( __LINE__ . ' MLAUIElementsExample::mla_term_list_attributes no
|
353 |
}
|
354 |
|
355 |
return $shortcode_attributes;
|
356 |
}
|
357 |
|
358 |
-
$terms = $_REQUEST['tax_input'][ $taxonomy ];
|
359 |
if ( is_string( $terms ) ) {
|
360 |
$terms = (array) trim( stripslashes( $terms ), ' \'"' );
|
361 |
}
|
@@ -382,9 +356,14 @@ class MLAUIElementsExample {
|
|
382 |
}
|
383 |
|
384 |
// Reflect option_all changes in the query arguments
|
385 |
-
|
|
|
|
|
|
|
|
|
|
|
386 |
if ( $muie_debug ) {
|
387 |
-
MLACore::mla_debug_add( __LINE__ . ' MLAUIElementsExample::mla_term_list_attributes
|
388 |
}
|
389 |
|
390 |
// Pass selected terms to the shortcode
|
@@ -467,6 +446,9 @@ class MLAUIElementsExample {
|
|
467 |
// Fill these in from $_REQUEST parameters
|
468 |
$muie_filters = array();
|
469 |
|
|
|
|
|
|
|
470 |
/*
|
471 |
* Special handling of the current archive parameter to make archive processing easier.
|
472 |
* Look for this parameter in $_REQUEST if it's not present in the shortcode itself.
|
@@ -481,9 +463,11 @@ class MLAUIElementsExample {
|
|
481 |
unset( $shortcode_attributes[ $archive_parameter_name ] );
|
482 |
}
|
483 |
|
484 |
-
$
|
485 |
-
|
486 |
-
|
|
|
|
|
487 |
}
|
488 |
|
489 |
// Add the orderby & order parameters
|
@@ -499,9 +483,6 @@ class MLAUIElementsExample {
|
|
499 |
$muie_filters['muie_order'] = $shortcode_attributes['order'] = $_REQUEST['muie_order'];
|
500 |
}
|
501 |
|
502 |
-
// Flag for the "empty_default_gallery" parameter
|
503 |
-
$default_gallery = true;
|
504 |
-
|
505 |
// Add the terms search parameters, if present
|
506 |
if ( !empty( $_REQUEST['muie_terms_search'] ) && is_array( $_REQUEST['muie_terms_search'] ) && !empty( $_REQUEST['muie_terms_search']['mla_terms_phrases'] ) ) {
|
507 |
$default_gallery = false;
|
@@ -514,10 +495,24 @@ class MLAUIElementsExample {
|
|
514 |
}
|
515 |
|
516 |
// Add the keyword search parameters, if present
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
$default_gallery = false;
|
519 |
$muie_filters['muie_keyword_search'] = $_REQUEST['muie_keyword_search'];
|
520 |
-
foreach( $
|
521 |
if ( !empty( $value ) ) {
|
522 |
$shortcode_attributes[ $key ] = $value;
|
523 |
}
|
@@ -564,6 +559,7 @@ class MLAUIElementsExample {
|
|
564 |
if ( !empty( $simple_tax_queries ) ) {
|
565 |
foreach ( $simple_tax_queries as $key => $value ) {
|
566 |
$tax_input[ $key ] = explode( ',', $value );
|
|
|
567 |
}
|
568 |
}
|
569 |
if ( $muie_debug ) {
|
@@ -702,13 +698,12 @@ class MLAUIElementsExample {
|
|
702 |
}
|
703 |
|
704 |
// Add the filter settings to pagination URLs
|
|
|
705 |
if ( !empty( $shortcode_attributes['mla_output'] ) ) {
|
706 |
-
|
707 |
-
$filters = urlencode( json_encode( $muie_filters ) );
|
708 |
-
$shortcode_attributes['mla_link_href'] = '[+new_url+]?[+new_page_text+]&muie_filters=' . $filters;
|
709 |
|
710 |
if ( !empty( $shortcode_attributes['posts_per_page'] ) ) {
|
711 |
-
|
712 |
}
|
713 |
}
|
714 |
|
@@ -721,6 +716,47 @@ class MLAUIElementsExample {
|
|
721 |
return $shortcode_attributes;
|
722 |
} // mla_gallery_attributes
|
723 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
724 |
/**
|
725 |
* Terms search generator shortcode
|
726 |
*
|
@@ -735,10 +771,11 @@ class MLAUIElementsExample {
|
|
735 |
*/
|
736 |
public static function muie_terms_search( $attr, $content = NULL ) {
|
737 |
$default_arguments = array(
|
|
|
|
|
738 |
'mla_terms_phrases' => '',
|
739 |
'mla_terms_taxonomies' => '',
|
740 |
'mla_phrase_delimiter' => '',
|
741 |
-
'mla_term_delimiter' => '',
|
742 |
'mla_phrase_connector' => '',
|
743 |
'mla_term_delimiter' => '',
|
744 |
'mla_term_connector' => '',
|
@@ -749,6 +786,10 @@ class MLAUIElementsExample {
|
|
749 |
|
750 |
// Accept only the attributes we need and supply defaults
|
751 |
$arguments = shortcode_atts( $default_arguments, $attr );
|
|
|
|
|
|
|
|
|
752 |
|
753 |
// Pagination links, e.g. Previous or Next, have muie_filters that encode the form parameters
|
754 |
if ( !empty( $_REQUEST['muie_filters'] ) ) {
|
@@ -761,9 +802,17 @@ class MLAUIElementsExample {
|
|
761 |
|
762 |
// muie_terms_search has settings from the form or pagination link
|
763 |
if ( !empty( $_REQUEST['muie_terms_search'] ) && is_array( $_REQUEST['muie_terms_search'] ) ) {
|
764 |
-
|
765 |
-
|
766 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
767 |
}
|
768 |
}
|
769 |
}
|
@@ -775,14 +824,31 @@ class MLAUIElementsExample {
|
|
775 |
$delimiter = '"';
|
776 |
}
|
777 |
|
778 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
779 |
unset( $arguments['mla_terms_phrases'] );
|
780 |
|
781 |
// Add optional parameters
|
782 |
foreach( $arguments as $key => $value ) {
|
783 |
if ( !empty( $value ) ) {
|
784 |
$id_value = str_replace( '_', '-', substr( $key, 4 ) );
|
785 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
786 |
}
|
787 |
}
|
788 |
|
@@ -803,6 +869,8 @@ class MLAUIElementsExample {
|
|
803 |
*/
|
804 |
public static function muie_keyword_search( $attr, $content = NULL ) {
|
805 |
$default_arguments = array(
|
|
|
|
|
806 |
's' => '',
|
807 |
'mla_search_fields' => '',
|
808 |
'mla_search_connector' => '',
|
@@ -815,6 +883,10 @@ class MLAUIElementsExample {
|
|
815 |
|
816 |
// Accept only the attributes we need and supply defaults
|
817 |
$arguments = shortcode_atts( $default_arguments, $attr );
|
|
|
|
|
|
|
|
|
818 |
|
819 |
// Pagination links, e.g. Previous or Next, have muie_filters that encode the form parameters
|
820 |
if ( !empty( $_REQUEST['muie_filters'] ) ) {
|
@@ -827,9 +899,17 @@ class MLAUIElementsExample {
|
|
827 |
|
828 |
// muie_keyword_search has settings from the form or pagination link
|
829 |
if ( !empty( $_REQUEST['muie_keyword_search'] ) && is_array( $_REQUEST['muie_keyword_search'] ) ) {
|
830 |
-
|
831 |
-
|
832 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
833 |
}
|
834 |
}
|
835 |
}
|
@@ -841,14 +921,35 @@ class MLAUIElementsExample {
|
|
841 |
$delimiter = '"';
|
842 |
}
|
843 |
|
844 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
845 |
unset( $arguments['s'] );
|
846 |
|
847 |
// Add optional parameters
|
848 |
foreach( $arguments as $key => $value ) {
|
849 |
if ( !empty( $value ) ) {
|
850 |
-
|
851 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
}
|
853 |
}
|
854 |
|
5 |
*
|
6 |
* Detailed information is in the Settings/MLA UI Elements Documentation tab.
|
7 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
* Created for support topic "How do I provide a front-end search of my media items using Custom Fields?"
|
9 |
* opened on 4/15/2016 by "direys".
|
10 |
* https://wordpress.org/support/topic/how-do-i-provide-a-front-end-search-of-my-media-items-using-custom-fields
|
45 |
* opened on 5/18/2021 by "heb51".
|
46 |
* https://wordpress.org/support/topic/checklist-behaviour-my_custom_sql-muie_terms_search/
|
47 |
*
|
48 |
+
* Enhanced (named control fixes) for support topic "how to split 2 types of tags?"
|
49 |
+
* opened on 5/29/2022 by "agdagan".
|
50 |
+
* https://wordpress.org/support/topic/how-to-split-2-types-of-tags/
|
51 |
+
*
|
52 |
+
* Enhanced (attributes parameters on keyword and terms search) for support topic "How to paginate 2 separate gallery"
|
53 |
+
* opened on 6/12/2022 by "jejela19".
|
54 |
+
* https://wordpress.org/support/topic/how-to-paginate-2-separate-gallery/
|
55 |
+
*
|
56 |
* @package MLA UI Elements Example
|
57 |
+
* @version 2.04
|
58 |
*/
|
59 |
|
60 |
/*
|
62 |
Plugin URI: http://davidlingren.com/
|
63 |
Description: Provides shortcodes to improve user experience for [mla_term_list], [mla_tag_cloud] and [mla_gallery] shortcodes. Adds [muie_archive_list] for date-based archive lists.
|
64 |
Author: David Lingren
|
65 |
+
Version: 2.04
|
66 |
Author URI: http://davidlingren.com/
|
67 |
|
68 |
+
Copyright 2016-2022 David Lingren
|
69 |
|
70 |
This program is free software; you can redistribute it and/or modify
|
71 |
it under the terms of the GNU General Public License as published by
|
96 |
*
|
97 |
* @var integer
|
98 |
*/
|
99 |
+
const PLUGIN_VERSION = '2.04';
|
100 |
|
101 |
/**
|
102 |
* Constant to log this plugin's debug activity
|
177 |
|
178 |
add_filter( 'mla_term_list_attributes', 'MLAUIElementsExample::mla_term_list_attributes', 10, 1 );
|
179 |
add_filter( 'mla_gallery_attributes', 'MLAUIElementsExample::mla_gallery_attributes', 10, 1 );
|
180 |
+
add_filter( 'mla_gallery_pagination_values', 'MLAUIElementsExample::mla_gallery_pagination_values', 10, 1 );
|
181 |
|
182 |
// Add the custom shortcode for generating "sticky" term search text box
|
183 |
add_shortcode( 'muie_terms_search', 'MLAUIElementsExample::muie_terms_search' );
|
231 |
*/
|
232 |
public static function mla_term_list_attributes( $shortcode_attributes ) {
|
233 |
// Exit if this is not a "filtered" term list
|
234 |
+
$use_filters = !empty( $shortcode_attributes['use_filters'] ) ? trim ( strtolower( $shortcode_attributes['use_filters'] ) ) : '';;
|
235 |
unset( $shortcode_attributes['use_filters'] );
|
236 |
+
|
237 |
+
$local_filters = 'local' === $use_filters;
|
238 |
+
$use_filters = $local_filters || 'true' === $use_filters;
|
239 |
if ( !$use_filters ) {
|
240 |
return $shortcode_attributes;
|
241 |
}
|
274 |
// Handle default 'tax_input[[+taxonomy+]][]' values
|
275 |
if ( $index = strpos( $mla_control_name, '[]' ) ) {
|
276 |
$mla_control_name = substr( $mla_control_name, 0, $index );
|
277 |
+
} elseif ( $index = strpos( $mla_control_name, '{}' ) ) {
|
278 |
+
$mla_control_name = substr( $mla_control_name, 0, $index );
|
279 |
}
|
280 |
}
|
281 |
|
292 |
}
|
293 |
}
|
294 |
|
295 |
+
$terms = array();
|
296 |
if ( $mla_control_name && !empty( $_REQUEST[ $mla_control_name ] ) ) {
|
297 |
self::$mla_control_names[ $mla_control_name ] = $_REQUEST[ $mla_control_name ];
|
298 |
+
$terms = $_REQUEST[ $mla_control_name ];
|
299 |
+
|
300 |
+
// Copy named control terms to tax_input by default
|
301 |
+
if ( !$local_filters ) {
|
302 |
+
if ( is_scalar( $terms ) ) {
|
303 |
+
$input = array( $terms );
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
} else {
|
305 |
+
$input = $terms;
|
306 |
}
|
307 |
+
|
308 |
+
// Check for with possible taxonomy.term values from "combined" taxonomies
|
309 |
+
foreach( $input as $input_element ) {
|
310 |
+
$value = explode( '.', $input_element );
|
311 |
+
|
312 |
+
if ( 2 === count( $value ) ) {
|
313 |
+
$taxonomy = $value[0];
|
314 |
+
$_REQUEST['tax_input'][ $taxonomy ][] = $value[1];
|
315 |
+
} else {
|
316 |
+
$_REQUEST['tax_input'][ $taxonomy ][] = $input_element;
|
317 |
+
}
|
318 |
+
}
|
319 |
+
} // !$local_filters
|
320 |
+
} elseif ( !empty( $_REQUEST['tax_input'] ) && array_key_exists( $taxonomy, $_REQUEST['tax_input'] ) ) {
|
321 |
+
$terms = $_REQUEST['tax_input'][ $taxonomy ];
|
322 |
}
|
323 |
+
|
324 |
// If nothing is set for this taxonomy we're done
|
325 |
+
if ( empty( $terms ) ) {
|
326 |
if ( $muie_debug ) {
|
327 |
+
MLACore::mla_debug_add( __LINE__ . ' MLAUIElementsExample::mla_term_list_attributes no terms present' );
|
328 |
}
|
329 |
|
330 |
return $shortcode_attributes;
|
331 |
}
|
332 |
|
|
|
333 |
if ( is_string( $terms ) ) {
|
334 |
$terms = (array) trim( stripslashes( $terms ), ' \'"' );
|
335 |
}
|
356 |
}
|
357 |
|
358 |
// Reflect option_all changes in the query arguments
|
359 |
+
if ( $mla_control_name ) {
|
360 |
+
$_REQUEST[ $mla_control_name ] = $terms;
|
361 |
+
} else {
|
362 |
+
$_REQUEST['tax_input'][ $taxonomy ] = $terms;
|
363 |
+
}
|
364 |
+
|
365 |
if ( $muie_debug ) {
|
366 |
+
MLACore::mla_debug_add( __LINE__ . ' MLAUIElementsExample::mla_term_list_attributes _REQUEST = ' . var_export( $_REQUEST, true ) );
|
367 |
}
|
368 |
|
369 |
// Pass selected terms to the shortcode
|
446 |
// Fill these in from $_REQUEST parameters
|
447 |
$muie_filters = array();
|
448 |
|
449 |
+
// Flag for the "empty_default_gallery" parameter
|
450 |
+
$default_gallery = true;
|
451 |
+
|
452 |
/*
|
453 |
* Special handling of the current archive parameter to make archive processing easier.
|
454 |
* Look for this parameter in $_REQUEST if it's not present in the shortcode itself.
|
463 |
unset( $shortcode_attributes[ $archive_parameter_name ] );
|
464 |
}
|
465 |
|
466 |
+
$mla_control_names = !empty( $shortcode_attributes['mla_control_name'] ) ? explode( ',', $shortcode_attributes['mla_control_name'] ) : array();
|
467 |
+
foreach ( $mla_control_names as $control_name ) {
|
468 |
+
if ( !empty( $_REQUEST[ $control_name ] ) ) {
|
469 |
+
$default_gallery = false;
|
470 |
+
}
|
471 |
}
|
472 |
|
473 |
// Add the orderby & order parameters
|
483 |
$muie_filters['muie_order'] = $shortcode_attributes['order'] = $_REQUEST['muie_order'];
|
484 |
}
|
485 |
|
|
|
|
|
|
|
486 |
// Add the terms search parameters, if present
|
487 |
if ( !empty( $_REQUEST['muie_terms_search'] ) && is_array( $_REQUEST['muie_terms_search'] ) && !empty( $_REQUEST['muie_terms_search']['mla_terms_phrases'] ) ) {
|
488 |
$default_gallery = false;
|
495 |
}
|
496 |
|
497 |
// Add the keyword search parameters, if present
|
498 |
+
$muie_keyword_search = array( 's' => '', );
|
499 |
+
if ( !empty( $_REQUEST['muie_keyword_search'] ) && is_array( $_REQUEST['muie_keyword_search'] ) ) {
|
500 |
+
if ( !empty( $shortcode_attributes['muie_keyword_parameter'] ) && isset( $_REQUEST['muie_keyword_search'][ $shortcode_attributes['muie_keyword_parameter'] ] ) ) {
|
501 |
+
$muie_keyword_search = $_REQUEST['muie_keyword_search'][ $shortcode_attributes['muie_keyword_parameter'] ];
|
502 |
+
} else {
|
503 |
+
// Skip any named muie_keyword_parameter arrays and copy default values
|
504 |
+
foreach ( $_REQUEST['muie_keyword_search'] as $key => $value ) {
|
505 |
+
if ( !is_array( $value ) ) {
|
506 |
+
$muie_keyword_search[ $key ] = $value;
|
507 |
+
}
|
508 |
+
}
|
509 |
+
}
|
510 |
+
}
|
511 |
+
|
512 |
+
if ( !empty( $muie_keyword_search['s'] ) ) {
|
513 |
$default_gallery = false;
|
514 |
$muie_filters['muie_keyword_search'] = $_REQUEST['muie_keyword_search'];
|
515 |
+
foreach( $muie_keyword_search as $key => $value ) {
|
516 |
if ( !empty( $value ) ) {
|
517 |
$shortcode_attributes[ $key ] = $value;
|
518 |
}
|
559 |
if ( !empty( $simple_tax_queries ) ) {
|
560 |
foreach ( $simple_tax_queries as $key => $value ) {
|
561 |
$tax_input[ $key ] = explode( ',', $value );
|
562 |
+
unset( $shortcode_attributes[ $key ] );
|
563 |
}
|
564 |
}
|
565 |
if ( $muie_debug ) {
|
698 |
}
|
699 |
|
700 |
// Add the filter settings to pagination URLs
|
701 |
+
MLAUIElementsExample::$muie_filters = array();
|
702 |
if ( !empty( $shortcode_attributes['mla_output'] ) ) {
|
703 |
+
MLAUIElementsExample::$muie_filters['muie_filters'] = urlencode( json_encode( $muie_filters ) );
|
|
|
|
|
704 |
|
705 |
if ( !empty( $shortcode_attributes['posts_per_page'] ) ) {
|
706 |
+
MLAUIElementsExample::$muie_filters['muie_per_page'] = $shortcode_attributes['posts_per_page'];
|
707 |
}
|
708 |
}
|
709 |
|
716 |
return $shortcode_attributes;
|
717 |
} // mla_gallery_attributes
|
718 |
|
719 |
+
/**
|
720 |
+
* Pass muie_filters from mla_gallery_attributes to mla_gallery_pagination_values
|
721 |
+
*
|
722 |
+
* @since 2.02
|
723 |
+
*
|
724 |
+
* @var array
|
725 |
+
*/
|
726 |
+
private static $muie_filters = NULL;
|
727 |
+
|
728 |
+
/**
|
729 |
+
* Pagination control substitution values
|
730 |
+
*
|
731 |
+
* @since 2.02
|
732 |
+
*
|
733 |
+
* @param array substitution para,eters and values
|
734 |
+
*/
|
735 |
+
public static function mla_gallery_pagination_values( $markup_values ) {
|
736 |
+
// Add or replace the filter parameters
|
737 |
+
if ( !empty( MLAUIElementsExample::$muie_filters ) ) {
|
738 |
+
$old_query = $markup_values['query_string'];
|
739 |
+
$new_query = remove_query_arg( MLAUIElementsExample::$muie_filters, $old_query );
|
740 |
+
$new_query = add_query_arg( MLAUIElementsExample::$muie_filters, $new_query );
|
741 |
+
|
742 |
+
if ( '?' !== $new_query[0] ) {
|
743 |
+
$new_query = '?' . $new_query;
|
744 |
+
}
|
745 |
+
|
746 |
+
$markup_values['query_string'] = $new_query;
|
747 |
+
|
748 |
+
if ( !empty( $old_query ) ) {
|
749 |
+
$markup_values['request_uri'] = str_replace( $old_query, $new_query, $markup_values['request_uri'] );
|
750 |
+
$markup_values['new_url'] = str_replace( $old_query, $new_query, $markup_values['new_url'] );
|
751 |
+
} else {
|
752 |
+
$markup_values['request_uri'] .= $new_query;
|
753 |
+
$markup_values['new_url'] .= $new_query;
|
754 |
+
}
|
755 |
+
}
|
756 |
+
|
757 |
+
return $markup_values;
|
758 |
+
} // mla_gallery_pagination_values
|
759 |
+
|
760 |
/**
|
761 |
* Terms search generator shortcode
|
762 |
*
|
771 |
*/
|
772 |
public static function muie_terms_search( $attr, $content = NULL ) {
|
773 |
$default_arguments = array(
|
774 |
+
'muie_terms_parameter' => '',
|
775 |
+
'muie_attributes' => '',
|
776 |
'mla_terms_phrases' => '',
|
777 |
'mla_terms_taxonomies' => '',
|
778 |
'mla_phrase_delimiter' => '',
|
|
|
779 |
'mla_phrase_connector' => '',
|
780 |
'mla_term_delimiter' => '',
|
781 |
'mla_term_connector' => '',
|
786 |
|
787 |
// Accept only the attributes we need and supply defaults
|
788 |
$arguments = shortcode_atts( $default_arguments, $attr );
|
789 |
+
$qualifier = $arguments['muie_terms_parameter'];
|
790 |
+
unset( $arguments['muie_terms_parameter'] );
|
791 |
+
$muie_attributes = MLAShortcodes::mla_validate_attributes( $arguments['muie_attributes'] );
|
792 |
+
unset( $arguments['muie_attributes'] );
|
793 |
|
794 |
// Pagination links, e.g. Previous or Next, have muie_filters that encode the form parameters
|
795 |
if ( !empty( $_REQUEST['muie_filters'] ) ) {
|
802 |
|
803 |
// muie_terms_search has settings from the form or pagination link
|
804 |
if ( !empty( $_REQUEST['muie_terms_search'] ) && is_array( $_REQUEST['muie_terms_search'] ) ) {
|
805 |
+
if ( empty( $qualifier ) ) {
|
806 |
+
foreach ( $arguments as $key => $value ) {
|
807 |
+
if ( !empty( $_REQUEST['muie_terms_search'][ $key ] ) ) {
|
808 |
+
$arguments[ $key ] = stripslashes( $_REQUEST['muie_terms_search'][ $key ] );
|
809 |
+
}
|
810 |
+
}
|
811 |
+
} else {
|
812 |
+
foreach ( $arguments as $key => $value ) {
|
813 |
+
if ( !empty( $_REQUEST['muie_terms_search'][$qualifier][ $key ] ) ) {
|
814 |
+
$arguments[ $key ] = stripslashes( $_REQUEST['muie_terms_search'][$qualifier][ $key ] );
|
815 |
+
}
|
816 |
}
|
817 |
}
|
818 |
}
|
824 |
$delimiter = '"';
|
825 |
}
|
826 |
|
827 |
+
$added_attributes = array_merge( array( 'type' => 'text', 'size' => '20' ), $muie_attributes );
|
828 |
+
$attributes = ' ';
|
829 |
+
foreach ( $added_attributes as $key => $value ) {
|
830 |
+
$attributes .= $key . '="' . $value . '" ';
|
831 |
+
}
|
832 |
+
|
833 |
+
if ( empty( $qualifier ) ) {
|
834 |
+
$return_value = '<input name="muie_terms_search[mla_terms_phrases]" id="muie-terms-phrases"' . $attributes . 'value=' . $delimiter . $arguments['mla_terms_phrases'] . $delimiter . " />\n";
|
835 |
+
} else {
|
836 |
+
$return_value = '<input name="muie_terms_search[' . $qualifier . '][mla_terms_phrases]" id="muie-terms-phrases-' . $qualifier . '"' . $attributes . 'value=' . $delimiter . $arguments['mla_terms_phrases'] . $delimiter . " />\n";
|
837 |
+
}
|
838 |
+
|
839 |
unset( $arguments['mla_terms_phrases'] );
|
840 |
|
841 |
// Add optional parameters
|
842 |
foreach( $arguments as $key => $value ) {
|
843 |
if ( !empty( $value ) ) {
|
844 |
$id_value = str_replace( '_', '-', substr( $key, 4 ) );
|
845 |
+
|
846 |
+
if ( empty( $qualifier ) ) {
|
847 |
+
$return_value .= sprintf( '<input name="muie_terms_search[%1$s]" id="muie-%2$s" type="hidden" value="%3$s" />%4$s', $key, $id_value, $value, "\n" );
|
848 |
+
} else {
|
849 |
+
$id_value .= '-' . $qualifier;
|
850 |
+
$return_value .= sprintf( '<input name="muie_terms_search[' . $qualifier . '][%1$s]" id="muie-%2$s" type="hidden" value="%3$s" />%4$s', $key, $id_value, $value, "\n" );
|
851 |
+
}
|
852 |
}
|
853 |
}
|
854 |
|
869 |
*/
|
870 |
public static function muie_keyword_search( $attr, $content = NULL ) {
|
871 |
$default_arguments = array(
|
872 |
+
'muie_keyword_parameter' => '',
|
873 |
+
'muie_attributes' => '',
|
874 |
's' => '',
|
875 |
'mla_search_fields' => '',
|
876 |
'mla_search_connector' => '',
|
883 |
|
884 |
// Accept only the attributes we need and supply defaults
|
885 |
$arguments = shortcode_atts( $default_arguments, $attr );
|
886 |
+
$qualifier = $arguments['muie_keyword_parameter'];
|
887 |
+
unset( $arguments['muie_keyword_parameter'] );
|
888 |
+
$muie_attributes = MLAShortcodes::mla_validate_attributes( $arguments['muie_attributes'] );
|
889 |
+
unset( $arguments['muie_attributes'] );
|
890 |
|
891 |
// Pagination links, e.g. Previous or Next, have muie_filters that encode the form parameters
|
892 |
if ( !empty( $_REQUEST['muie_filters'] ) ) {
|
899 |
|
900 |
// muie_keyword_search has settings from the form or pagination link
|
901 |
if ( !empty( $_REQUEST['muie_keyword_search'] ) && is_array( $_REQUEST['muie_keyword_search'] ) ) {
|
902 |
+
if ( empty( $qualifier ) ) {
|
903 |
+
foreach ( $arguments as $key => $value ) {
|
904 |
+
if ( !empty( $_REQUEST['muie_keyword_search'][ $key ] ) ) {
|
905 |
+
$arguments[ $key ] = stripslashes( $_REQUEST['muie_keyword_search'][ $key ] );
|
906 |
+
}
|
907 |
+
}
|
908 |
+
} else {
|
909 |
+
foreach ( $arguments as $key => $value ) {
|
910 |
+
if ( !empty( $_REQUEST['muie_keyword_search'][$qualifier][ $key ] ) ) {
|
911 |
+
$arguments[ $key ] = stripslashes( $_REQUEST['muie_keyword_search'][$qualifier][ $key ] );
|
912 |
+
}
|
913 |
}
|
914 |
}
|
915 |
}
|
921 |
$delimiter = '"';
|
922 |
}
|
923 |
|
924 |
+
$added_attributes = array_merge( array( 'type' => 'text', 'size' => '20' ), $muie_attributes );
|
925 |
+
$attributes = ' ';
|
926 |
+
foreach ( $added_attributes as $key => $value ) {
|
927 |
+
$attributes .= $key . '="' . $value . '" ';
|
928 |
+
}
|
929 |
+
|
930 |
+
if ( empty( $qualifier ) ) {
|
931 |
+
$return_value = '<input name="muie_keyword_search[s]" id="muie-s"' . $attributes . 'value=' . $delimiter . $arguments['s'] . $delimiter . " />\n";
|
932 |
+
} else {
|
933 |
+
$return_value = '<input name="muie_keyword_search[' . $qualifier . '][s]" id="muie-s-' . $qualifier . '"' . $attributes . 'value=' . $delimiter . $arguments['s'] . $delimiter . " />\n";
|
934 |
+
}
|
935 |
+
|
936 |
unset( $arguments['s'] );
|
937 |
|
938 |
// Add optional parameters
|
939 |
foreach( $arguments as $key => $value ) {
|
940 |
if ( !empty( $value ) ) {
|
941 |
+
if ( 0 === strpos( $key, 'mla' ) ) {
|
942 |
+
$id_value = str_replace( '_', '-', substr( $key, 4 ) );
|
943 |
+
} else {
|
944 |
+
$id_value = str_replace( '_', '-', $key );
|
945 |
+
}
|
946 |
+
|
947 |
+
if ( empty( $qualifier ) ) {
|
948 |
+
$return_value .= sprintf( '<input name="muie_keyword_search[%1$s]" id="muie-%2$s" type="hidden" value="%3$s" />%4$s', $key, $id_value, $value, "\n" );
|
949 |
+
} else {
|
950 |
+
$id_value .= '-' . $qualifier;
|
951 |
+
$return_value .= sprintf( '<input name="muie_keyword_search[' . $qualifier . '][%1$s]" id="muie-%2$s" type="hidden" value="%3$s" />%4$s', $key, $id_value, $value, "\n" );
|
952 |
+
}
|
953 |
}
|
954 |
}
|
955 |
|
includes/class-mla-core-options.php
CHANGED
@@ -287,6 +287,11 @@ class MLACoreOptions {
|
|
287 |
*/
|
288 |
const MLA_DELETE_OPTION_BACKUPS = 'delete_option_backups';
|
289 |
|
|
|
|
|
|
|
|
|
|
|
290 |
/**
|
291 |
* Provides a unique name for the Media Manager Force Image Default Setings option
|
292 |
*/
|
@@ -1106,7 +1111,7 @@ class MLACoreOptions {
|
|
1106 |
'std' => 'checked',
|
1107 |
'help' => __( 'Check this option to allow the "mla_viewer" to generate thumbnail images for PDF documents. Thumbnails are generated dynamically, each time the item appears in an [mla_gallery] display.<br> <strong>IMPORTANT: both Ghostscript and Imagick/ImageMagick must be installed for this feature.</strong>', 'media-library-assistant' )),
|
1108 |
|
1109 |
-
|
1110 |
array('tab' => 'mla_gallery',
|
1111 |
'name' => __( 'Enable Featured Images', 'media-library-assistant' ),
|
1112 |
'type' => 'checkbox',
|
@@ -1135,17 +1140,13 @@ class MLACoreOptions {
|
|
1135 |
'size' => 20,
|
1136 |
'help' => __( 'If your “gs” executable is in a non-standard location, enter the full path and filename here, e.g., “/usr/bin/gs”. It will override the search for Ghostscript in other places.', 'media-library-assistant' )),
|
1137 |
|
1138 |
-
|
1139 |
-
* Managed by mla_get_style_templates and mla_put_style_templates
|
1140 |
-
*/
|
1141 |
'style_templates' =>
|
1142 |
array('tab' => '',
|
1143 |
'type' => 'hidden',
|
1144 |
'std' => array()),
|
1145 |
|
1146 |
-
|
1147 |
-
* Managed by mla_get_markup_templates and mla_put_markup_templates
|
1148 |
-
*/
|
1149 |
'markup_templates' =>
|
1150 |
array('tab' => '',
|
1151 |
'type' => 'hidden',
|
287 |
*/
|
288 |
const MLA_DELETE_OPTION_BACKUPS = 'delete_option_backups';
|
289 |
|
290 |
+
/**
|
291 |
+
* Provides a unique name for the Enabled Featured Image option
|
292 |
+
*/
|
293 |
+
const MLA_ENABLE_FEATURED_IMAGE = 'enable_featured_image';
|
294 |
+
|
295 |
/**
|
296 |
* Provides a unique name for the Media Manager Force Image Default Setings option
|
297 |
*/
|
1111 |
'std' => 'checked',
|
1112 |
'help' => __( 'Check this option to allow the "mla_viewer" to generate thumbnail images for PDF documents. Thumbnails are generated dynamically, each time the item appears in an [mla_gallery] display.<br> <strong>IMPORTANT: both Ghostscript and Imagick/ImageMagick must be installed for this feature.</strong>', 'media-library-assistant' )),
|
1113 |
|
1114 |
+
MLACoreOptions::MLA_ENABLE_FEATURED_IMAGE =>
|
1115 |
array('tab' => 'mla_gallery',
|
1116 |
'name' => __( 'Enable Featured Images', 'media-library-assistant' ),
|
1117 |
'type' => 'checkbox',
|
1140 |
'size' => 20,
|
1141 |
'help' => __( 'If your “gs” executable is in a non-standard location, enter the full path and filename here, e.g., “/usr/bin/gs”. It will override the search for Ghostscript in other places.', 'media-library-assistant' )),
|
1142 |
|
1143 |
+
// Managed by mla_get_style_templates and mla_put_style_templates
|
|
|
|
|
1144 |
'style_templates' =>
|
1145 |
array('tab' => '',
|
1146 |
'type' => 'hidden',
|
1147 |
'std' => array()),
|
1148 |
|
1149 |
+
// Managed by mla_get_markup_templates and mla_put_markup_templates
|
|
|
|
|
1150 |
'markup_templates' =>
|
1151 |
array('tab' => '',
|
1152 |
'type' => 'hidden',
|
includes/class-mla-core.php
CHANGED
@@ -21,7 +21,7 @@ class MLACore {
|
|
21 |
*
|
22 |
* @var string
|
23 |
*/
|
24 |
-
const CURRENT_MLA_VERSION = '
|
25 |
|
26 |
/**
|
27 |
* Current date for Development Versions, empty for production versions
|
@@ -275,6 +275,33 @@ class MLACore {
|
|
275 |
*/
|
276 |
const MLA_ADMIN_SINGLE_ADD = 'single_item_add';
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
/**
|
279 |
* Action name; gives a context for the nonce
|
280 |
*
|
21 |
*
|
22 |
* @var string
|
23 |
*/
|
24 |
+
const CURRENT_MLA_VERSION = '3.01';
|
25 |
|
26 |
/**
|
27 |
* Current date for Development Versions, empty for production versions
|
275 |
*/
|
276 |
const MLA_ADMIN_SINGLE_ADD = 'single_item_add';
|
277 |
|
278 |
+
/**
|
279 |
+
* Action name; gives a context for the 'download-zip'/'mla_download_file nonce
|
280 |
+
*
|
281 |
+
* @since 3.00
|
282 |
+
*
|
283 |
+
* @var string
|
284 |
+
*/
|
285 |
+
const MLA_DOWNLOAD_NONCE_ACTION = 'mla_download_nonce_action';
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Action name; gives a context for the 'mla_download_example_plugin' nonce
|
289 |
+
*
|
290 |
+
* @since 3.00
|
291 |
+
*
|
292 |
+
* @var string
|
293 |
+
*/
|
294 |
+
const MLA_DOWNLOAD_EXAMPLE_NONCE_ACTION = 'mla_download_example_nonce_action';
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Action name; gives a context for the 'mla_download_error_log' nonce
|
298 |
+
*
|
299 |
+
* @since 3.00
|
300 |
+
*
|
301 |
+
* @var string
|
302 |
+
*/
|
303 |
+
const MLA_ERROR_LOG_NONCE_ACTION = 'mla_error_log_nonce_action';
|
304 |
+
|
305 |
/**
|
306 |
* Action name; gives a context for the nonce
|
307 |
*
|
includes/class-mla-data-pdf.php
CHANGED
@@ -714,13 +714,13 @@ class MLAPDF {
|
|
714 |
* @return array ( 'xmp' => array( key => value ), 'pdf' => array( key => value ) ) for each metadata field, in string format
|
715 |
*/
|
716 |
public static function mla_extract_pdf_metadata( $file_name ) {
|
717 |
-
$xmp =
|
718 |
$metadata = array();
|
719 |
self::$pdf_indirect_objects = NULL;
|
720 |
$chunksize = 16384;
|
721 |
|
722 |
if ( ! file_exists( $file_name ) ) {
|
723 |
-
return array( 'xmp' =>
|
724 |
}
|
725 |
|
726 |
$filesize = filesize( $file_name );
|
@@ -740,14 +740,12 @@ class MLAPDF {
|
|
740 |
$metadata['PDF_VersionNumber'] = substr( $header, 5, 3 );
|
741 |
}
|
742 |
|
743 |
-
|
744 |
-
* Find the xref and (optional) trailer
|
745 |
-
*/
|
746 |
$match_count = preg_match_all( '/startxref[\x00-\x20]+(\d+)[\x00-\x20]+\%\%EOF/', $tail, $matches, PREG_OFFSET_CAPTURE );
|
747 |
if ( 0 == $match_count ) {
|
748 |
/* translators: 1: ERROR tag 2: path and file */
|
749 |
MLACore::mla_debug_add( sprintf( _x( '%1$s: File "%2$s", startxref not found.', 'error_log', 'media-library-assistant' ), __( 'ERROR', 'media-library-assistant' ), $path ), MLACore::MLA_DEBUG_CATEGORY_ANY );
|
750 |
-
return array( 'xmp' =>
|
751 |
}
|
752 |
|
753 |
$startxref = (integer) $matches[1][ $match_count - 1 ][0];
|
@@ -766,9 +764,7 @@ class MLAPDF {
|
|
766 |
if ( isset( $info_reference ) ) {
|
767 |
$info_object = self::_find_pdf_indirect_dictionary( $file_name, $info_reference['object'], $info_reference['generation'] );
|
768 |
|
769 |
-
|
770 |
-
* Handle single or multiple Info instances
|
771 |
-
*/
|
772 |
$info_objects = array();
|
773 |
if ( $info_object ) {
|
774 |
if ( 1 == $info_object['count'] ) {
|
@@ -802,20 +798,17 @@ class MLAPDF {
|
|
802 |
} // each info entry
|
803 |
} // foreach Info object
|
804 |
|
805 |
-
|
806 |
-
* Remove spurious "Filter" dictionaries
|
807 |
-
*/
|
808 |
unset( $metadata['Filter'] );
|
809 |
unset( $metadata['Length'] );
|
810 |
unset( $metadata['Length1'] );
|
811 |
} // found Info reference
|
812 |
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata pdf metadata = ' . var_export( $metadata, true ), 0 );
|
813 |
|
814 |
-
|
815 |
-
* Look for XMP Metadata
|
816 |
-
*/
|
817 |
$root_reference = NULL;
|
818 |
//error_log( __LINE__ . " MLAPDF::mla_extract_pdf_metadata info_dictionary = " . var_export( $info_dictionary, true ), 0 );
|
|
|
819 |
foreach ( $trailer_dictionaries as $trailer_dictionary ) {
|
820 |
if ( isset( $trailer_dictionary['Root'] ) ) {
|
821 |
$root_reference = $trailer_dictionary['Root'];
|
@@ -834,20 +827,33 @@ class MLAPDF {
|
|
834 |
|
835 |
if ( isset( $root_dictionary['Metadata'] ) ) {
|
836 |
$xmp_object = self::_find_pdf_indirect_dictionary( $file_name, $root_dictionary['Metadata']['object'], $root_dictionary['Metadata']['generation'] );
|
837 |
-
//error_log( __LINE__ . " MLAPDF::mla_extract_pdf_metadata
|
|
|
838 |
$xmp = MLAData::mla_parse_xmp_metadata( $file_name, $xmp_object['start'] + $xmp_object['length'] );
|
839 |
-
|
840 |
if ( is_array( $xmp ) ) {
|
841 |
$metadata = array_merge( $metadata, $xmp );
|
842 |
-
} else {
|
843 |
-
$xmp = array();
|
844 |
-
$xmp = MLAData::mla_parse_xmp_metadata( $file_name, 0 );
|
845 |
-
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata recovered xmp = ' . var_export( $xmp, true ), 0 );
|
846 |
}
|
847 |
} // found Metadata reference
|
848 |
} // found Root object
|
849 |
} // found Root reference
|
850 |
} // found trailer_dictionaries
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
851 |
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata pdf = ' . var_export( $metadata, true ), 0 );
|
852 |
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata xmp = ' . var_export( $xmp, true ), 0 );
|
853 |
|
714 |
* @return array ( 'xmp' => array( key => value ), 'pdf' => array( key => value ) ) for each metadata field, in string format
|
715 |
*/
|
716 |
public static function mla_extract_pdf_metadata( $file_name ) {
|
717 |
+
$xmp = NULL;
|
718 |
$metadata = array();
|
719 |
self::$pdf_indirect_objects = NULL;
|
720 |
$chunksize = 16384;
|
721 |
|
722 |
if ( ! file_exists( $file_name ) ) {
|
723 |
+
return array( 'xmp' => array(), 'pdf' => $metadata );
|
724 |
}
|
725 |
|
726 |
$filesize = filesize( $file_name );
|
740 |
$metadata['PDF_VersionNumber'] = substr( $header, 5, 3 );
|
741 |
}
|
742 |
|
743 |
+
// Find the xref and (optional) trailer
|
|
|
|
|
744 |
$match_count = preg_match_all( '/startxref[\x00-\x20]+(\d+)[\x00-\x20]+\%\%EOF/', $tail, $matches, PREG_OFFSET_CAPTURE );
|
745 |
if ( 0 == $match_count ) {
|
746 |
/* translators: 1: ERROR tag 2: path and file */
|
747 |
MLACore::mla_debug_add( sprintf( _x( '%1$s: File "%2$s", startxref not found.', 'error_log', 'media-library-assistant' ), __( 'ERROR', 'media-library-assistant' ), $path ), MLACore::MLA_DEBUG_CATEGORY_ANY );
|
748 |
+
return array( 'xmp' => array(), 'pdf' => $metadata );
|
749 |
}
|
750 |
|
751 |
$startxref = (integer) $matches[1][ $match_count - 1 ][0];
|
764 |
if ( isset( $info_reference ) ) {
|
765 |
$info_object = self::_find_pdf_indirect_dictionary( $file_name, $info_reference['object'], $info_reference['generation'] );
|
766 |
|
767 |
+
// Handle single or multiple Info instances
|
|
|
|
|
768 |
$info_objects = array();
|
769 |
if ( $info_object ) {
|
770 |
if ( 1 == $info_object['count'] ) {
|
798 |
} // each info entry
|
799 |
} // foreach Info object
|
800 |
|
801 |
+
// Remove spurious "Filter" dictionaries
|
|
|
|
|
802 |
unset( $metadata['Filter'] );
|
803 |
unset( $metadata['Length'] );
|
804 |
unset( $metadata['Length1'] );
|
805 |
} // found Info reference
|
806 |
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata pdf metadata = ' . var_export( $metadata, true ), 0 );
|
807 |
|
808 |
+
// Look for XMP Metadata
|
|
|
|
|
809 |
$root_reference = NULL;
|
810 |
//error_log( __LINE__ . " MLAPDF::mla_extract_pdf_metadata info_dictionary = " . var_export( $info_dictionary, true ), 0 );
|
811 |
+
//error_log( __LINE__ . " MLAPDF::mla_extract_pdf_metadata trailer_dictionaries = " . var_export( $trailer_dictionaries, true ), 0 );
|
812 |
foreach ( $trailer_dictionaries as $trailer_dictionary ) {
|
813 |
if ( isset( $trailer_dictionary['Root'] ) ) {
|
814 |
$root_reference = $trailer_dictionary['Root'];
|
827 |
|
828 |
if ( isset( $root_dictionary['Metadata'] ) ) {
|
829 |
$xmp_object = self::_find_pdf_indirect_dictionary( $file_name, $root_dictionary['Metadata']['object'], $root_dictionary['Metadata']['generation'] );
|
830 |
+
//error_log( __LINE__ . " MLAPDF::mla_extract_pdf_metadata( {$file_name} ) root_dictionary = " . var_export( $root_dictionary, true ), 0 );
|
831 |
+
//error_log( __LINE__ . " MLAPDF::mla_extract_pdf_metadata( {$file_name} ) xmp_object = " . var_export( $xmp_object, true ), 0 );
|
832 |
$xmp = MLAData::mla_parse_xmp_metadata( $file_name, $xmp_object['start'] + $xmp_object['length'] );
|
|
|
833 |
if ( is_array( $xmp ) ) {
|
834 |
$metadata = array_merge( $metadata, $xmp );
|
|
|
|
|
|
|
|
|
835 |
}
|
836 |
} // found Metadata reference
|
837 |
} // found Root object
|
838 |
} // found Root reference
|
839 |
} // found trailer_dictionaries
|
840 |
+
|
841 |
+
// Last try for XML recovery
|
842 |
+
if ( is_null( $xmp ) ) {
|
843 |
+
$xmp = MLAData::mla_parse_xmp_metadata( $file_name, 0 );
|
844 |
+
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata recovered xmp = ' . var_export( $xmp, true ), 0 );
|
845 |
+
|
846 |
+
if ( is_array( $xmp ) ) {
|
847 |
+
// Add scalar values to pdf: array to populate as many D.I.D. entries as possible
|
848 |
+
foreach ( $xmp as $key => $value ) {
|
849 |
+
if ( is_scalar( $value ) ) {
|
850 |
+
$metadata[ $key ] = $value;
|
851 |
+
}
|
852 |
+
}
|
853 |
+
} else {
|
854 |
+
$xmp = array();
|
855 |
+
}
|
856 |
+
}
|
857 |
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata pdf = ' . var_export( $metadata, true ), 0 );
|
858 |
//error_log( __LINE__ . ' MLAPDF::mla_extract_pdf_metadata xmp = ' . var_export( $xmp, true ), 0 );
|
859 |
|
includes/class-mla-data-query.php
CHANGED
@@ -897,7 +897,7 @@ class MLAQuery {
|
|
897 |
break;
|
898 |
case 'orderby':
|
899 |
// 'rml' is for Real Media Library compatibility
|
900 |
-
if ( in_array( $value, array( 'none', 'post__in', 'rml' ) ) ) {
|
901 |
$clean_request[ $key ] = $value;
|
902 |
} else {
|
903 |
$orderby = NULL;
|
@@ -2134,6 +2134,9 @@ class MLAQuery {
|
|
2134 |
// post__in is passed from Media Manager Modal Window
|
2135 |
case 'post__in':
|
2136 |
return $orderby_clause;
|
|
|
|
|
|
|
2137 |
/*
|
2138 |
* There are two columns defined that end up sorting on post_title,
|
2139 |
* so we can't use the database column to identify the column but
|
897 |
break;
|
898 |
case 'orderby':
|
899 |
// 'rml' is for Real Media Library compatibility
|
900 |
+
if ( in_array( $value, array( 'none', 'post__in', 'menu_order ID', 'rml' ) ) ) {
|
901 |
$clean_request[ $key ] = $value;
|
902 |
} else {
|
903 |
$orderby = NULL;
|
2134 |
// post__in is passed from Media Manager Modal Window
|
2135 |
case 'post__in':
|
2136 |
return $orderby_clause;
|
2137 |
+
// menu_order ID is passed from Media Manager Modal Window
|
2138 |
+
case 'menu_order ID':
|
2139 |
+
return "{$wpdb->posts}.menu_order,{$wpdb->posts}.ID";
|
2140 |
/*
|
2141 |
* There are two columns defined that end up sorting on post_title,
|
2142 |
* so we can't use the database column to identify the column but
|
includes/class-mla-data-source.php
CHANGED
@@ -206,6 +206,7 @@ class MLAData_Source {
|
|
206 |
'height' => '',
|
207 |
'orientation' => '',
|
208 |
'hwstring_small' => '',
|
|
|
209 |
'sizes' => array()
|
210 |
);
|
211 |
|
@@ -227,6 +228,10 @@ class MLAData_Source {
|
|
227 |
$results[ $key ] = $value;
|
228 |
}
|
229 |
|
|
|
|
|
|
|
|
|
230 |
$sizes = isset( $attachment_metadata['sizes'] ) ? $attachment_metadata['sizes'] : array();
|
231 |
|
232 |
if ( isset( $attachment_metadata['width'] ) ) {
|
@@ -250,24 +255,32 @@ class MLAData_Source {
|
|
250 |
$results['hwstring_small'] = isset( $attachment_metadata['hwstring_small'] ) ? $attachment_metadata['hwstring_small'] : '';
|
251 |
}
|
252 |
|
|
|
253 |
if ( ! empty( $base_file ) ) {
|
254 |
$pathinfo = pathinfo( $base_file );
|
255 |
$results['base_file'] = $base_file;
|
256 |
if ( '.' == $pathinfo['dirname'] ) {
|
257 |
$results['absolute_path_raw'] = $upload_dir;
|
258 |
-
$results['absolute_path'] = wptexturize( str_replace( '\\', '/', $upload_dir ) );
|
|
|
259 |
$results['path'] = '';
|
260 |
} else {
|
261 |
$results['absolute_path_raw'] = $upload_dir . $pathinfo['dirname'] . '/';
|
262 |
-
$results['absolute_path'] = wptexturize( str_replace( '\\', '/', $results['absolute_path_raw'] ) );
|
263 |
-
$results['
|
|
|
|
|
264 |
}
|
265 |
|
266 |
$results['absolute_file_name_raw'] = $results['absolute_path_raw'] . $pathinfo['basename'];
|
267 |
-
$results['absolute_file_name'] = wptexturize( str_replace( '\\', '/', $results['absolute_file_name_raw'] ) );
|
268 |
-
$results['
|
269 |
-
$results['
|
270 |
-
$results['
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
|
273 |
$results['sizes'] = $sizes;
|
@@ -625,6 +638,11 @@ class MLAData_Source {
|
|
625 |
}
|
626 |
break;
|
627 |
case 'file_size':
|
|
|
|
|
|
|
|
|
|
|
628 |
$filesize = @ filesize( $file_info['absolute_file_name_raw'] );
|
629 |
if ( ! (false === $filesize ) ) {
|
630 |
$result = $filesize;
|
@@ -664,7 +682,12 @@ class MLAData_Source {
|
|
664 |
case 'size_bytes':
|
665 |
$result = array();
|
666 |
foreach ( $file_info['sizes'] as $key => $value ) {
|
667 |
-
|
|
|
|
|
|
|
|
|
|
|
668 |
if ( false === $filesize ) {
|
669 |
$result[] = '?';
|
670 |
} else {
|
@@ -714,7 +737,12 @@ class MLAData_Source {
|
|
714 |
$result = $size_info['file'];
|
715 |
break;
|
716 |
case 'size_bytes[size]':
|
717 |
-
|
|
|
|
|
|
|
|
|
|
|
718 |
if ( false === $result ) {
|
719 |
$result = '?';
|
720 |
}
|
206 |
'height' => '',
|
207 |
'orientation' => '',
|
208 |
'hwstring_small' => '',
|
209 |
+
'filesize' => '',
|
210 |
'sizes' => array()
|
211 |
);
|
212 |
|
228 |
$results[ $key ] = $value;
|
229 |
}
|
230 |
|
231 |
+
if ( isset( $attachment_metadata['filesize'] ) ) {
|
232 |
+
$results['filesize'] = $attachment_metadata['filesize'];
|
233 |
+
}
|
234 |
+
|
235 |
$sizes = isset( $attachment_metadata['sizes'] ) ? $attachment_metadata['sizes'] : array();
|
236 |
|
237 |
if ( isset( $attachment_metadata['width'] ) ) {
|
255 |
$results['hwstring_small'] = isset( $attachment_metadata['hwstring_small'] ) ? $attachment_metadata['hwstring_small'] : '';
|
256 |
}
|
257 |
|
258 |
+
// Removed wptexturize() in MLA 3.00
|
259 |
if ( ! empty( $base_file ) ) {
|
260 |
$pathinfo = pathinfo( $base_file );
|
261 |
$results['base_file'] = $base_file;
|
262 |
if ( '.' == $pathinfo['dirname'] ) {
|
263 |
$results['absolute_path_raw'] = $upload_dir;
|
264 |
+
// $results['absolute_path'] = wptexturize( str_replace( '\\', '/', $upload_dir ) );
|
265 |
+
$results['absolute_path'] = str_replace( '\\', '/', $upload_dir );
|
266 |
$results['path'] = '';
|
267 |
} else {
|
268 |
$results['absolute_path_raw'] = $upload_dir . $pathinfo['dirname'] . '/';
|
269 |
+
// $results['absolute_path'] = wptexturize( str_replace( '\\', '/', $results['absolute_path_raw'] ) );
|
270 |
+
$results['absolute_path'] = str_replace( '\\', '/', $results['absolute_path_raw'] );
|
271 |
+
// $results['path'] = wptexturize( $pathinfo['dirname'] . '/' );
|
272 |
+
$results['path'] = $pathinfo['dirname'] . '/';
|
273 |
}
|
274 |
|
275 |
$results['absolute_file_name_raw'] = $results['absolute_path_raw'] . $pathinfo['basename'];
|
276 |
+
// $results['absolute_file_name'] = wptexturize( str_replace( '\\', '/', $results['absolute_file_name_raw'] ) );
|
277 |
+
$results['absolute_file_name'] = str_replace( '\\', '/', $results['absolute_file_name_raw'] );
|
278 |
+
// $results['file_name'] = wptexturize( $pathinfo['basename'] );
|
279 |
+
$results['file_name'] = $pathinfo['basename'];
|
280 |
+
// $results['name_only'] = wptexturize( $pathinfo['filename'] );
|
281 |
+
$results['name_only'] = $pathinfo['filename'];
|
282 |
+
// $results['extension'] = wptexturize( $pathinfo['extension'] );
|
283 |
+
$results['extension'] = $pathinfo['extension'];
|
284 |
}
|
285 |
|
286 |
$results['sizes'] = $sizes;
|
638 |
}
|
639 |
break;
|
640 |
case 'file_size':
|
641 |
+
if ( !empty( $file_info['filesize'] ) ) {
|
642 |
+
$result = $file_info['filesize'];
|
643 |
+
break;
|
644 |
+
}
|
645 |
+
|
646 |
$filesize = @ filesize( $file_info['absolute_file_name_raw'] );
|
647 |
if ( ! (false === $filesize ) ) {
|
648 |
$result = $filesize;
|
682 |
case 'size_bytes':
|
683 |
$result = array();
|
684 |
foreach ( $file_info['sizes'] as $key => $value ) {
|
685 |
+
if ( !empty( $value['filesize'] ) ) {
|
686 |
+
$filesize = $value['filesize'];
|
687 |
+
} else {
|
688 |
+
$filesize = @ filesize( $file_info['absolute_path_raw'] . $value['file'] );
|
689 |
+
}
|
690 |
+
|
691 |
if ( false === $filesize ) {
|
692 |
$result[] = '?';
|
693 |
} else {
|
737 |
$result = $size_info['file'];
|
738 |
break;
|
739 |
case 'size_bytes[size]':
|
740 |
+
if ( !empty( $size_info['filesize'] ) ) {
|
741 |
+
$result = $size_info['filesize'];
|
742 |
+
} else {
|
743 |
+
$result = @ filesize( $file_info['absolute_path_raw'] . $size_info['file'] );
|
744 |
+
}
|
745 |
+
|
746 |
if ( false === $result ) {
|
747 |
$result = '?';
|
748 |
}
|
includes/class-mla-data.php
CHANGED
@@ -1666,7 +1666,6 @@ class MLAData {
|
|
1666 |
*/
|
1667 |
public static function mla_get_template_placeholders( $tpl, $default_option = 'text' ) {
|
1668 |
$results = array();
|
1669 |
-
|
1670 |
/*
|
1671 |
* Look for and process templates, removing them from the input so substitution parameters within
|
1672 |
* the template are not expanded. They will be expanded when the template itself is expanded.
|
@@ -4727,7 +4726,7 @@ class MLAData {
|
|
4727 |
if ( class_exists( 'Meow_MFRH_Core', false ) && isset( $updates['post_title'] ) ) {
|
4728 |
global $mfrh_core;
|
4729 |
|
4730 |
-
if ( is_object( $
|
4731 |
$mfrh_core->rename( $post_id );
|
4732 |
}
|
4733 |
}
|
1666 |
*/
|
1667 |
public static function mla_get_template_placeholders( $tpl, $default_option = 'text' ) {
|
1668 |
$results = array();
|
|
|
1669 |
/*
|
1670 |
* Look for and process templates, removing them from the input so substitution parameters within
|
1671 |
* the template are not expanded. They will be expanded when the template itself is expanded.
|
4726 |
if ( class_exists( 'Meow_MFRH_Core', false ) && isset( $updates['post_title'] ) ) {
|
4727 |
global $mfrh_core;
|
4728 |
|
4729 |
+
if ( is_object( $mfrh_core ) ) {
|
4730 |
$mfrh_core->rename( $post_id );
|
4731 |
}
|
4732 |
}
|
includes/class-mla-edit-media.php
CHANGED
@@ -80,7 +80,7 @@ class MLAEdit {
|
|
80 |
*/
|
81 |
public static function mla_admin_init_action( ) {
|
82 |
$edit_media_support = array( 'custom-fields' );
|
83 |
-
if ( ( 'checked' == MLACore::mla_get_option(
|
84 |
$edit_media_support[] = 'thumbnail';
|
85 |
}
|
86 |
|
@@ -355,14 +355,18 @@ class MLAEdit {
|
|
355 |
}
|
356 |
|
357 |
/**
|
358 |
-
* Generates the bulk edit area
|
359 |
*
|
360 |
-
*
|
|
|
|
|
361 |
* Anything echoed here goes below the "Maximum upload file size" message
|
362 |
* and above the id="media-items" div.
|
363 |
*
|
364 |
* @param array $fieldset_values Initial taxonomy terms and field values
|
365 |
-
* @param string $filter_root Root portion of
|
|
|
|
|
366 |
*
|
367 |
* @since 2.99
|
368 |
*
|
@@ -375,6 +379,8 @@ class MLAEdit {
|
|
375 |
return $message;
|
376 |
}
|
377 |
|
|
|
|
|
378 |
// Initialize blank/default fieldset values
|
379 |
$page_values = array(
|
380 |
'filter_root' => $filter_root,
|
@@ -1437,10 +1443,10 @@ class MLAEdit {
|
|
1437 |
*/
|
1438 |
public static function mla_file_metadata_handler( $post ) {
|
1439 |
$value = MLAData::mla_compose_attachment_metadata( $post->ID );
|
|
|
1440 |
|
1441 |
-
|
1442 |
-
|
1443 |
-
$html = '<label class="screen-reader-text" for="mla_file_metadata">' . __( 'Attachment File Metadata', 'media-library-assistant' ) . '</label><textarea class="readonly" id="mla_file_metadata" rows="' . absint( $value['rows'] ) . '" cols="' . absint( $value['cols'] ) . '" readonly="readonly" name="mla_file_metadata" >' . esc_textarea( $value['value'] ) . "</textarea>\n";
|
1444 |
echo apply_filters( 'mla_file_metadata_meta_box_html', $html, $value, $post ); // phpcs:ignore
|
1445 |
}
|
1446 |
|
80 |
*/
|
81 |
public static function mla_admin_init_action( ) {
|
82 |
$edit_media_support = array( 'custom-fields' );
|
83 |
+
if ( ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ENABLE_FEATURED_IMAGE ) ) && current_theme_supports( 'post-thumbnails', 'attachment' ) ) {
|
84 |
$edit_media_support[] = 'thumbnail';
|
85 |
}
|
86 |
|
355 |
}
|
356 |
|
357 |
/**
|
358 |
+
* Generates the bulk edit area fieldsets HTML for the Media/Assistant and Media/Add New screens
|
359 |
*
|
360 |
+
* For Media/Assistant, fires in the _build_inline_edit_form function that generates the Bulk Edit Area.
|
361 |
+
|
362 |
+
* For Media/Add New, fires on the post upload UI screen; legacy (pre-3.5.0) upload interface.
|
363 |
* Anything echoed here goes below the "Maximum upload file size" message
|
364 |
* and above the id="media-items" div.
|
365 |
*
|
366 |
* @param array $fieldset_values Initial taxonomy terms and field values
|
367 |
+
* @param string $filter_root Root portion of '_fieldset_values', '_values' and '_template' filter names:
|
368 |
+
* 'mla_upload_bulk_edit_form_blank', 'mla_upload_bulk_edit_form_initial', 'mla_upload_bulk_edit_form_preset',
|
369 |
+
* 'mla_list_table_inline_blank', 'mla_list_table_inline_initial', 'mla_list_table_inline_preset',
|
370 |
*
|
371 |
* @since 2.99
|
372 |
*
|
379 |
return $message;
|
380 |
}
|
381 |
|
382 |
+
$fieldset_values = apply_filters( $filter_root . '_fieldset_values', $fieldset_values, $filter_root );
|
383 |
+
|
384 |
// Initialize blank/default fieldset values
|
385 |
$page_values = array(
|
386 |
'filter_root' => $filter_root,
|
1443 |
*/
|
1444 |
public static function mla_file_metadata_handler( $post ) {
|
1445 |
$value = MLAData::mla_compose_attachment_metadata( $post->ID );
|
1446 |
+
$value = apply_filters( 'mla_file_metadata_meta_box', array( 'value' => $value, 'rows' => 5, 'cols' => 80, 'flags' => ENT_SUBSTITUTE ), $post );
|
1447 |
|
1448 |
+
// Can't use esc_textarea( $value['value'] ) because the value might contain invalid code unit sequences
|
1449 |
+
$html = '<label class="screen-reader-text" for="mla_file_metadata">' . __( 'Attachment File Metadata', 'media-library-assistant' ) . '</label><textarea class="readonly" id="mla_file_metadata" rows="' . absint( $value['rows'] ) . '" cols="' . absint( $value['cols'] ) . '" readonly="readonly" name="mla_file_metadata" >' . htmlspecialchars( $value['value'], $value['flags'] ) . "</textarea>\n";
|
|
|
1450 |
echo apply_filters( 'mla_file_metadata_meta_box_html', $html, $value, $post ); // phpcs:ignore
|
1451 |
}
|
1452 |
|
includes/class-mla-file-downloader.php
CHANGED
@@ -6,6 +6,8 @@
|
|
6 |
* @since 2.32
|
7 |
*/
|
8 |
|
|
|
|
|
9 |
/**
|
10 |
* Class MLA (Media Library Assistant) File Downloader provides file streaming to client.
|
11 |
*
|
6 |
* @since 2.32
|
7 |
*/
|
8 |
|
9 |
+
defined( 'ABSPATH' ) or die();
|
10 |
+
|
11 |
/**
|
12 |
* Class MLA (Media Library Assistant) File Downloader provides file streaming to client.
|
13 |
*
|
includes/class-mla-list-table.php
CHANGED
@@ -837,7 +837,7 @@ class MLA_List_Table extends WP_List_Table {
|
|
837 |
$file = get_attached_file( $item->ID );
|
838 |
$download_args = array( 'page' => MLACore::ADMIN_PAGE_SLUG, 'mla_download_file' => urlencode( $file ), 'mla_download_type' => $item->post_mime_type );
|
839 |
|
840 |
-
$actions['download'] = '<a href="' . add_query_arg( $download_args, MLACore::mla_nonce_url( 'upload.php', MLACore::
|
841 |
|
842 |
$actions['view'] = '<a href="' . site_url( ) . '?attachment_id=' . $item->ID . '" rel="permalink" title="' . __( 'View', 'media-library-assistant' ) . ' “' . $att_title . '”">' . __( 'View', 'media-library-assistant' ) . '</a>';
|
843 |
}
|
@@ -1466,11 +1466,11 @@ class MLA_List_Table extends WP_List_Table {
|
|
1466 |
* @return string HTML markup to be placed inside the column
|
1467 |
*/
|
1468 |
function column_post_mime_type( $item ) {
|
1469 |
-
return sprintf( '<a href="%1$s" title="' . __( 'Filter by', 'media-library-assistant' ) . ' “%2$s”">%2$s</a>', esc_url( add_query_arg( array_merge( array(
|
1470 |
'page' => MLACore::ADMIN_PAGE_SLUG,
|
1471 |
'post_mime_type' => urlencode( $item->post_mime_type ),
|
1472 |
'heading_suffix' => urlencode( __( 'MIME Type', 'media-library-assistant' ) . ': ' . $item->post_mime_type )
|
1473 |
-
)
|
1474 |
}
|
1475 |
|
1476 |
/**
|
837 |
$file = get_attached_file( $item->ID );
|
838 |
$download_args = array( 'page' => MLACore::ADMIN_PAGE_SLUG, 'mla_download_file' => urlencode( $file ), 'mla_download_type' => $item->post_mime_type );
|
839 |
|
840 |
+
$actions['download'] = '<a href="' . add_query_arg( $download_args, MLACore::mla_nonce_url( 'upload.php', MLACore::MLA_DOWNLOAD_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ) . '" title="' . __( 'Download', 'media-library-assistant' ) . ' “' . $att_title . '”">' . __( 'Download', 'media-library-assistant' ) . '</a>';
|
841 |
|
842 |
$actions['view'] = '<a href="' . site_url( ) . '?attachment_id=' . $item->ID . '" rel="permalink" title="' . __( 'View', 'media-library-assistant' ) . ' “' . $att_title . '”">' . __( 'View', 'media-library-assistant' ) . '</a>';
|
843 |
}
|
1466 |
* @return string HTML markup to be placed inside the column
|
1467 |
*/
|
1468 |
function column_post_mime_type( $item ) {
|
1469 |
+
return sprintf( '<a href="%1$s" title="' . __( 'Filter by', 'media-library-assistant' ) . ' “%2$s”">%2$s</a>', esc_url( add_query_arg( array_merge( self::mla_submenu_arguments( false ), array(
|
1470 |
'page' => MLACore::ADMIN_PAGE_SLUG,
|
1471 |
'post_mime_type' => urlencode( $item->post_mime_type ),
|
1472 |
'heading_suffix' => urlencode( __( 'MIME Type', 'media-library-assistant' ) . ': ' . $item->post_mime_type )
|
1473 |
+
) ), 'upload.php' ) ), esc_html( $item->post_mime_type ), esc_html( $item->post_mime_type ) );
|
1474 |
}
|
1475 |
|
1476 |
/**
|
includes/class-mla-main.php
CHANGED
@@ -141,14 +141,14 @@ class MLA {
|
|
141 |
|
142 |
// Process secure file download requests
|
143 |
if ( isset( $_REQUEST['mla_download_file'] ) && isset( $_REQUEST['mla_download_type'] ) ) {
|
144 |
-
check_admin_referer( MLACore::
|
145 |
self::_process_mla_download_file( $_REQUEST, true );
|
146 |
exit();
|
147 |
}
|
148 |
|
149 |
// Process example plugin download requests from the Documentation tab
|
150 |
if ( isset( $_REQUEST['mla_download_example_plugin'] ) ) {
|
151 |
-
check_admin_referer( MLACore::
|
152 |
|
153 |
$request = array (
|
154 |
'mla_download_file' => str_replace( '\\', '/', MLA_PLUGIN_PATH . 'examples/plugins/' . sanitize_text_field( wp_unslash( $_REQUEST['mla_download_example_plugin'] ) ) ),
|
@@ -161,7 +161,7 @@ class MLA {
|
|
161 |
|
162 |
// Process error log download requests from the Debug tab
|
163 |
if ( isset( $_REQUEST['mla_download_error_log'] ) ) {
|
164 |
-
check_admin_referer( MLACore::
|
165 |
|
166 |
// Find the appropriate error log file
|
167 |
$error_log_name = MLACore::mla_get_option( MLACoreOptions::MLA_DEBUG_FILE );
|
@@ -195,7 +195,8 @@ class MLA {
|
|
195 |
$bulk_action = 'download-zip';
|
196 |
}
|
197 |
|
198 |
-
if ( 'download-zip'
|
|
|
199 |
// Exits after redirect unless it returns an error
|
200 |
$_REQUEST['mla_zip_archive_error_message'] = self::_process_zip_archive_download( $_REQUEST );
|
201 |
MLACore::mla_debug_add( __LINE__ . " MLA::_process_zip_archive_download message = " . var_export( $_REQUEST['mla_zip_archive_error_message'], true ), MLACore::MLA_DEBUG_CATEGORY_ANY ); // phpcs:ignore
|
@@ -896,6 +897,11 @@ class MLA {
|
|
896 |
return __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'no ZipArchive support.', 'media-library-assistant' );
|
897 |
}
|
898 |
|
|
|
|
|
|
|
|
|
|
|
899 |
// Create unique local names in case the same file name appears in multiple year/month/ directories.
|
900 |
$file_names = array();
|
901 |
foreach ( $request['cb_attachment'] as $index => $post_id ) {
|
@@ -915,7 +921,7 @@ class MLA {
|
|
915 |
$upload_dir = wp_upload_dir();
|
916 |
$prefix = ( defined( MLA_OPTION_PREFIX ) ) ? MLA_OPTION_PREFIX : 'mla_';
|
917 |
$date = date("Ymd_B");
|
918 |
-
$archive_name = $upload_dir['basedir'] . '/' . "{$prefix}
|
919 |
|
920 |
// Clean up an obsolete file
|
921 |
if ( file_exists( $archive_name ) ) {
|
@@ -948,7 +954,7 @@ class MLA {
|
|
948 |
|
949 |
$download_args = array( 'page' => MLACore::ADMIN_PAGE_SLUG, 'mla_download_file' => urlencode( $archive_name ), 'mla_download_type' => 'application/zip', 'mla_download_disposition' => 'delete' );
|
950 |
|
951 |
-
wp_redirect( add_query_arg( $download_args, wp_nonce_url( 'upload.php', MLACore::
|
952 |
exit;
|
953 |
}
|
954 |
|
@@ -979,7 +985,7 @@ class MLA {
|
|
979 |
if ( ' ' == $new_value ) {
|
980 |
$new_value = '';
|
981 |
}
|
982 |
-
} elseif (
|
983 |
// preserve leading/trailing whitespace on non-empty entered values
|
984 |
return $bulk_value;
|
985 |
}
|
@@ -1006,7 +1012,7 @@ class MLA {
|
|
1006 |
$new_data = array() ;
|
1007 |
if ( isset( $request['post_title'] ) ) {
|
1008 |
$test_value = self::_process_bulk_value( $post_id, $request['post_title'] );
|
1009 |
-
if (
|
1010 |
$new_data['post_title'] = $test_value;
|
1011 |
} elseif ( is_null( $test_value ) ) {
|
1012 |
$new_data['post_title'] = '';
|
@@ -1015,7 +1021,7 @@ class MLA {
|
|
1015 |
|
1016 |
if ( isset( $request['post_excerpt'] ) ) {
|
1017 |
$test_value = self::_process_bulk_value( $post_id, $request['post_excerpt'] );
|
1018 |
-
if (
|
1019 |
$new_data['post_excerpt'] = $test_value;
|
1020 |
} elseif ( is_null( $test_value ) ) {
|
1021 |
$new_data['post_excerpt'] = '';
|
@@ -1024,7 +1030,7 @@ class MLA {
|
|
1024 |
|
1025 |
if ( isset( $request['post_content'] ) ) {
|
1026 |
$test_value = self::_process_bulk_value( $post_id, $request['post_content'] );
|
1027 |
-
if (
|
1028 |
$new_data['post_content'] = $test_value;
|
1029 |
} elseif ( is_null( $test_value ) ) {
|
1030 |
$new_data['post_content'] = '';
|
@@ -1038,7 +1044,7 @@ class MLA {
|
|
1038 |
*/
|
1039 |
if ( isset( $request['image_alt'] ) ) {
|
1040 |
$test_value = self::_process_bulk_value( $post_id, $request['image_alt'] );
|
1041 |
-
if (
|
1042 |
$new_data['bulk_image_alt'] = $test_value;
|
1043 |
} elseif ( is_null( $test_value ) ) {
|
1044 |
$new_data['bulk_image_alt'] = '';
|
@@ -1047,7 +1053,7 @@ class MLA {
|
|
1047 |
|
1048 |
if ( isset( $request['post_date'] ) ) {
|
1049 |
$test_value = self::_process_bulk_value( $post_id, $request['post_date'] );
|
1050 |
-
if (
|
1051 |
// User input is in local time, not UTC
|
1052 |
$tz = get_option( 'timezone_string' );
|
1053 |
if ( !$tz ) {
|
@@ -1108,7 +1114,7 @@ class MLA {
|
|
1108 |
foreach ( $custom_field_map as $slug => $details ) {
|
1109 |
if ( isset( $request[ $slug ] ) ) {
|
1110 |
$test_value = self::_process_bulk_value( $post_id, $request[ $slug ] );
|
1111 |
-
if (
|
1112 |
$custom_fields[ $details['name'] ] = $test_value;
|
1113 |
} elseif ( is_null( $test_value ) ) {
|
1114 |
if ( $details['no_null'] ) {
|
@@ -1278,6 +1284,11 @@ class MLA {
|
|
1278 |
* It is passed in the $request so it can be filtered.
|
1279 |
*/
|
1280 |
if ( NULL == $request ) {
|
|
|
|
|
|
|
|
|
|
|
1281 |
$request = $_REQUEST;
|
1282 |
$request['mla_bulk_action_do_cleanup'] = true;
|
1283 |
} else {
|
@@ -1285,7 +1296,7 @@ class MLA {
|
|
1285 |
}
|
1286 |
|
1287 |
$request = apply_filters( 'mla_list_table_bulk_action_initial_request', $request, $bulk_action, $custom_field_map );
|
1288 |
-
MLACore::mla_debug_add( __LINE__ . " MLA::mla_process_bulk_action request = " . var_export( $request, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX );
|
1289 |
|
1290 |
if ( isset( $request['cb_attachment'] ) ) {
|
1291 |
if ( !empty( $request['cb_offset'] ) ) {
|
141 |
|
142 |
// Process secure file download requests
|
143 |
if ( isset( $_REQUEST['mla_download_file'] ) && isset( $_REQUEST['mla_download_type'] ) ) {
|
144 |
+
check_admin_referer( MLACore::MLA_DOWNLOAD_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME );
|
145 |
self::_process_mla_download_file( $_REQUEST, true );
|
146 |
exit();
|
147 |
}
|
148 |
|
149 |
// Process example plugin download requests from the Documentation tab
|
150 |
if ( isset( $_REQUEST['mla_download_example_plugin'] ) ) {
|
151 |
+
check_admin_referer( MLACore::MLA_DOWNLOAD_EXAMPLE_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME );
|
152 |
|
153 |
$request = array (
|
154 |
'mla_download_file' => str_replace( '\\', '/', MLA_PLUGIN_PATH . 'examples/plugins/' . sanitize_text_field( wp_unslash( $_REQUEST['mla_download_example_plugin'] ) ) ),
|
161 |
|
162 |
// Process error log download requests from the Debug tab
|
163 |
if ( isset( $_REQUEST['mla_download_error_log'] ) ) {
|
164 |
+
check_admin_referer( MLACore::MLA_ERROR_LOG_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME );
|
165 |
|
166 |
// Find the appropriate error log file
|
167 |
$error_log_name = MLACore::mla_get_option( MLACoreOptions::MLA_DEBUG_FILE );
|
195 |
$bulk_action = 'download-zip';
|
196 |
}
|
197 |
|
198 |
+
if ( 'download-zip' === $bulk_action ) {
|
199 |
+
check_admin_referer( 'bulk-attachments' );
|
200 |
// Exits after redirect unless it returns an error
|
201 |
$_REQUEST['mla_zip_archive_error_message'] = self::_process_zip_archive_download( $_REQUEST );
|
202 |
MLACore::mla_debug_add( __LINE__ . " MLA::_process_zip_archive_download message = " . var_export( $_REQUEST['mla_zip_archive_error_message'], true ), MLACore::MLA_DEBUG_CATEGORY_ANY ); // phpcs:ignore
|
897 |
return __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'no ZipArchive support.', 'media-library-assistant' );
|
898 |
}
|
899 |
|
900 |
+
// Make sure we have attachments to process
|
901 |
+
if ( empty( $request['cb_attachment'] ) ) {
|
902 |
+
return __( 'ERROR', 'media-library-assistant' ) . ': ' . __( 'Could not retrieve Attachment.', 'media-library-assistant' );
|
903 |
+
}
|
904 |
+
|
905 |
// Create unique local names in case the same file name appears in multiple year/month/ directories.
|
906 |
$file_names = array();
|
907 |
foreach ( $request['cb_attachment'] as $index => $post_id ) {
|
921 |
$upload_dir = wp_upload_dir();
|
922 |
$prefix = ( defined( MLA_OPTION_PREFIX ) ) ? MLA_OPTION_PREFIX : 'mla_';
|
923 |
$date = date("Ymd_B");
|
924 |
+
$archive_name = $upload_dir['basedir'] . '/' . "{$prefix}attachments_{$date}.zip";
|
925 |
|
926 |
// Clean up an obsolete file
|
927 |
if ( file_exists( $archive_name ) ) {
|
954 |
|
955 |
$download_args = array( 'page' => MLACore::ADMIN_PAGE_SLUG, 'mla_download_file' => urlencode( $archive_name ), 'mla_download_type' => 'application/zip', 'mla_download_disposition' => 'delete' );
|
956 |
|
957 |
+
wp_redirect( add_query_arg( $download_args, wp_nonce_url( 'upload.php', MLACore::MLA_DOWNLOAD_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ), 302 );
|
958 |
exit;
|
959 |
}
|
960 |
|
985 |
if ( ' ' == $new_value ) {
|
986 |
$new_value = '';
|
987 |
}
|
988 |
+
} elseif ( strlen( $new_value ) ) {
|
989 |
// preserve leading/trailing whitespace on non-empty entered values
|
990 |
return $bulk_value;
|
991 |
}
|
1012 |
$new_data = array() ;
|
1013 |
if ( isset( $request['post_title'] ) ) {
|
1014 |
$test_value = self::_process_bulk_value( $post_id, $request['post_title'] );
|
1015 |
+
if ( strlen( $test_value ) ) {
|
1016 |
$new_data['post_title'] = $test_value;
|
1017 |
} elseif ( is_null( $test_value ) ) {
|
1018 |
$new_data['post_title'] = '';
|
1021 |
|
1022 |
if ( isset( $request['post_excerpt'] ) ) {
|
1023 |
$test_value = self::_process_bulk_value( $post_id, $request['post_excerpt'] );
|
1024 |
+
if ( strlen( $test_value ) ) {
|
1025 |
$new_data['post_excerpt'] = $test_value;
|
1026 |
} elseif ( is_null( $test_value ) ) {
|
1027 |
$new_data['post_excerpt'] = '';
|
1030 |
|
1031 |
if ( isset( $request['post_content'] ) ) {
|
1032 |
$test_value = self::_process_bulk_value( $post_id, $request['post_content'] );
|
1033 |
+
if ( strlen( $test_value ) ) {
|
1034 |
$new_data['post_content'] = $test_value;
|
1035 |
} elseif ( is_null( $test_value ) ) {
|
1036 |
$new_data['post_content'] = '';
|
1044 |
*/
|
1045 |
if ( isset( $request['image_alt'] ) ) {
|
1046 |
$test_value = self::_process_bulk_value( $post_id, $request['image_alt'] );
|
1047 |
+
if ( strlen( $test_value ) ) {
|
1048 |
$new_data['bulk_image_alt'] = $test_value;
|
1049 |
} elseif ( is_null( $test_value ) ) {
|
1050 |
$new_data['bulk_image_alt'] = '';
|
1053 |
|
1054 |
if ( isset( $request['post_date'] ) ) {
|
1055 |
$test_value = self::_process_bulk_value( $post_id, $request['post_date'] );
|
1056 |
+
if ( strlen( $test_value ) ) {
|
1057 |
// User input is in local time, not UTC
|
1058 |
$tz = get_option( 'timezone_string' );
|
1059 |
if ( !$tz ) {
|
1114 |
foreach ( $custom_field_map as $slug => $details ) {
|
1115 |
if ( isset( $request[ $slug ] ) ) {
|
1116 |
$test_value = self::_process_bulk_value( $post_id, $request[ $slug ] );
|
1117 |
+
if ( strlen( $test_value ) ) {
|
1118 |
$custom_fields[ $details['name'] ] = $test_value;
|
1119 |
} elseif ( is_null( $test_value ) ) {
|
1120 |
if ( $details['no_null'] ) {
|
1284 |
* It is passed in the $request so it can be filtered.
|
1285 |
*/
|
1286 |
if ( NULL == $request ) {
|
1287 |
+
// Bulk Edit actions have their own NONCE check
|
1288 |
+
if ( isset( $_REQUEST['_wpnonce'] ) ) {
|
1289 |
+
check_admin_referer( 'bulk-attachments' );
|
1290 |
+
}
|
1291 |
+
|
1292 |
$request = $_REQUEST;
|
1293 |
$request['mla_bulk_action_do_cleanup'] = true;
|
1294 |
} else {
|
1296 |
}
|
1297 |
|
1298 |
$request = apply_filters( 'mla_list_table_bulk_action_initial_request', $request, $bulk_action, $custom_field_map );
|
1299 |
+
MLACore::mla_debug_add( __LINE__ . " MLA::mla_process_bulk_action( {$bulk_action} ) request = " . var_export( $request, true ), MLACore::MLA_DEBUG_CATEGORY_AJAX );
|
1300 |
|
1301 |
if ( isset( $request['cb_attachment'] ) ) {
|
1302 |
if ( !empty( $request['cb_offset'] ) ) {
|
includes/class-mla-media-modal-ajax.php
CHANGED
@@ -766,6 +766,9 @@ class MLAModal_Ajax {
|
|
766 |
//error_log( __LINE__ . ' MLAModal_Ajax::mla_query_attachments_action() query = ' . var_export( $query, true ), 0 );
|
767 |
|
768 |
$attachments_query = MLAQuery::mla_query_media_modal_items( $query, $offset, $count );
|
|
|
|
|
|
|
769 |
$posts = array_map( 'wp_prepare_attachment_for_js', $attachments_query->posts );
|
770 |
$posts = array_filter( $posts );
|
771 |
$total_posts = $attachments_query->found_posts;
|
766 |
//error_log( __LINE__ . ' MLAModal_Ajax::mla_query_attachments_action() query = ' . var_export( $query, true ), 0 );
|
767 |
|
768 |
$attachments_query = MLAQuery::mla_query_media_modal_items( $query, $offset, $count );
|
769 |
+
|
770 |
+
do_action_ref_array( 'mla_media_modal_query_items', array( &$attachments_query, $query, $raw_query, $offset, $count ) );
|
771 |
+
|
772 |
$posts = array_map( 'wp_prepare_attachment_for_js', $attachments_query->posts );
|
773 |
$posts = array_filter( $posts );
|
774 |
$total_posts = $attachments_query->found_posts;
|
includes/class-mla-polylang-support.php
CHANGED
@@ -1696,7 +1696,7 @@ class MLA_Polylang {
|
|
1696 |
MLACore::mla_debug_add( __LINE__ . " MLA_Polylang::mla_list_table_inline_action( {$post_id} )", MLACore::MLA_DEBUG_CATEGORY_LANGUAGE );
|
1697 |
|
1698 |
self::_build_existing_terms( $post_id );
|
1699 |
-
if ( isset( $_REQUEST['action'] ) &&
|
1700 |
MLACore::mla_debug_add( __LINE__ . " MLA_Polylang::mla_list_table_inline_action( {$post_id} ) Quick Edit initial \$_REQUEST['tax_input'] = " . var_export( $_REQUEST['tax_input'], true ), MLACore::MLA_DEBUG_CATEGORY_AJAX ); // phpcs:ignore
|
1701 |
|
1702 |
if ( 'checked' == MLACore::mla_get_option( 'term_assignment', false, false, MLA_Polylang::$mla_language_option_definitions ) ) {
|
1696 |
MLACore::mla_debug_add( __LINE__ . " MLA_Polylang::mla_list_table_inline_action( {$post_id} )", MLACore::MLA_DEBUG_CATEGORY_LANGUAGE );
|
1697 |
|
1698 |
self::_build_existing_terms( $post_id );
|
1699 |
+
if ( isset( $_REQUEST['action'] ) && MLACore::JAVASCRIPT_INLINE_EDIT_SLUG === $_REQUEST['action'] && isset( $_REQUEST['tax_input'] ) ) {
|
1700 |
MLACore::mla_debug_add( __LINE__ . " MLA_Polylang::mla_list_table_inline_action( {$post_id} ) Quick Edit initial \$_REQUEST['tax_input'] = " . var_export( $_REQUEST['tax_input'], true ), MLACore::MLA_DEBUG_CATEGORY_AJAX ); // phpcs:ignore
|
1701 |
|
1702 |
if ( 'checked' == MLACore::mla_get_option( 'term_assignment', false, false, MLA_Polylang::$mla_language_option_definitions ) ) {
|
includes/class-mla-settings-documentation-tab.php
CHANGED
@@ -670,7 +670,7 @@ class MLA_Example_List_Table extends WP_List_Table {
|
|
670 |
'page' => MLACore::ADMIN_PAGE_SLUG,
|
671 |
'mla_download_example_plugin' => urlencode( $item->file ),
|
672 |
);
|
673 |
-
$actions['download'] = '<a href="' . add_query_arg( $args, MLACore::mla_nonce_url( 'upload.php', MLACore::
|
674 |
}
|
675 |
|
676 |
$actions['view'] = '<a href="' . add_query_arg( $view_args, MLACore::mla_nonce_url( '?mla_admin_action=' . MLACore::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ) . '" title="' . __( 'View this item', 'media-library-assistant' ) . '">' . __( 'View', 'media-library-assistant' ) . '</a>';
|
670 |
'page' => MLACore::ADMIN_PAGE_SLUG,
|
671 |
'mla_download_example_plugin' => urlencode( $item->file ),
|
672 |
);
|
673 |
+
$actions['download'] = '<a href="' . add_query_arg( $args, MLACore::mla_nonce_url( 'upload.php', MLACore::MLA_DOWNLOAD_EXAMPLE_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ) . '" title="' . __( 'Download', 'media-library-assistant' ) . ' “' . esc_attr( $item->file ) . '”">' . __( 'Download', 'media-library-assistant' ) . '</a>';
|
674 |
}
|
675 |
|
676 |
$actions['view'] = '<a href="' . add_query_arg( $view_args, MLACore::mla_nonce_url( '?mla_admin_action=' . MLACore::MLA_ADMIN_SINGLE_EDIT_DISPLAY, MLACore::MLA_ADMIN_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ) . '" title="' . __( 'View this item', 'media-library-assistant' ) . '">' . __( 'View', 'media-library-assistant' ) . '</a>';
|
includes/class-mla-settings.php
CHANGED
@@ -1290,6 +1290,7 @@ If you find the Media Library Assistant plugin useful and would like to support
|
|
1290 |
|
1291 |
// Check for other page-level actions
|
1292 |
if ( isset( $_REQUEST['mla_reset_log'] ) && 'true' == $_REQUEST['mla_reset_log'] ) {
|
|
|
1293 |
$file_error = false;
|
1294 |
$file_handle = @fopen( $error_log_name, 'w' );
|
1295 |
|
@@ -1378,7 +1379,7 @@ If you find the Media Library Assistant plugin useful and would like to support
|
|
1378 |
'page' => MLACore::ADMIN_PAGE_SLUG,
|
1379 |
'mla_download_error_log' => 'true',
|
1380 |
);
|
1381 |
-
$download_link = '<a class="button-secondary" href="' . add_query_arg( $args, MLACore::mla_nonce_url( 'upload.php', MLACore::
|
1382 |
} else {
|
1383 |
$download_link = '';
|
1384 |
}
|
@@ -1388,7 +1389,7 @@ If you find the Media Library Assistant plugin useful and would like to support
|
|
1388 |
'mla_tab' => 'debug',
|
1389 |
'mla_reset_log' => 'true'
|
1390 |
);
|
1391 |
-
$reset_link = '<a class="button-secondary" href="' . add_query_arg( $args, MLACore::mla_nonce_url( 'options-general.php', MLACore::
|
1392 |
}
|
1393 |
|
1394 |
$settings_list = self::_compose_settings_row( 'Display Limit', $display_limit );
|
1290 |
|
1291 |
// Check for other page-level actions
|
1292 |
if ( isset( $_REQUEST['mla_reset_log'] ) && 'true' == $_REQUEST['mla_reset_log'] ) {
|
1293 |
+
check_admin_referer( MLACore::MLA_ERROR_LOG_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME );
|
1294 |
$file_error = false;
|
1295 |
$file_handle = @fopen( $error_log_name, 'w' );
|
1296 |
|
1379 |
'page' => MLACore::ADMIN_PAGE_SLUG,
|
1380 |
'mla_download_error_log' => 'true',
|
1381 |
);
|
1382 |
+
$download_link = '<a class="button-secondary" href="' . add_query_arg( $args, MLACore::mla_nonce_url( 'upload.php', MLACore::MLA_ERROR_LOG_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ) . '" title="' . __( 'Download', 'media-library-assistant' ) . ' “' . __( 'Error Log', 'media-library-assistant' ) . '”">' . __( 'Download', 'media-library-assistant' ) . '</a>';
|
1383 |
} else {
|
1384 |
$download_link = '';
|
1385 |
}
|
1389 |
'mla_tab' => 'debug',
|
1390 |
'mla_reset_log' => 'true'
|
1391 |
);
|
1392 |
+
$reset_link = '<a class="button-secondary" href="' . add_query_arg( $args, MLACore::mla_nonce_url( 'options-general.php', MLACore::MLA_ERROR_LOG_NONCE_ACTION, MLACore::MLA_ADMIN_NONCE_NAME ) ) . '" title="' . __( 'Reset', 'media-library-assistant' ) . ' “' . __( 'Error Log', 'media-library-assistant' ) . '”">' . __( 'Reset', 'media-library-assistant' ) . '</a>';
|
1393 |
}
|
1394 |
|
1395 |
$settings_list = self::_compose_settings_row( 'Display Limit', $display_limit );
|
includes/class-mla-shortcode-support.php
CHANGED
@@ -162,6 +162,15 @@ class MLAShortcode_Support {
|
|
162 |
*/
|
163 |
private static $size_parameter = '';
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
/**
|
166 |
* Filters the image src result, returning the "Featured Image" or an icon to represent a non-image attachment.
|
167 |
*
|
@@ -187,13 +196,28 @@ class MLAShortcode_Support {
|
|
187 |
$image = false;
|
188 |
}
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
// If a native image exists, we're done
|
191 |
if ( false !== $image ) {
|
192 |
return $image;
|
193 |
}
|
194 |
|
195 |
// Look for the "Featured Image" as an alternate thumbnail for PDFs, etc.
|
196 |
-
if ( ( 'icon_only' !== self::$size_parameter ) && ( 'checked' == MLACore::mla_get_option(
|
197 |
$nested_call = true;
|
198 |
$feature = get_the_post_thumbnail( $attachment_id, $size, array( 'class' => 'attachment-thumbnail' ) );
|
199 |
$nested_call = false;
|
@@ -499,6 +523,7 @@ class MLAShortcode_Support {
|
|
499 |
'mla_rml_include_children' => false,
|
500 |
|
501 |
'mla_named_transfer' => false,
|
|
|
502 |
'mla_viewer' => false,
|
503 |
'mla_single_thread' => false,
|
504 |
'mla_viewer_extensions' => 'ai,eps,pdf,ps',
|
@@ -773,6 +798,9 @@ class MLAShortcode_Support {
|
|
773 |
$size = strtolower( $arguments['size'] );
|
774 |
self::$size_parameter = $size;
|
775 |
|
|
|
|
|
|
|
776 |
if ( ( 'icon_only' === $size ) || ( 'icon_feature' === $size ) ) {
|
777 |
$size = 'icon';
|
778 |
}
|
@@ -1395,7 +1423,7 @@ class MLAShortcode_Support {
|
|
1395 |
} else {
|
1396 |
$thumbnail_content = $attachment->post_title;
|
1397 |
|
1398 |
-
if ( ( 'none' !== $arguments['size'] ) && ( 'checked' == MLACore::mla_get_option(
|
1399 |
// Look for the "Featured Image" as an alternate thumbnail for PDFs, etc.
|
1400 |
$thumb = get_the_post_thumbnail( $attachment->ID, $size, array( 'class' => 'attachment-thumbnail' ) );
|
1401 |
$thumb = apply_filters( 'mla_gallery_featured_image', $thumb, $attachment, $size, $item_values );
|
@@ -1462,8 +1490,10 @@ class MLAShortcode_Support {
|
|
1462 |
}
|
1463 |
|
1464 |
if ( ! empty( $link_attributes ) ) {
|
1465 |
-
$item_values['pagelink'] =
|
1466 |
-
$item_values['filelink'] =
|
|
|
|
|
1467 |
}
|
1468 |
|
1469 |
/*
|
@@ -1683,7 +1713,7 @@ class MLAShortcode_Support {
|
|
1683 |
$item_values['thumbnail_url'] = '';
|
1684 |
|
1685 |
/* Replaced by logic in _get_attachment_image_src v2.90
|
1686 |
-
if ( ( 'none' !== $arguments['size'] ) && ( 'checked' == MLACore::mla_get_option(
|
1687 |
// Look for the "Featured Image" as an alternate thumbnail for PDFs, etc.
|
1688 |
$feature = get_the_post_thumbnail( $attachment->ID, $size, array( 'class' => 'attachment-thumbnail' ) );
|
1689 |
$feature = apply_filters( 'mla_gallery_featured_image', $feature, $attachment, $size, $item_values );
|
@@ -4527,15 +4557,19 @@ class MLAShortcode_Support {
|
|
4527 |
* @since 2.20
|
4528 |
*
|
4529 |
* @param array value(s) for mla_output_type parameter
|
4530 |
-
* @param
|
4531 |
-
* @param
|
4532 |
-
* @param
|
4533 |
* @param integer number of attachments in the gallery, without pagination
|
4534 |
* @param string output text so far, may include debug values
|
4535 |
*
|
4536 |
* @return mixed false or string with HTML for pagination output types
|
4537 |
*/
|
4538 |
private static function _process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $found_rows, $output = '' ) {
|
|
|
|
|
|
|
|
|
4539 |
if ( ! in_array( $output_parameters[0], array( 'previous_page', 'next_page', 'paginate_links' ) ) ) {
|
4540 |
return false;
|
4541 |
}
|
@@ -4556,6 +4590,7 @@ class MLAShortcode_Support {
|
|
4556 |
$arguments[ $mla_page_parameter ] = '';
|
4557 |
}
|
4558 |
}
|
|
|
4559 |
|
4560 |
if ( 0 == $posts_per_page ) {
|
4561 |
$posts_per_page = absint( $arguments['numberposts'] );
|
@@ -4651,8 +4686,8 @@ class MLAShortcode_Support {
|
|
4651 |
$markup_values['new_offset'] = 0;
|
4652 |
}
|
4653 |
|
4654 |
-
$markup_values['current_page_text'] = '
|
4655 |
-
$markup_values['new_page_text'] = '
|
4656 |
$markup_values['last_page_text'] = 'mla_paginate_total="[+last_page+]"';
|
4657 |
$markup_values['posts_per_page_text'] = 'posts_per_page="[+posts_per_page+]"';
|
4658 |
|
@@ -4674,6 +4709,10 @@ class MLAShortcode_Support {
|
|
4674 |
$uri_query = add_query_arg( array( $mla_page_parameter => $new_page ), $uri_query );
|
4675 |
}
|
4676 |
|
|
|
|
|
|
|
|
|
4677 |
// Validate the query arguments to prevent cross-site scripting (reflection) attacks
|
4678 |
$test_query = array();
|
4679 |
parse_str( strval( $uri_query ), $test_query );
|
@@ -4691,7 +4730,8 @@ class MLAShortcode_Support {
|
|
4691 |
$markup_values['query_string'] = $clean_query;
|
4692 |
|
4693 |
if ( !empty( $clean_query ) ) {
|
4694 |
-
$markup_values['request_uri'] = $uri_path . '?' . $clean_query;
|
|
|
4695 |
} else {
|
4696 |
$markup_values['request_uri'] = $uri_path;
|
4697 |
}
|
@@ -6906,7 +6946,7 @@ class MLAShortcode_Support {
|
|
6906 |
* The "ids" parameter can build an item-specific cloud.
|
6907 |
* Compile a list of all the terms assigned to the items.
|
6908 |
*/
|
6909 |
-
if ( ! empty( $arguments['ids'] )
|
6910 |
$ids = wp_parse_id_list( $arguments['ids'] );
|
6911 |
$placeholders = implode( "','", $ids );
|
6912 |
$clause[] = "AND tr.object_id IN ( '{$placeholders}' )";
|
@@ -6923,6 +6963,11 @@ class MLAShortcode_Support {
|
|
6923 |
} // taxonomies
|
6924 |
} // ids
|
6925 |
|
|
|
|
|
|
|
|
|
|
|
6926 |
// If there are no terms we want an empty cloud
|
6927 |
if ( empty( $includes ) ) {
|
6928 |
$arguments['include'] = (string) 0x7FFFFFFF;
|
162 |
*/
|
163 |
private static $size_parameter = '';
|
164 |
|
165 |
+
/**
|
166 |
+
* Informs _get_attachment_image_src() of the 'size=icon_feature' setting
|
167 |
+
*
|
168 |
+
* @since 3.00
|
169 |
+
*
|
170 |
+
* @var boolean 'mla_use_featured' parameter value
|
171 |
+
*/
|
172 |
+
private static $mla_use_featured = false;
|
173 |
+
|
174 |
/**
|
175 |
* Filters the image src result, returning the "Featured Image" or an icon to represent a non-image attachment.
|
176 |
*
|
196 |
$image = false;
|
197 |
}
|
198 |
|
199 |
+
// Look for the "Featured Image" as an alternate thumbnail for PDFs, etc.
|
200 |
+
if ( self::$mla_use_featured && ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ENABLE_FEATURED_IMAGE ) ) ) {
|
201 |
+
$nested_call = true;
|
202 |
+
$feature = get_the_post_thumbnail( $attachment_id, $size, array( 'class' => 'attachment-thumbnail' ) );
|
203 |
+
$nested_call = false;
|
204 |
+
|
205 |
+
if ( ! empty( $feature ) ) {
|
206 |
+
$match_count = preg_match_all( '# width=\"([^\"]+)\" height=\"([^\"]+)\" src=\"([^\"]+)\" #', $feature, $matches, PREG_OFFSET_CAPTURE );
|
207 |
+
if ( ! ( ( $match_count == false ) || ( $match_count == 0 ) ) ) {
|
208 |
+
$image = array( $matches[3][0][0], $matches[1][0][0], $matches[2][0][0] );
|
209 |
+
return $image;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
} // enable_featured_image
|
213 |
+
|
214 |
// If a native image exists, we're done
|
215 |
if ( false !== $image ) {
|
216 |
return $image;
|
217 |
}
|
218 |
|
219 |
// Look for the "Featured Image" as an alternate thumbnail for PDFs, etc.
|
220 |
+
if ( ( 'icon_only' !== self::$size_parameter ) && ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ENABLE_FEATURED_IMAGE ) ) ) {
|
221 |
$nested_call = true;
|
222 |
$feature = get_the_post_thumbnail( $attachment_id, $size, array( 'class' => 'attachment-thumbnail' ) );
|
223 |
$nested_call = false;
|
523 |
'mla_rml_include_children' => false,
|
524 |
|
525 |
'mla_named_transfer' => false,
|
526 |
+
'mla_use_featured' => false,
|
527 |
'mla_viewer' => false,
|
528 |
'mla_single_thread' => false,
|
529 |
'mla_viewer_extensions' => 'ai,eps,pdf,ps',
|
798 |
$size = strtolower( $arguments['size'] );
|
799 |
self::$size_parameter = $size;
|
800 |
|
801 |
+
// Pass mla_use_featured argument to _get_attachment_image_src() and replace special values
|
802 |
+
self::$mla_use_featured = !empty( $arguments['mla_use_featured'] ) ? 'true' === strtolower( $arguments['mla_use_featured'] ) : false;
|
803 |
+
|
804 |
if ( ( 'icon_only' === $size ) || ( 'icon_feature' === $size ) ) {
|
805 |
$size = 'icon';
|
806 |
}
|
1423 |
} else {
|
1424 |
$thumbnail_content = $attachment->post_title;
|
1425 |
|
1426 |
+
if ( ( 'none' !== $arguments['size'] ) && ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ENABLE_FEATURED_IMAGE ) ) ) {
|
1427 |
// Look for the "Featured Image" as an alternate thumbnail for PDFs, etc.
|
1428 |
$thumb = get_the_post_thumbnail( $attachment->ID, $size, array( 'class' => 'attachment-thumbnail' ) );
|
1429 |
$thumb = apply_filters( 'mla_gallery_featured_image', $thumb, $attachment, $size, $item_values );
|
1490 |
}
|
1491 |
|
1492 |
if ( ! empty( $link_attributes ) ) {
|
1493 |
+
$item_values['pagelink'] = preg_replace( '#<a( .*)href=#', '<a$1' . $link_attributes . 'href=', $item_values['pagelink'] );
|
1494 |
+
$item_values['filelink'] = preg_replace( '#<a( .*)href=#', '<a$1' . $link_attributes . 'href=', $item_values['filelink'] );
|
1495 |
+
// $item_values['pagelink'] = str_replace( '<a href=', '<a ' . $link_attributes . 'href=', $item_values['pagelink'] );
|
1496 |
+
// $item_values['filelink'] = str_replace( '<a href=', '<a ' . $link_attributes . 'href=', $item_values['filelink'] );
|
1497 |
}
|
1498 |
|
1499 |
/*
|
1713 |
$item_values['thumbnail_url'] = '';
|
1714 |
|
1715 |
/* Replaced by logic in _get_attachment_image_src v2.90
|
1716 |
+
if ( ( 'none' !== $arguments['size'] ) && ( 'checked' == MLACore::mla_get_option( MLACoreOptions::MLA_ENABLE_FEATURED_IMAGE ) ) ) {
|
1717 |
// Look for the "Featured Image" as an alternate thumbnail for PDFs, etc.
|
1718 |
$feature = get_the_post_thumbnail( $attachment->ID, $size, array( 'class' => 'attachment-thumbnail' ) );
|
1719 |
$feature = apply_filters( 'mla_gallery_featured_image', $feature, $attachment, $size, $item_values );
|
4557 |
* @since 2.20
|
4558 |
*
|
4559 |
* @param array value(s) for mla_output_type parameter
|
4560 |
+
* @param array template substitution values, e.g., ('instance' => '1', ... )
|
4561 |
+
* @param array merged default and passed shortcode parameter values
|
4562 |
+
* @param array raw passed shortcode parameter values
|
4563 |
* @param integer number of attachments in the gallery, without pagination
|
4564 |
* @param string output text so far, may include debug values
|
4565 |
*
|
4566 |
* @return mixed false or string with HTML for pagination output types
|
4567 |
*/
|
4568 |
private static function _process_pagination_output_types( $output_parameters, $markup_values, $arguments, $attr, $found_rows, $output = '' ) {
|
4569 |
+
//error_log( __LINE__ . ' _process_pagination_output_types output_parameters = ' . var_export( $output_parameters, true ), 0 );
|
4570 |
+
//error_log( __LINE__ . ' _process_pagination_output_types markup_values = ' . var_export( $markup_values, true ), 0 );
|
4571 |
+
//error_log( __LINE__ . ' _process_pagination_output_types arguments = ' . var_export( $arguments, true ), 0 );
|
4572 |
+
//error_log( __LINE__ . ' _process_pagination_output_types attr = ' . var_export( $attr, true ), 0 );
|
4573 |
if ( ! in_array( $output_parameters[0], array( 'previous_page', 'next_page', 'paginate_links' ) ) ) {
|
4574 |
return false;
|
4575 |
}
|
4590 |
$arguments[ $mla_page_parameter ] = '';
|
4591 |
}
|
4592 |
}
|
4593 |
+
//error_log( __LINE__ . ' _process_pagination_output_types arguments = ' . var_export( $arguments, true ), 0 );
|
4594 |
|
4595 |
if ( 0 == $posts_per_page ) {
|
4596 |
$posts_per_page = absint( $arguments['numberposts'] );
|
4686 |
$markup_values['new_offset'] = 0;
|
4687 |
}
|
4688 |
|
4689 |
+
$markup_values['current_page_text'] = $mla_page_parameter . '="[+current_page+]"';
|
4690 |
+
$markup_values['new_page_text'] = $mla_page_parameter . '="[+new_page+]"';
|
4691 |
$markup_values['last_page_text'] = 'mla_paginate_total="[+last_page+]"';
|
4692 |
$markup_values['posts_per_page_text'] = 'posts_per_page="[+posts_per_page+]"';
|
4693 |
|
4709 |
$uri_query = add_query_arg( array( $mla_page_parameter => $new_page ), $uri_query );
|
4710 |
}
|
4711 |
|
4712 |
+
if ( ( 0 < strlen( $uri_query ) ) && ( '?' !== $uri_query[0] ) ) {
|
4713 |
+
$uri_query = '?' . $uri_query;
|
4714 |
+
}
|
4715 |
+
|
4716 |
// Validate the query arguments to prevent cross-site scripting (reflection) attacks
|
4717 |
$test_query = array();
|
4718 |
parse_str( strval( $uri_query ), $test_query );
|
4730 |
$markup_values['query_string'] = $clean_query;
|
4731 |
|
4732 |
if ( !empty( $clean_query ) ) {
|
4733 |
+
// $markup_values['request_uri'] = $uri_path . '?' . $clean_query;
|
4734 |
+
$markup_values['request_uri'] = $uri_path . $clean_query;
|
4735 |
} else {
|
4736 |
$markup_values['request_uri'] = $uri_path;
|
4737 |
}
|
6946 |
* The "ids" parameter can build an item-specific cloud.
|
6947 |
* Compile a list of all the terms assigned to the items.
|
6948 |
*/
|
6949 |
+
if ( ! empty( $arguments['ids'] ) ) {
|
6950 |
$ids = wp_parse_id_list( $arguments['ids'] );
|
6951 |
$placeholders = implode( "','", $ids );
|
6952 |
$clause[] = "AND tr.object_id IN ( '{$placeholders}' )";
|
6963 |
} // taxonomies
|
6964 |
} // ids
|
6965 |
|
6966 |
+
// Apply a non-empty argument before we replace it.
|
6967 |
+
if ( ! empty( $arguments['include'] ) ) {
|
6968 |
+
$includes = array_intersect( $includes, wp_parse_id_list( $arguments['include'] ) );
|
6969 |
+
}
|
6970 |
+
|
6971 |
// If there are no terms we want an empty cloud
|
6972 |
if ( empty( $includes ) ) {
|
6973 |
$arguments['include'] = (string) 0x7FFFFFFF;
|
includes/class-mla-wpml-support.php
CHANGED
@@ -266,7 +266,7 @@ class MLA_WPML {
|
|
266 |
}
|
267 |
|
268 |
self::_build_existing_terms( $post_id );
|
269 |
-
if ( isset( $_REQUEST['action'] ) &&
|
270 |
MLACore::mla_debug_add( __LINE__ . " MLA_WPML::mla_list_table_inline_action( {$post_id} ) Quick Edit initial \$_REQUEST['tax_input'] = " . var_export( $_REQUEST['tax_input'], true ), MLACore::MLA_DEBUG_CATEGORY_LANGUAGE ); // phpcs:ignore
|
271 |
|
272 |
if ( 'checked' == MLACore::mla_get_option( 'term_assignment', false, false, MLA_WPML::$mla_language_option_definitions ) ) {
|
266 |
}
|
267 |
|
268 |
self::_build_existing_terms( $post_id );
|
269 |
+
if ( isset( $_REQUEST['action'] ) && MLACore::JAVASCRIPT_INLINE_EDIT_SLUG === $_REQUEST['action'] && isset( $_REQUEST['tax_input'] ) ) {
|
270 |
MLACore::mla_debug_add( __LINE__ . " MLA_WPML::mla_list_table_inline_action( {$post_id} ) Quick Edit initial \$_REQUEST['tax_input'] = " . var_export( $_REQUEST['tax_input'], true ), MLACore::MLA_DEBUG_CATEGORY_LANGUAGE ); // phpcs:ignore
|
271 |
|
272 |
if ( 'checked' == MLACore::mla_get_option( 'term_assignment', false, false, MLA_WPML::$mla_language_option_definitions ) ) {
|
index.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* will the rest of the plugin be loaded and run.
|
7 |
*
|
8 |
* @package Media Library Assistant
|
9 |
-
* @version
|
10 |
*/
|
11 |
|
12 |
/*
|
@@ -16,7 +16,7 @@ Description: Enhances the Media Library; powerful [mla_gallery] [mla_tag_cloud]
|
|
16 |
Author: David Lingren
|
17 |
Text Domain: media-library-assistant
|
18 |
Domain Path: /languages
|
19 |
-
Version:
|
20 |
Author URI: http://davidlingren.com/
|
21 |
|
22 |
Copyright 2011-2022 David Lingren
|
6 |
* will the rest of the plugin be loaded and run.
|
7 |
*
|
8 |
* @package Media Library Assistant
|
9 |
+
* @version 3.01
|
10 |
*/
|
11 |
|
12 |
/*
|
16 |
Author: David Lingren
|
17 |
Text Domain: media-library-assistant
|
18 |
Domain Path: /languages
|
19 |
+
Version: 3.01
|
20 |
Author URI: http://davidlingren.com/
|
21 |
|
22 |
Copyright 2011-2022 David Lingren
|
js/mla-media-modal-scripts.js
CHANGED
@@ -286,13 +286,15 @@ var wp, wpAjax, ajaxurl, jQuery, _,
|
|
286 |
},
|
287 |
|
288 |
change: function() {
|
289 |
-
var toolbar = $( this.el ).closest( 'div.media-toolbar' ),
|
290 |
-
|
291 |
|
292 |
if ( filter ) {
|
293 |
// silent because we must change the "s" prop before triggering an update
|
294 |
-
this.model.set( filter.props, { silent: true } );
|
295 |
-
$( '#mla-search-submit', toolbar ).trigger('click');
|
|
|
|
|
296 |
}
|
297 |
}
|
298 |
});
|
@@ -392,13 +394,15 @@ var wp, wpAjax, ajaxurl, jQuery, _,
|
|
392 |
},
|
393 |
|
394 |
change: function() {
|
395 |
-
var toolbar = $( this.el ).closest( 'div.media-toolbar' ),
|
396 |
-
|
397 |
|
398 |
if ( filter ) {
|
399 |
// silent because we must change the "s" prop before triggering an update
|
400 |
-
this.model.set( filter.props, { silent: true } );
|
401 |
-
$( '#mla-search-submit', toolbar ).trigger('click');
|
|
|
|
|
402 |
}
|
403 |
}
|
404 |
});
|
286 |
},
|
287 |
|
288 |
change: function() {
|
289 |
+
// var toolbar = $( this.el ).closest( 'div.media-toolbar' ),
|
290 |
+
var filter = this.filters[ this.el.value ];
|
291 |
|
292 |
if ( filter ) {
|
293 |
// silent because we must change the "s" prop before triggering an update
|
294 |
+
// this.model.set( filter.props, { silent: true } );
|
295 |
+
// $( '#mla-search-submit', toolbar ).trigger('click');
|
296 |
+
// console.log('AttachmentFilters.Mla filter: ', JSON.stringify( filter ) );
|
297 |
+
this.model.set( filter.props, { silent: false } );
|
298 |
}
|
299 |
}
|
300 |
});
|
394 |
},
|
395 |
|
396 |
change: function() {
|
397 |
+
// var toolbar = $( this.el ).closest( 'div.media-toolbar' ),
|
398 |
+
var filter = this.filters[ this.el.value ];
|
399 |
|
400 |
if ( filter ) {
|
401 |
// silent because we must change the "s" prop before triggering an update
|
402 |
+
// this.model.set( filter.props, { silent: true } );
|
403 |
+
// $( '#mla-search-submit', toolbar ).trigger('click');
|
404 |
+
// console.log('AttachmentFilters.MlaUploaded filter: ', JSON.stringify( filter ) );
|
405 |
+
this.model.set( filter.props, { silent: false } );
|
406 |
}
|
407 |
}
|
408 |
});
|
js/mla-media-modal-scripts.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var wp,wpAjax,ajaxurl,jQuery,_,getUserSetting,setUserSetting,deleteUserSetting,mlaTaxonomy,mlaModal={strings:{},settings:{},initialHTML:{},uploading:false,cid:null,utility:{originalMediaAjax:null,mlaAttachmentsBrowser:null,parseTermsOptions:null,arrayCleanup:null,parseTaxonomyId:null,hookCompatTaxonomies:null,fillCompatTaxonomies:null,supportCompatTaxonomies:null},tagBox:null};(function(d){var c=wp.media.view.AttachmentsBrowser,b=wp.media.view.AttachmentCompat,a=wp.media.model.Selection;mlaModal.strings=typeof wp.media.view.l10n.mla_strings==="undefined"?{}:wp.media.view.l10n.mla_strings;delete wp.media.view.l10n.mla_strings;mlaModal.settings=typeof wp.media.view.settings.mla_settings==="undefined"?{screen:"unknown",enableMediaGrid:false,enableMediaModal:false}:wp.media.view.settings.mla_settings;delete wp.media.view.settings.mla_settings;if(!(mlaModal.settings.enableMediaGrid||mlaModal.settings.enableMediaModal)){return}if("grid"===mlaModal.settings.screen){if(false===mlaModal.settings.enableMediaGrid){return}d("body").addClass("mla-media-grid")}if("modal"===mlaModal.settings.screen){if(false===mlaModal.settings.enableMediaModal){return}d("body").addClass("mla-media-modal")}mlaModal.settings.pagenow=typeof pagenow==="undefined"?"unknown":pagenow;if(mlaModal.settings.pagenow==="toolset_page_views-editor"){return}mlaModal.utility.originalMediaAjax=wp.media.ajax;wp.media.ajax=function(k,g){var j=mlaModal.settings.state,i,f,h,e,l;if(_.isObject(k)){g=k}else{g=g||{};g.data=_.extend(g.data||{},{action:k})}if("query-attachments"==g.data.action){i=g.data.query;f=typeof i.s;if("object"==f){h=i.s}else{if("string"==f){h={mla_search_value:i.s}}else{h={mla_search_value:""}}}if("undefined"!=typeof i.post_mime_type){mlaModal.settings.query[j].filterMime=i.post_mime_type}else{mlaModal.settings.query[j].filterMime="all"}if("undefined"!=typeof h.mla_filter_month){mlaModal.settings.query[j].filterMonth=h.mla_filter_month}else{if("undefined"!=typeof i.year){mlaModal.settings.query[j].filterMonth=(100*i.year)+(1*i.monthnum)}else{}}if("undefined"!=typeof h.mla_filter_term){mlaModal.settings.query[j].filterTerm=h.mla_filter_term}if("undefined"!=typeof h.mla_search_value){mlaModal.settings.query[j].searchValue=h.mla_search_value}e={mla_filter_month:mlaModal.settings.query[j].filterMonth,mla_filter_term:mlaModal.settings.query[j].filterTerm,mla_terms_search:mlaModal.settings.query[j].termsSearch,mla_search_clicks:mlaModal.settings.query[j].searchClicks,mla_search_value:mlaModal.settings.query[j].searchValue,mla_search_fields:mlaModal.settings.query[j].searchFields,mla_search_connector:mlaModal.settings.query[j].searchConnector};mlaModal.settings.query[j].termsSearch="";d("#mla-terms-search-input").html("").val("");g.data.query.s=e;if(d(document.activeElement).hasClass("acf-button")){l=d(document.activeElement).parentsUntil("div.acf-fields");if(l.length){g.data.query._acfuploader=d(l[l.length-1]).attr("data-key")}}}return mlaModal.utility.originalMediaAjax.call(this,g)};if(mlaModal.settings.enableMimeTypes){wp.media.view.AttachmentFilters.Mla=wp.media.view.AttachmentFilters.extend({createFilters:function(){var f=this.controller._state,e={};_.each(mlaModal.settings.allMimeTypes||{},function(h,g){if(("grid"===mlaModal.settings.screen)||("trash"!==g)){e[g]={text:h,props:{type:g,uploadedTo:null,orderby:"date",order:"DESC"}}}});e.all={text:wp.media.view.l10n.allMediaItems,props:{type:null,uploadedTo:null,orderby:"date",order:"DESC"},priority:10};if(wp.media.view.settings.post.id){e.uploaded={text:wp.media.view.l10n.uploadedToThisPost,props:{type:null,uploadedTo:wp.media.view.settings.post.id,orderby:"menuOrder",order:"ASC"},priority:20}}this.filters=e;if("undefined"===typeof e[mlaModal.settings.query[f].filterMime]){mlaModal.settings.query[f].filterMime="all"}if(mlaModal.settings.query[f].filterMime!="all"){this.model.set(e[mlaModal.settings.query[f].filterMime].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterMime,f=e.toJSON();if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}_.find(this.filters,function(j,k){var i=_.all(j.props,function(m,l){return m===(_.isUndefined(f[l])?null:f[l])});if(i){return g=k}});this.$el.val(g)},change:function(){var f=d(this.el).closest("div.media-toolbar"),e=this.filters[this.el.value];if(e){this.model.set(e.props,{silent:true});d("#mla-search-submit",f).trigger("click")}}});wp.media.view.AttachmentFilters.MlaUploaded=wp.media.view.AttachmentFilters.extend({createFilters:function(){var f=this.model.get("type"),e=wp.media.view.settings.mimeTypes,i,h=this.controller._state,g={};if(e&&f){i=e[f]}_.each(mlaModal.settings.uploadMimeTypes||{},function(k,j){if(("grid"===mlaModal.settings.screen)||("trash"!==j)){g[j]={text:k,props:{type:j,uploadedTo:null,orderby:"date",order:"DESC"}}}});g.all={text:i||wp.media.view.l10n.allMediaItems,props:{uploadedTo:null,orderby:"date",order:"DESC"},priority:10};g.uploaded={text:wp.media.view.l10n.uploadedToThisPost,props:{type:null,uploadedTo:wp.media.view.settings.post.id,orderby:"menuOrder",order:"ASC"},priority:20};g.unattached={text:wp.media.view.l10n.unattached,props:{uploadedTo:0,orderby:"menuOrder",order:"ASC"},priority:50};this.filters=g;if("undefined"===typeof g[mlaModal.settings.query[h].filterUploaded]){mlaModal.settings.query[h].filterUploaded="all"}if(mlaModal.settings.query[h].filterUploaded!="all"){this.model.set(g[mlaModal.settings.query[h].filterUploaded].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterMime,f=e.toJSON();if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}_.find(this.filters,function(j,k){var i=_.all(j.props,function(m,l){return m===(_.isUndefined(f[l])?null:f[l])});if(i){return g=k}});this.$el.val(g)},change:function(){var f=d(this.el).closest("div.media-toolbar"),e=this.filters[this.el.value];if(e){this.model.set(e.props,{silent:true});d("#mla-search-submit",f).trigger("click")}}})}if(mlaModal.settings.enableMonthsDropdown){wp.media.view.AttachmentFilters.MlaMonths=wp.media.view.AttachmentFilters.extend({className:"attachment-filters",id:"media-attachment-date-filters",createFilters:function(){var f=this.controller._state,e={};_.each(mlaModal.settings.months||{},function(h,g){e[g]={text:h,props:{s:{mla_filter_month:g}}}});this.filters=e;if("undefined"===typeof e[mlaModal.settings.query[f].filterMonth]){mlaModal.settings.query[f].filterMonth=0}if(mlaModal.settings.query[f].filterMonth>0){this.model.set(e[mlaModal.settings.query[f].filterMonth].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterMonth,f=e.toJSON();if(_.isUndefined(f.s)){f.s={}}if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}if(_.isUndefined(f.s.mla_filter_month)){f.s.mla_filter_month=mlaModal.settings.query[h].filterMonth}else{mlaModal.settings.query[h].filterMonth=f.s.mla_filter_month}_.find(this.filters,function(j,k){var i=_.all(j.props,function(l){return l.mla_filter_month==mlaModal.settings.query[h].filterMonth});if(i){return g=k}});this.$el.val(g)},change:function(){var e=this.filters[this.el.value],f;if(e){f={s:{mla_filter_month:e.props.s.mla_filter_month}};this.model.set(f)}}})}if(mlaModal.settings.enableTermsDropdown){wp.media.view.AttachmentFilters.MlaTerms=wp.media.view.AttachmentFilters.extend({className:"attachment-filters",id:"media-attachment-term-filters",createFilters:function(){var h=this.controller._state,e,f,g={};_.each(mlaModal.settings.termsText||{},function(j,i){if(mlaModal.settings.termsCustom){f=mlaModal.settings.termsValue[i]}else{f=parseInt(mlaModal.settings.termsValue[i])}g[i]={text:j,props:{s:{mla_filter_term:f}}}});this.filters=g;e=_.indexOf(mlaModal.settings.termsValue,mlaModal.settings.query[h].filterTerm);if(e>0){this.model.set(g[e].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterTerm,f=e.toJSON();if(_.isUndefined(f.s)){f.s={}}if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}if(_.isUndefined(f.s.mla_filter_term)){f.s.mla_filter_term=mlaModal.settings.query[h].filterTerm}else{mlaModal.settings.query[h].filterTerm=f.s.mla_filter_term}_.find(this.filters,function(j,k){var i=_.all(j.props,function(l){return l.mla_filter_term==mlaModal.settings.query[h].filterTerm});if(i){return g=k}});this.$el.val(g)},change:function(){var e=this.filters[this.el.value],f;if(e){f={s:{mla_filter_term:e.props.s.mla_filter_term}};this.model.set(f)}}})}if(mlaModal.settings.enableTermsSearch){wp.media.view.MlaTermsSearch=wp.media.View.extend({tagName:"span",className:"mla-terms-search",template:wp.media.template("mla-terms-search-button"),attributes:{type:"mla-terms-search-button"},events:{change:"termsSearchOpen",click:"termsSearchOpen"},render:function(){this.$el.html(this.template(mlaModal.strings));return this},termsSearchOpen:function(f){var e=d(this.el).closest("div.media-toolbar");if(("click"==f.type)&&("mla_terms_search"===f.target.name)){mlaTaxonomy.termsSearch.open();d("#mla-terms-search-form").off("submit");d("#mla-terms-search-form").submit(function(j){var g,i,h={phrases:"",taxonomies:[]};j.preventDefault();g=d("#mla-terms-search-form").serializeArray();for(i=0;i<g.length;i++){switch(g[i].name){case"mla_terms_search[phrases]":h.phrases=g[i].value;break;case"mla_terms_search[radio_phrases]":h.radio_phrases=g[i].value;break;case"mla_terms_search[radio_terms]":h.radio_terms=g[i].value;break;case"mla_terms_search[taxonomies][]":h.taxonomies[h.taxonomies.length]=g[i].value;break}}mlaModal.settings.query[mlaModal.settings.state].termsSearch=h;d("#mla-search-submit",e).trigger("click");return false});d("#mla-terms-search-input").on("keypress",function(g){if(13==g.which){g.preventDefault();d("#mla-terms-search-submit").trigger("click")}})}}})}if(mlaModal.settings.enableSearchBox){wp.media.view.MlaSearch=wp.media.View.extend({tagName:"div",className:"mla-search-box",template:wp.media.template("mla-search-box"),attributes:{type:"mla-search-box"},events:{input:"search",change:"search",click:"search",search:"search",MlaSearch:"search"},initialize:function(){var e=this.controller._state;if("undefined"===typeof mlaModal.settings.query[e]){mlaModal.settings.query[e]=_.clone(mlaModal.settings.query.initial);mlaModal.settings.query[e].searchFields=_.clone(mlaModal.settings.query.initial.searchFields)}},render:function(){var f=this.controller._state,e=_.extend(mlaModal.strings,mlaModal.settings.query[f]);searchValues={mla_filter_month:mlaModal.settings.query[f].filterMonth,mla_filter_term:mlaModal.settings.query[f].filterTerm,mla_terms_search:mlaModal.settings.query[f].termsSearch,mla_search_clicks:mlaModal.settings.query[f].searchClicks++,mla_search_value:mlaModal.settings.query[f].searchValue,mla_search_fields:mlaModal.settings.query[f].searchFields,mla_search_connector:mlaModal.settings.query[f].searchConnector};this.model.set({s:searchValues});this.$el.html(this.template(e));return this},search:function(g){var h=this.controller._state,e,f;if(("input"==g.type)&&("s[mla_search_value]"==g.target.name)){mlaModal.settings.query[h].searchValue=g.target.value;return}if(("click"==g.type)&&("mla_search_submit"!=g.target.name)){return}switch(g.target.name){case"s[mla_search_value]":mlaModal.settings.query[h].searchValue=g.target.value;break;case"mla_search_submit":e={mla_filter_month:mlaModal.settings.query[h].filterMonth,mla_filter_term:mlaModal.settings.query[h].filterTerm,mla_terms_search:mlaModal.settings.query[h].termsSearch,mla_search_clicks:mlaModal.settings.query[h].searchClicks++,mla_search_value:mlaModal.settings.query[h].searchValue,mla_search_fields:mlaModal.settings.query[h].searchFields,mla_search_connector:mlaModal.settings.query[h].searchConnector};this.model.set({s:e});break;case"s[mla_search_connector]":mlaModal.settings.query[h].searchConnector=g.target.value;break;case"s[mla_search_title]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("title");if(-1==f){mlaModal.settings.query[h].searchFields.push("title")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_name]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("name");if(-1==f){mlaModal.settings.query[h].searchFields.push("name")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_alt_text]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("alt-text");if(-1==f){mlaModal.settings.query[h].searchFields.push("alt-text")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_excerpt]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("excerpt");if(-1==f){mlaModal.settings.query[h].searchFields.push("excerpt")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_content]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("content");if(-1==f){mlaModal.settings.query[h].searchFields.push("content")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_file]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("file");if(-1==f){mlaModal.settings.query[h].searchFields.push("file")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_terms]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("terms");if(-1==f){mlaModal.settings.query[h].searchFields.push("terms")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break}}})}else{wp.media.view.MlaSearch=wp.media.View.extend({tagName:"span",className:"mla-simulate-search-button",template:wp.media.template("mla-simulate-search-button"),attributes:{type:"mla-simulate-search-button"},events:{click:"simulateSearch"},render:function(){this.$el.html(this.template(mlaModal.strings));return this},simulateSearch:function(){var f=this.controller._state,e={mla_filter_month:mlaModal.settings.query[f].filterMonth,mla_filter_term:mlaModal.settings.query[f].filterTerm,mla_terms_search:mlaModal.settings.query[f].termsSearch,mla_search_clicks:mlaModal.settings.query[f].searchClicks++,mla_search_value:mlaModal.settings.query[f].searchValue,mla_search_fields:mlaModal.settings.query[f].searchFields,mla_search_connector:mlaModal.settings.query[f].searchConnector};this.model.set({s:e})}})}if(mlaModal.settings.enableMimeTypes||mlaModal.settings.enableMonthsDropdown||mlaModal.settings.enableTermsDropdown||mlaModal.settings.enableTermsSearch||mlaModal.settings.enableSearchBox){wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({initialize:function(){c.prototype.initialize.apply(this,arguments);if("undefined"===typeof window.eml){if("grid"===mlaModal.settings.screen){d("body").addClass("mla-media-grid")}else{d("body").addClass("mla-media-modal")}mlaModal.settings.oldHeight=0;this.$window=d(window);if("object"===typeof this.attachmentsWrapper){this.on("ready",this.adjustBrowser58,this);this.$window.on("resize",_.debounce(_.bind(this.adjustBrowser58,this),15))}else{if("object"===typeof this.attachments){this.on("ready",this.adjustBrowser57,this);this.$window.on("resize",_.debounce(_.bind(this.adjustBrowser57,this),15))}}}},adjustBrowser58:function(){var i=this.attachmentsWrapper,f=this.toolbar,h,e,g;e=f.primary.$el.height();g=f.secondary.$el.height();if(e>g){h=e}else{h=g}if((0<h)&&(h!==mlaModal.settings.oldHeight)){i.$el.css("top",h+10+"px");mlaModal.settings.oldHeight=h}},adjustBrowser57:function(){var f=this.attachments,g=this.toolbar,i,e,h;e=g.primary.$el.height();h=g.secondary.$el.height();if(e>h){i=e}else{i=h}if((0<i)&&(i!==mlaModal.settings.oldHeight)){f.$el.css("top",i+10+"px");mlaModal.settings.oldHeight=i}},createToolbar:function(){var e,f=this.controller._state;mlaModal.settings.state=f;mlaModal.settings.$el=this.controller.$el;if("undefined"===typeof mlaModal.settings.query[f]){mlaModal.settings.query[f]=_.clone(mlaModal.settings.query.initial);mlaModal.settings.query[f].searchFields=_.clone(mlaModal.settings.query.initial.searchFields)}c.prototype.createToolbar.apply(this,arguments);mlaModal.utility.mlaAttachmentsBrowser=this;e=this.options.filters;d(".media-attachments-filter-heading",this.$el).css("display","none");if(("all"===e)&&mlaModal.settings.enableMimeTypes){this.toolbar.unset("filters",{silent:true});this.toolbar.set("filters",new wp.media.view.AttachmentFilters.Mla({controller:this.controller,model:this.collection.props,priority:-80}).render())}if(("uploaded"===e)&&mlaModal.settings.enableMimeTypes){this.toolbar.unset("filters",{silent:true});this.toolbar.set("filters",new wp.media.view.AttachmentFilters.MlaUploaded({controller:this.controller,model:this.collection.props,priority:-80}).render())}if(this.options.search&&mlaModal.settings.enableMonthsDropdown){this.toolbar.unset("dateFilter",{silent:true});this.toolbar.set("dateFilter",new wp.media.view.AttachmentFilters.MlaMonths({controller:this.controller,model:this.collection.props,priority:-75}).render())}if(this.options.search&&mlaModal.settings.enableTermsDropdown){this.toolbar.set("terms",new wp.media.view.AttachmentFilters.MlaTerms({controller:this.controller,model:this.collection.props,priority:-50}).render())}if(this.options.search&&mlaModal.settings.enableTermsSearch){this.toolbar.set("termsSearch",new wp.media.view.MlaTermsSearch({controller:this.controller,model:this.collection.props,priority:-50}).render())}if(this.options.search){if(mlaModal.settings.enableSearchBox){this.controller.on("content:activate",this.hideDefaultSearch);this.controller.on("edit:activate",this.hideDefaultSearch);this.controller.on("router:render",this.hideDefaultSearch);this.controller.on("uploader:ready",this.hideDefaultSearch);this.toolbar.set("MlaSearch",new wp.media.view.MlaSearch({controller:this.controller,model:this.collection.props,priority:-40}).render())}else{this.toolbar.set("MlaSearch",new wp.media.view.MlaSearch({controller:this.controller,model:this.collection.props,priority:70}).render())}}},hideDefaultSearch:function(){var e=d("#media-search-input",mlaModal.settings.$el),f=d(".media-search-input-label",mlaModal.settings.$el);if(0===e.length){e=d("div.media-toolbar-primary > input.search",mlaModal.settings.$el)}e.hide();f.hide()},updateFilters:function(e,f){var g={};if(this.options.search&&mlaModal.settings.enableTermsDropdown&&mlaModal.settings.termsTaxonomy==e){g=mlaModal.utility.parseTermsOptions(f);mlaModal.settings.termsClass=g.termsClass;mlaModal.settings.termsText=g.termsText;mlaModal.settings.termsValue=g.termsValue;this.toolbar.unset("terms",{silent:true});this.toolbar.set("terms",new wp.media.view.AttachmentFilters.MlaTerms({controller:this.controller,model:this.collection.props,priority:-80}).render())}}})}mlaModal.utility.parseTermsOptions=function(k){var j={termsClass:[mlaModal.settings.termsClass[0],mlaModal.settings.termsClass[1]],termsText:[mlaModal.settings.termsText[0],mlaModal.settings.termsText[1]],termsValue:[mlaModal.settings.termsValue[0],mlaModal.settings.termsValue[1]]},g=2,e,f,i=/\<option(( class=\"([^\"]+)\" )|( ))value=((\'([^\']+)\')|(\"([^\"]+)\"))([^\>]*)\>([^\<]*)\<.*/g,h=[];if("object"===typeof k){g=mlaModal.settings.termsValue.length;for(e=2;e<g;e++){h[e]={termsClass:mlaModal.settings.termsClass[e],termsText:mlaModal.settings.termsText[e],termsValue:mlaModal.settings.termsValue[e]};if("undefined"!==typeof k[mlaModal.settings.termsValue[e]]){delete k[mlaModal.settings.termsValue[e]]}}for(f in k){h[e++]={termsClass:"level-0",termsText:k[f],termsValue:f.toString()}}if(g===e){return{termsClass:mlaModal.settings.termsClass,termsText:mlaModal.settings.termsText,termsValue:mlaModal.settings.termsValue}}h.sort(function(m,l){if(m.termsText>l.termsText){return 1}else{if(m.termsText<l.termsText){return -1}else{return 0}}});e=2;for(f in h){j.termsClass[e]=h[f].termsClass;j.termsText[e]=h[f].termsText;j.termsValue[e++]=h[f].termsValue}return j}h=i.exec(k);while(null!==(h=i.exec(k))){j.termsClass[g]=h[3];j.termsValue[g]=("undefined"===typeof h[6])?h[9]:h[7];j.termsText[g++]=h[11].replace(" ",mlaModal.settings.termsIndent)}return j};mlaModal.utility.arrayCleanup=function(g){var f=[],e=("string"===typeof g);if(e){g=g.split(mlaModal.settings.comma)}jQuery.each(g,function(h,i){i=jQuery.trim(i);if(i&&jQuery.inArray(i,f)==-1){f.push(i)}});f.sort();if(e){f=f.join(mlaModal.settings.comma)}return f};mlaModal.utility.parseTaxonomyId=function(f){var e=f.split("-");e.shift();e.shift();return e.join("-")};mlaModal.tagBox={cleanTags:function(f){var e=mlaModal.settings.comma;if(","!==e){f=f.replace(new RegExp(e,"g"),",")}f=f.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"");if(","!==e){f=f.replace(/,/g,e)}return f},parseTags:function(h){var l=h.id,f=l.split("-check-num-")[1],i=d(h).closest(".tagsdiv"),k=i.find(".the-tags"),e=mlaModal.settings.comma,g=k.val().split(e),j=[];delete g[f];d.each(g,function(m,n){n=d.trim(n);if(n){j.push(n)}});k.val(this.cleanTags(j.join(e)));this.quickClicks(i);return false},quickClicks:function(g){var j=d(".the-tags",g),h=d(".tagchecklist",g),i=d(g).attr("id"),e,f;if(!j.length){return}f=j.prop("disabled");e=j.val().split(mlaModal.settings.comma);h.empty();d.each(e,function(m,n){var l,k;n=d.trim(n);if(!n){return}if(mlaModal.settings.generateTagUl){l=d("<li />").text(n)}else{l=d("<span />").text(n)}if(!f){if(mlaModal.settings.generateTagButtons){k=d('<button class="ntdelbutton" id="'+i+"-check-num-"+m+'" type="button"><span class="remove-tag-icon" aria-hidden="true"></span><span class="screen-reader-text">'+mlaModal.settings.removeTerm+": "+n+"</span></button>")}else{k=d('<a id="'+i+"-check-num-"+m+'" class="ntdelbutton">X</a>')}k.on("click",function(){mlaModal.tagBox.parseTags(this)});l.prepend(" ").prepend(k)}h.append(l)})},flushTags:function(k,h,g){var m,e,i,n=d(".the-tags",k),j=d("input.newtag",k),l=mlaModal.settings.comma;h=h||false;i=h?d(h).text():j.val();m=n.val();e=m?m+l+i:i;e=mlaModal.utility.arrayCleanup(this.cleanTags(e));n.val(e);this.quickClicks(k);if(!h){j.val("")}if("undefined"==typeof(g)){j.focus()}return false},getCloud:function(f,e){d.post(ajaxurl,{action:"get-tagcloud",tax:e},function(h,g){if(0===h||"success"!=g){h=wpAjax.broken}h=d('<p id="tagcloud-'+e+'" class="the-tagcloud">'+h+"</p>");d("a",h).on("click",function(){mlaModal.tagBox.flushTags(d(this).closest(".mla-taxonomy-field").children(".tagsdiv"),this);return false});d("#"+f).after(h)})},init:function(i,e,g){var h,f;h=d("#mla-taxonomy-"+e,g);f=d("div.ajaxtag",h);mlaModal.tagBox.quickClicks(h);d("input.tagadd",f).on("click",function(){mlaModal.tagBox.flushTags(d(this).closest(".tagsdiv"))});d("input.newtag",f).on("keyup",function(j){if(13==j.which){mlaModal.tagBox.flushTags(h);return false}}).on("keypress",function(j){if(13==j.which){j.preventDefault();return false}}).each(function(){d(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+e,{delay:500,resultsClass:"mla_ac_results",selectClass:"mla_ac_over",matchClass:"mla_ac_match",minchars:2,multiple:true,multipleSep:mlaModal.settings.comma+" "})});h.siblings(":first").on("click",function(){mlaModal.tagBox.getCloud(d("a",this).attr("id"),e);d("a",this).unbind().on("click",function(){d(this).siblings(".the-tagcloud").toggle();return false});return false});d(".compat-field-"+e+" td",g).on("mouseleave",function(){var m,k=this,j=mlaModal.utility.arrayCleanup(d(".server-tags",k).val()),l=mlaModal.utility.arrayCleanup(d(".the-tags",k).val());if(j===l){return}d(k).css("opacity","0.5");m={id:i};m[e]=l;wp.media.post(mlaModal.settings.ajaxUpdateCompatAction,m).done(function(o){var p,n,q;for(n in o){if("object"===typeof(o[n]["object-terms"])){if(null!==mlaModal.utility.mlaAttachmentsBrowser){mlaModal.utility.mlaAttachmentsBrowser.updateFilters(n,o[n]["object-terms"])}delete o[n]["object-terms"]}for(q in o[n]){d("#"+q,k).replaceWith(o[n][q])}p=d("#mla-taxonomy-"+n,k);mlaModal.tagBox.quickClicks(p)}d(k).css("opacity","1.0")})});h.on("change",function(j){j.stopPropagation();return false});d(".the-tags, .server-tags .newtag",h).on("change",function(j){j.stopPropagation();return false})}};if(mlaModal.settings.enableDetailsCategory||mlaModal.settings.enableDetailsTag){wp.media.view.AttachmentCompat=wp.media.view.AttachmentCompat.extend({render:function(){b.prototype.render.apply(this,arguments);mlaModal.utility.hookCompatTaxonomies(this.model.get("id"),this.el);return this}})}if(mlaModal.settings.enableDetailsCategory||mlaModal.settings.enableDetailsTag){wp.media.model.Selection=wp.media.model.Selection.extend({initialize:function(){a.prototype.initialize.apply(this,arguments);this.on("selection:reset",function(){mlaModal.cid=null});this.on("selection:unsingle",function(){mlaModal.cid=null});this.on("selection:single",function(e){mlaModal.cid=e.cid});this.on("change:uploading",function(){mlaModal.uploading=true});this.on("change",function(e){var f=false,g;if(mlaModal.uploading&&mlaModal.cid===e.cid){mlaModal.uploading=false;f=true}else{if(false===e.attributes.uploading){g=_.clone(e.changed);delete g.title;delete g.caption;delete g.alt;delete g.description;if(!_.isEmpty(g)){f=true}}}if(true===f){mlaModal.utility.hookCompatTaxonomies(e.get("id"),mlaModal.settings.$el)}})}})}mlaModal.utility.hookCompatTaxonomies=function(h,f){var e,g=null;d(".mla-taxonomy-field .categorydiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));if(-1!=mlaModal.settings.enhancedTaxonomies.indexOf(e)){d(".compat-field-"+e+" th",f).on("click",{id:h,currentTaxonomy:e,el:f},function(i){mlaModal.utility.fillCompatTaxonomies(i.data)});d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).show()}else{d(this).remove()}});if(null===g){g=e}}else{d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).remove()}})}});d(".mla-taxonomy-field .tagsdiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));if(-1!=mlaModal.settings.enhancedTaxonomies.indexOf(e)){d(".compat-field-"+e+" th",f).on("click",{id:h,currentTaxonomy:e,el:f},function(i){mlaModal.utility.fillCompatTaxonomies(i.data)});d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).show()}else{d(this).remove()}});if(null===g){g=e}}else{d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).remove()}})}});if(mlaModal.settings.enableTermsAutofill&&null!==g){d(".compat-field-"+g+" th",f).trigger("click")}};mlaModal.utility.fillCompatTaxonomies=function(i){var f=i.el,h=[],e,g;d(".mla-taxonomy-field .categorydiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));h[h.length]=e;g=".compat-field-"+e;if("undefined"===typeof(mlaModal.initialHTML[e])){mlaModal.initialHTML[e]=d(g,f).html()}else{d(g,f).html(mlaModal.initialHTML[e])}d(g+" .categorydiv",f).html(mlaModal.strings.loadingText)});d(".mla-taxonomy-field .tagsdiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));h[h.length]=e;g=".compat-field-"+e;if("undefined"===typeof(mlaModal.initialHTML[e])){mlaModal.initialHTML[e]=d(g,f).html()}else{d(g,f).html(mlaModal.initialHTML[e])}d(g+" .tagsdiv",f).html(mlaModal.strings.loadingText)});if(h.length){wp.media.post(mlaModal.settings.ajaxFillCompatAction,{id:i.id,query:h}).done(function(k){var j,l;for(j in k){l=".compat-field-"+j;d(l,f).html(k[j])}mlaModal.utility.supportCompatTaxonomies(i);d(".compat-field-"+i.currentTaxonomy+" td",f).show()})}};mlaModal.utility.supportCompatTaxonomies=function(g){var f=g.id,e=g.el;if(mlaModal.settings.enableDetailsCategory){d(".mla-taxonomy-field .categorydiv",e).each(function(){var j=d(this),h,k,i,n,l,p,o,m;i=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));n=i+"_tab";l="#mla-"+i;p="#mla-new-"+i;o="#mla-search-"+i;m="#mla-attachments-"+f+"-"+i;if(i=="category"){n="cats"}j.find(".category-tabs").show();d(".compat-field-"+i+" th",e).on("click",function(){d(this).siblings("td").slideToggle()});j.on("mouseleave",function(){var t,q,s=[],r=j.find(l+"-checklist input:checked");r.each(function(){s[s.length]=d(this).val()});s.sort(function(v,u){return v-u});s=s.join(",");q=j.siblings(m).val();if(q===s){return}j.siblings(m).val(s);j.prop("disabled",true);t={id:f};t[i]=s;wp.media.post(mlaModal.settings.ajaxUpdateCompatAction,t).done(function(v){var u,w;for(u in v){for(w in v[u]){j.find("#"+w).html(v[u][w])}}j.find(o).val("");j.find(l+"-searcher").addClass("mla-hidden-children");j.prop("disabled",false)})});j.on('change input[type="checkbox"]',function(q){q.stopPropagation();return false});j.find(l+"-tabs a").on("click",function(){var q=d(this).attr("href");d(this).parent().addClass("tabs").siblings("li").removeClass("tabs");j.find(l+"-tabs").siblings(".tabs-panel").hide();j.find(q).show();d(this).focus();if("#mla-"+i+"-all"==q){deleteUserSetting(n)}else{setUserSetting(n,"pop")}return false});if(getUserSetting(n)){j.find(l+'-tabs a[href="#mla-'+i+'-pop"]').trigger("click")}j.find(l+"-add-toggle").on("click",function(){j.find(l+"-searcher").addClass("mla-hidden-children");j.find(l+"-adder").toggleClass("mla-hidden-children");j.find(l+'-tabs a[href="#mla-'+i+'-all"]').trigger("click");j.find(l+"-checklist li").show();j.find(l+"-checklist-pop li").show();if(false===j.find(l+"-adder").hasClass("mla-hidden-children")){j.find(p).val("").removeClass("form-input-tip");j.find(p).focus()}return false});j.find(p).on("keypress",function(q){if(13===q.keyCode){q.preventDefault();j.find(l+"-add-submit").trigger("click")}});j.find(l+"-add-submit").on("click",function(){j.find(p).focus()});h=function(q){if(!j.find(p).val()){return false}q.data+="&"+j.find(l+"-checklist :checked").serialize();j.prop("disabled",true);return q};k=function(v,u){var t,q=j.find("#new"+i+"_parent");j.prop("disabled",false);if("undefined"!=u.parsed.responses[0]&&(t=u.parsed.responses[0].supplemental.newcat_parent)){q.before(t);q.remove();if(null!==mlaModal.utility.mlaAttachmentsBrowser){mlaModal.utility.mlaAttachmentsBrowser.updateFilters(i,t)}}};j.find(l+"-checklist").wpList({alt:"",response:"mla-"+i+"-ajax-response",addBefore:h,addAfter:k});j.find(l+"-checklist, "+l+"-checklist-pop").on("click",'li.popular-category > label input[type="checkbox"]',function(){var q=d(this),s=q.is(":checked"),r=q.val();if(r&&q.parents("#mla-taxonomy-"+i).length){d("#in-"+i+"-"+r+", #in-popular-"+i+"-"+r,"#mla-taxonomy-"+i).prop("checked",s)}});d.extend(d.expr.pseudos||d.expr[":"],{matchTerms:function(s,r,q,t){return(s.textContent||s.innerText||"").toLowerCase().indexOf((q[3]||"").toLowerCase())>=0}});j.find(o).on("keypress",function(q){if(13===q.keyCode){q.preventDefault();j.find(o).val("");j.find(l+"-searcher").addClass("mla-hidden-children");j.find(l+"-checklist li").show();j.find(l+"-checklist-pop li").show();return}});j.find(o).on("keyup",function(s){var u,t,v,r,q;if(13===s.keyCode){s.preventDefault();j.find(l+"-search-toggle").focus();return}u=j.find(o).val();t=j.find(l+"-checklist li");v=j.find(l+"-checklist-pop li");if(0<u.length){t.hide();v.hide()}else{t.show();v.show()}r=j.find(l+"-checklist label:matchTerms('"+u+"')");r.closest("li").find("li").andSelf().show();r.parents(l+"-checklist li").show();q=j.find(l+"-checklist-pop label:matchTerms('"+u+"')");q.closest("li").find("li").andSelf().show();q.parents(l+"-checklist li").show()});j.find(l+"-search-toggle").on("click",function(){j.find(l+"-adder ").addClass("mla-hidden-children");j.find(l+"-searcher").toggleClass("mla-hidden-children");j.find(l+'-tabs a[href="#mla-'+i+'-all"]').trigger("click");j.find(l+"-checklist li").show();j.find(l+"-checklist-pop li").show();if(false===j.find(l+"-searcher").hasClass("mla-hidden-children")){j.find(o).val("").removeClass("form-input-tip");j.find(o).focus()}return false})})}if(mlaModal.settings.enableDetailsTag){d(".mla-taxonomy-field .tagsdiv",e).each(function(){var h=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));d(".compat-field-"+h+" th",e).on("click",function(){d(this).siblings("td").slideToggle()});mlaModal.tagBox.init(f,h,e)})}}}(jQuery));
|
1 |
+
var wp,wpAjax,ajaxurl,jQuery,_,getUserSetting,setUserSetting,deleteUserSetting,mlaTaxonomy,mlaModal={strings:{},settings:{},initialHTML:{},uploading:false,cid:null,utility:{originalMediaAjax:null,mlaAttachmentsBrowser:null,parseTermsOptions:null,arrayCleanup:null,parseTaxonomyId:null,hookCompatTaxonomies:null,fillCompatTaxonomies:null,supportCompatTaxonomies:null},tagBox:null};(function(d){var c=wp.media.view.AttachmentsBrowser,b=wp.media.view.AttachmentCompat,a=wp.media.model.Selection;mlaModal.strings=typeof wp.media.view.l10n.mla_strings==="undefined"?{}:wp.media.view.l10n.mla_strings;delete wp.media.view.l10n.mla_strings;mlaModal.settings=typeof wp.media.view.settings.mla_settings==="undefined"?{screen:"unknown",enableMediaGrid:false,enableMediaModal:false}:wp.media.view.settings.mla_settings;delete wp.media.view.settings.mla_settings;if(!(mlaModal.settings.enableMediaGrid||mlaModal.settings.enableMediaModal)){return}if("grid"===mlaModal.settings.screen){if(false===mlaModal.settings.enableMediaGrid){return}d("body").addClass("mla-media-grid")}if("modal"===mlaModal.settings.screen){if(false===mlaModal.settings.enableMediaModal){return}d("body").addClass("mla-media-modal")}mlaModal.settings.pagenow=typeof pagenow==="undefined"?"unknown":pagenow;if(mlaModal.settings.pagenow==="toolset_page_views-editor"){return}mlaModal.utility.originalMediaAjax=wp.media.ajax;wp.media.ajax=function(k,g){var j=mlaModal.settings.state,i,f,h,e,l;if(_.isObject(k)){g=k}else{g=g||{};g.data=_.extend(g.data||{},{action:k})}if("query-attachments"==g.data.action){i=g.data.query;f=typeof i.s;if("object"==f){h=i.s}else{if("string"==f){h={mla_search_value:i.s}}else{h={mla_search_value:""}}}if("undefined"!=typeof i.post_mime_type){mlaModal.settings.query[j].filterMime=i.post_mime_type}else{mlaModal.settings.query[j].filterMime="all"}if("undefined"!=typeof h.mla_filter_month){mlaModal.settings.query[j].filterMonth=h.mla_filter_month}else{if("undefined"!=typeof i.year){mlaModal.settings.query[j].filterMonth=(100*i.year)+(1*i.monthnum)}else{}}if("undefined"!=typeof h.mla_filter_term){mlaModal.settings.query[j].filterTerm=h.mla_filter_term}if("undefined"!=typeof h.mla_search_value){mlaModal.settings.query[j].searchValue=h.mla_search_value}e={mla_filter_month:mlaModal.settings.query[j].filterMonth,mla_filter_term:mlaModal.settings.query[j].filterTerm,mla_terms_search:mlaModal.settings.query[j].termsSearch,mla_search_clicks:mlaModal.settings.query[j].searchClicks,mla_search_value:mlaModal.settings.query[j].searchValue,mla_search_fields:mlaModal.settings.query[j].searchFields,mla_search_connector:mlaModal.settings.query[j].searchConnector};mlaModal.settings.query[j].termsSearch="";d("#mla-terms-search-input").html("").val("");g.data.query.s=e;if(d(document.activeElement).hasClass("acf-button")){l=d(document.activeElement).parentsUntil("div.acf-fields");if(l.length){g.data.query._acfuploader=d(l[l.length-1]).attr("data-key")}}}return mlaModal.utility.originalMediaAjax.call(this,g)};if(mlaModal.settings.enableMimeTypes){wp.media.view.AttachmentFilters.Mla=wp.media.view.AttachmentFilters.extend({createFilters:function(){var f=this.controller._state,e={};_.each(mlaModal.settings.allMimeTypes||{},function(h,g){if(("grid"===mlaModal.settings.screen)||("trash"!==g)){e[g]={text:h,props:{type:g,uploadedTo:null,orderby:"date",order:"DESC"}}}});e.all={text:wp.media.view.l10n.allMediaItems,props:{type:null,uploadedTo:null,orderby:"date",order:"DESC"},priority:10};if(wp.media.view.settings.post.id){e.uploaded={text:wp.media.view.l10n.uploadedToThisPost,props:{type:null,uploadedTo:wp.media.view.settings.post.id,orderby:"menuOrder",order:"ASC"},priority:20}}this.filters=e;if("undefined"===typeof e[mlaModal.settings.query[f].filterMime]){mlaModal.settings.query[f].filterMime="all"}if(mlaModal.settings.query[f].filterMime!="all"){this.model.set(e[mlaModal.settings.query[f].filterMime].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterMime,f=e.toJSON();if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}_.find(this.filters,function(j,k){var i=_.all(j.props,function(m,l){return m===(_.isUndefined(f[l])?null:f[l])});if(i){return g=k}});this.$el.val(g)},change:function(){var e=this.filters[this.el.value];if(e){this.model.set(e.props,{silent:false})}}});wp.media.view.AttachmentFilters.MlaUploaded=wp.media.view.AttachmentFilters.extend({createFilters:function(){var f=this.model.get("type"),e=wp.media.view.settings.mimeTypes,i,h=this.controller._state,g={};if(e&&f){i=e[f]}_.each(mlaModal.settings.uploadMimeTypes||{},function(k,j){if(("grid"===mlaModal.settings.screen)||("trash"!==j)){g[j]={text:k,props:{type:j,uploadedTo:null,orderby:"date",order:"DESC"}}}});g.all={text:i||wp.media.view.l10n.allMediaItems,props:{uploadedTo:null,orderby:"date",order:"DESC"},priority:10};g.uploaded={text:wp.media.view.l10n.uploadedToThisPost,props:{type:null,uploadedTo:wp.media.view.settings.post.id,orderby:"menuOrder",order:"ASC"},priority:20};g.unattached={text:wp.media.view.l10n.unattached,props:{uploadedTo:0,orderby:"menuOrder",order:"ASC"},priority:50};this.filters=g;if("undefined"===typeof g[mlaModal.settings.query[h].filterUploaded]){mlaModal.settings.query[h].filterUploaded="all"}if(mlaModal.settings.query[h].filterUploaded!="all"){this.model.set(g[mlaModal.settings.query[h].filterUploaded].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterMime,f=e.toJSON();if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}_.find(this.filters,function(j,k){var i=_.all(j.props,function(m,l){return m===(_.isUndefined(f[l])?null:f[l])});if(i){return g=k}});this.$el.val(g)},change:function(){var e=this.filters[this.el.value];if(e){this.model.set(e.props,{silent:false})}}})}if(mlaModal.settings.enableMonthsDropdown){wp.media.view.AttachmentFilters.MlaMonths=wp.media.view.AttachmentFilters.extend({className:"attachment-filters",id:"media-attachment-date-filters",createFilters:function(){var f=this.controller._state,e={};_.each(mlaModal.settings.months||{},function(h,g){e[g]={text:h,props:{s:{mla_filter_month:g}}}});this.filters=e;if("undefined"===typeof e[mlaModal.settings.query[f].filterMonth]){mlaModal.settings.query[f].filterMonth=0}if(mlaModal.settings.query[f].filterMonth>0){this.model.set(e[mlaModal.settings.query[f].filterMonth].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterMonth,f=e.toJSON();if(_.isUndefined(f.s)){f.s={}}if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}if(_.isUndefined(f.s.mla_filter_month)){f.s.mla_filter_month=mlaModal.settings.query[h].filterMonth}else{mlaModal.settings.query[h].filterMonth=f.s.mla_filter_month}_.find(this.filters,function(j,k){var i=_.all(j.props,function(l){return l.mla_filter_month==mlaModal.settings.query[h].filterMonth});if(i){return g=k}});this.$el.val(g)},change:function(){var e=this.filters[this.el.value],f;if(e){f={s:{mla_filter_month:e.props.s.mla_filter_month}};this.model.set(f)}}})}if(mlaModal.settings.enableTermsDropdown){wp.media.view.AttachmentFilters.MlaTerms=wp.media.view.AttachmentFilters.extend({className:"attachment-filters",id:"media-attachment-term-filters",createFilters:function(){var h=this.controller._state,e,f,g={};_.each(mlaModal.settings.termsText||{},function(j,i){if(mlaModal.settings.termsCustom){f=mlaModal.settings.termsValue[i]}else{f=parseInt(mlaModal.settings.termsValue[i])}g[i]={text:j,props:{s:{mla_filter_term:f}}}});this.filters=g;e=_.indexOf(mlaModal.settings.termsValue,mlaModal.settings.query[h].filterTerm);if(e>0){this.model.set(g[e].props,{silent:false})}},select:function(){var h=this.controller._state,e=this.model,g=mlaModal.settings.query[h].filterTerm,f=e.toJSON();if(_.isUndefined(f.s)){f.s={}}if(false===mlaModal.settings.enableSearchBox){if("string"==typeof f.search){mlaModal.settings.query[h].searchValue=f.search}else{mlaModal.settings.query[h].searchValue=""}}if(_.isUndefined(f.s.mla_filter_term)){f.s.mla_filter_term=mlaModal.settings.query[h].filterTerm}else{mlaModal.settings.query[h].filterTerm=f.s.mla_filter_term}_.find(this.filters,function(j,k){var i=_.all(j.props,function(l){return l.mla_filter_term==mlaModal.settings.query[h].filterTerm});if(i){return g=k}});this.$el.val(g)},change:function(){var e=this.filters[this.el.value],f;if(e){f={s:{mla_filter_term:e.props.s.mla_filter_term}};this.model.set(f)}}})}if(mlaModal.settings.enableTermsSearch){wp.media.view.MlaTermsSearch=wp.media.View.extend({tagName:"span",className:"mla-terms-search",template:wp.media.template("mla-terms-search-button"),attributes:{type:"mla-terms-search-button"},events:{change:"termsSearchOpen",click:"termsSearchOpen"},render:function(){this.$el.html(this.template(mlaModal.strings));return this},termsSearchOpen:function(f){var e=d(this.el).closest("div.media-toolbar");if(("click"==f.type)&&("mla_terms_search"===f.target.name)){mlaTaxonomy.termsSearch.open();d("#mla-terms-search-form").off("submit");d("#mla-terms-search-form").submit(function(j){var g,i,h={phrases:"",taxonomies:[]};j.preventDefault();g=d("#mla-terms-search-form").serializeArray();for(i=0;i<g.length;i++){switch(g[i].name){case"mla_terms_search[phrases]":h.phrases=g[i].value;break;case"mla_terms_search[radio_phrases]":h.radio_phrases=g[i].value;break;case"mla_terms_search[radio_terms]":h.radio_terms=g[i].value;break;case"mla_terms_search[taxonomies][]":h.taxonomies[h.taxonomies.length]=g[i].value;break}}mlaModal.settings.query[mlaModal.settings.state].termsSearch=h;d("#mla-search-submit",e).trigger("click");return false});d("#mla-terms-search-input").on("keypress",function(g){if(13==g.which){g.preventDefault();d("#mla-terms-search-submit").trigger("click")}})}}})}if(mlaModal.settings.enableSearchBox){wp.media.view.MlaSearch=wp.media.View.extend({tagName:"div",className:"mla-search-box",template:wp.media.template("mla-search-box"),attributes:{type:"mla-search-box"},events:{input:"search",change:"search",click:"search",search:"search",MlaSearch:"search"},initialize:function(){var e=this.controller._state;if("undefined"===typeof mlaModal.settings.query[e]){mlaModal.settings.query[e]=_.clone(mlaModal.settings.query.initial);mlaModal.settings.query[e].searchFields=_.clone(mlaModal.settings.query.initial.searchFields)}},render:function(){var f=this.controller._state,e=_.extend(mlaModal.strings,mlaModal.settings.query[f]);searchValues={mla_filter_month:mlaModal.settings.query[f].filterMonth,mla_filter_term:mlaModal.settings.query[f].filterTerm,mla_terms_search:mlaModal.settings.query[f].termsSearch,mla_search_clicks:mlaModal.settings.query[f].searchClicks++,mla_search_value:mlaModal.settings.query[f].searchValue,mla_search_fields:mlaModal.settings.query[f].searchFields,mla_search_connector:mlaModal.settings.query[f].searchConnector};this.model.set({s:searchValues});this.$el.html(this.template(e));return this},search:function(g){var h=this.controller._state,e,f;if(("input"==g.type)&&("s[mla_search_value]"==g.target.name)){mlaModal.settings.query[h].searchValue=g.target.value;return}if(("click"==g.type)&&("mla_search_submit"!=g.target.name)){return}switch(g.target.name){case"s[mla_search_value]":mlaModal.settings.query[h].searchValue=g.target.value;break;case"mla_search_submit":e={mla_filter_month:mlaModal.settings.query[h].filterMonth,mla_filter_term:mlaModal.settings.query[h].filterTerm,mla_terms_search:mlaModal.settings.query[h].termsSearch,mla_search_clicks:mlaModal.settings.query[h].searchClicks++,mla_search_value:mlaModal.settings.query[h].searchValue,mla_search_fields:mlaModal.settings.query[h].searchFields,mla_search_connector:mlaModal.settings.query[h].searchConnector};this.model.set({s:e});break;case"s[mla_search_connector]":mlaModal.settings.query[h].searchConnector=g.target.value;break;case"s[mla_search_title]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("title");if(-1==f){mlaModal.settings.query[h].searchFields.push("title")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_name]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("name");if(-1==f){mlaModal.settings.query[h].searchFields.push("name")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_alt_text]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("alt-text");if(-1==f){mlaModal.settings.query[h].searchFields.push("alt-text")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_excerpt]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("excerpt");if(-1==f){mlaModal.settings.query[h].searchFields.push("excerpt")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_content]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("content");if(-1==f){mlaModal.settings.query[h].searchFields.push("content")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_file]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("file");if(-1==f){mlaModal.settings.query[h].searchFields.push("file")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break;case"s[mla_search_terms]":if("change"!=g.type){break}f=mlaModal.settings.query[h].searchFields.indexOf("terms");if(-1==f){mlaModal.settings.query[h].searchFields.push("terms")}else{mlaModal.settings.query[h].searchFields.splice(f,1)}break}}})}else{wp.media.view.MlaSearch=wp.media.View.extend({tagName:"span",className:"mla-simulate-search-button",template:wp.media.template("mla-simulate-search-button"),attributes:{type:"mla-simulate-search-button"},events:{click:"simulateSearch"},render:function(){this.$el.html(this.template(mlaModal.strings));return this},simulateSearch:function(){var f=this.controller._state,e={mla_filter_month:mlaModal.settings.query[f].filterMonth,mla_filter_term:mlaModal.settings.query[f].filterTerm,mla_terms_search:mlaModal.settings.query[f].termsSearch,mla_search_clicks:mlaModal.settings.query[f].searchClicks++,mla_search_value:mlaModal.settings.query[f].searchValue,mla_search_fields:mlaModal.settings.query[f].searchFields,mla_search_connector:mlaModal.settings.query[f].searchConnector};this.model.set({s:e})}})}if(mlaModal.settings.enableMimeTypes||mlaModal.settings.enableMonthsDropdown||mlaModal.settings.enableTermsDropdown||mlaModal.settings.enableTermsSearch||mlaModal.settings.enableSearchBox){wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({initialize:function(){c.prototype.initialize.apply(this,arguments);if("undefined"===typeof window.eml){if("grid"===mlaModal.settings.screen){d("body").addClass("mla-media-grid")}else{d("body").addClass("mla-media-modal")}mlaModal.settings.oldHeight=0;this.$window=d(window);if("object"===typeof this.attachmentsWrapper){this.on("ready",this.adjustBrowser58,this);this.$window.on("resize",_.debounce(_.bind(this.adjustBrowser58,this),15))}else{if("object"===typeof this.attachments){this.on("ready",this.adjustBrowser57,this);this.$window.on("resize",_.debounce(_.bind(this.adjustBrowser57,this),15))}}}},adjustBrowser58:function(){var i=this.attachmentsWrapper,f=this.toolbar,h,e,g;e=f.primary.$el.height();g=f.secondary.$el.height();if(e>g){h=e}else{h=g}if((0<h)&&(h!==mlaModal.settings.oldHeight)){i.$el.css("top",h+10+"px");mlaModal.settings.oldHeight=h}},adjustBrowser57:function(){var f=this.attachments,g=this.toolbar,i,e,h;e=g.primary.$el.height();h=g.secondary.$el.height();if(e>h){i=e}else{i=h}if((0<i)&&(i!==mlaModal.settings.oldHeight)){f.$el.css("top",i+10+"px");mlaModal.settings.oldHeight=i}},createToolbar:function(){var e,f=this.controller._state;mlaModal.settings.state=f;mlaModal.settings.$el=this.controller.$el;if("undefined"===typeof mlaModal.settings.query[f]){mlaModal.settings.query[f]=_.clone(mlaModal.settings.query.initial);mlaModal.settings.query[f].searchFields=_.clone(mlaModal.settings.query.initial.searchFields)}c.prototype.createToolbar.apply(this,arguments);mlaModal.utility.mlaAttachmentsBrowser=this;e=this.options.filters;d(".media-attachments-filter-heading",this.$el).css("display","none");if(("all"===e)&&mlaModal.settings.enableMimeTypes){this.toolbar.unset("filters",{silent:true});this.toolbar.set("filters",new wp.media.view.AttachmentFilters.Mla({controller:this.controller,model:this.collection.props,priority:-80}).render())}if(("uploaded"===e)&&mlaModal.settings.enableMimeTypes){this.toolbar.unset("filters",{silent:true});this.toolbar.set("filters",new wp.media.view.AttachmentFilters.MlaUploaded({controller:this.controller,model:this.collection.props,priority:-80}).render())}if(this.options.search&&mlaModal.settings.enableMonthsDropdown){this.toolbar.unset("dateFilter",{silent:true});this.toolbar.set("dateFilter",new wp.media.view.AttachmentFilters.MlaMonths({controller:this.controller,model:this.collection.props,priority:-75}).render())}if(this.options.search&&mlaModal.settings.enableTermsDropdown){this.toolbar.set("terms",new wp.media.view.AttachmentFilters.MlaTerms({controller:this.controller,model:this.collection.props,priority:-50}).render())}if(this.options.search&&mlaModal.settings.enableTermsSearch){this.toolbar.set("termsSearch",new wp.media.view.MlaTermsSearch({controller:this.controller,model:this.collection.props,priority:-50}).render())}if(this.options.search){if(mlaModal.settings.enableSearchBox){this.controller.on("content:activate",this.hideDefaultSearch);this.controller.on("edit:activate",this.hideDefaultSearch);this.controller.on("router:render",this.hideDefaultSearch);this.controller.on("uploader:ready",this.hideDefaultSearch);this.toolbar.set("MlaSearch",new wp.media.view.MlaSearch({controller:this.controller,model:this.collection.props,priority:-40}).render())}else{this.toolbar.set("MlaSearch",new wp.media.view.MlaSearch({controller:this.controller,model:this.collection.props,priority:70}).render())}}},hideDefaultSearch:function(){var e=d("#media-search-input",mlaModal.settings.$el),f=d(".media-search-input-label",mlaModal.settings.$el);if(0===e.length){e=d("div.media-toolbar-primary > input.search",mlaModal.settings.$el)}e.hide();f.hide()},updateFilters:function(e,f){var g={};if(this.options.search&&mlaModal.settings.enableTermsDropdown&&mlaModal.settings.termsTaxonomy==e){g=mlaModal.utility.parseTermsOptions(f);mlaModal.settings.termsClass=g.termsClass;mlaModal.settings.termsText=g.termsText;mlaModal.settings.termsValue=g.termsValue;this.toolbar.unset("terms",{silent:true});this.toolbar.set("terms",new wp.media.view.AttachmentFilters.MlaTerms({controller:this.controller,model:this.collection.props,priority:-80}).render())}}})}mlaModal.utility.parseTermsOptions=function(k){var j={termsClass:[mlaModal.settings.termsClass[0],mlaModal.settings.termsClass[1]],termsText:[mlaModal.settings.termsText[0],mlaModal.settings.termsText[1]],termsValue:[mlaModal.settings.termsValue[0],mlaModal.settings.termsValue[1]]},g=2,e,f,i=/\<option(( class=\"([^\"]+)\" )|( ))value=((\'([^\']+)\')|(\"([^\"]+)\"))([^\>]*)\>([^\<]*)\<.*/g,h=[];if("object"===typeof k){g=mlaModal.settings.termsValue.length;for(e=2;e<g;e++){h[e]={termsClass:mlaModal.settings.termsClass[e],termsText:mlaModal.settings.termsText[e],termsValue:mlaModal.settings.termsValue[e]};if("undefined"!==typeof k[mlaModal.settings.termsValue[e]]){delete k[mlaModal.settings.termsValue[e]]}}for(f in k){h[e++]={termsClass:"level-0",termsText:k[f],termsValue:f.toString()}}if(g===e){return{termsClass:mlaModal.settings.termsClass,termsText:mlaModal.settings.termsText,termsValue:mlaModal.settings.termsValue}}h.sort(function(m,l){if(m.termsText>l.termsText){return 1}else{if(m.termsText<l.termsText){return -1}else{return 0}}});e=2;for(f in h){j.termsClass[e]=h[f].termsClass;j.termsText[e]=h[f].termsText;j.termsValue[e++]=h[f].termsValue}return j}h=i.exec(k);while(null!==(h=i.exec(k))){j.termsClass[g]=h[3];j.termsValue[g]=("undefined"===typeof h[6])?h[9]:h[7];j.termsText[g++]=h[11].replace(" ",mlaModal.settings.termsIndent)}return j};mlaModal.utility.arrayCleanup=function(g){var f=[],e=("string"===typeof g);if(e){g=g.split(mlaModal.settings.comma)}jQuery.each(g,function(h,i){i=jQuery.trim(i);if(i&&jQuery.inArray(i,f)==-1){f.push(i)}});f.sort();if(e){f=f.join(mlaModal.settings.comma)}return f};mlaModal.utility.parseTaxonomyId=function(f){var e=f.split("-");e.shift();e.shift();return e.join("-")};mlaModal.tagBox={cleanTags:function(f){var e=mlaModal.settings.comma;if(","!==e){f=f.replace(new RegExp(e,"g"),",")}f=f.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"");if(","!==e){f=f.replace(/,/g,e)}return f},parseTags:function(h){var l=h.id,f=l.split("-check-num-")[1],i=d(h).closest(".tagsdiv"),k=i.find(".the-tags"),e=mlaModal.settings.comma,g=k.val().split(e),j=[];delete g[f];d.each(g,function(m,n){n=d.trim(n);if(n){j.push(n)}});k.val(this.cleanTags(j.join(e)));this.quickClicks(i);return false},quickClicks:function(g){var j=d(".the-tags",g),h=d(".tagchecklist",g),i=d(g).attr("id"),e,f;if(!j.length){return}f=j.prop("disabled");e=j.val().split(mlaModal.settings.comma);h.empty();d.each(e,function(m,n){var l,k;n=d.trim(n);if(!n){return}if(mlaModal.settings.generateTagUl){l=d("<li />").text(n)}else{l=d("<span />").text(n)}if(!f){if(mlaModal.settings.generateTagButtons){k=d('<button class="ntdelbutton" id="'+i+"-check-num-"+m+'" type="button"><span class="remove-tag-icon" aria-hidden="true"></span><span class="screen-reader-text">'+mlaModal.settings.removeTerm+": "+n+"</span></button>")}else{k=d('<a id="'+i+"-check-num-"+m+'" class="ntdelbutton">X</a>')}k.on("click",function(){mlaModal.tagBox.parseTags(this)});l.prepend(" ").prepend(k)}h.append(l)})},flushTags:function(k,h,g){var m,e,i,n=d(".the-tags",k),j=d("input.newtag",k),l=mlaModal.settings.comma;h=h||false;i=h?d(h).text():j.val();m=n.val();e=m?m+l+i:i;e=mlaModal.utility.arrayCleanup(this.cleanTags(e));n.val(e);this.quickClicks(k);if(!h){j.val("")}if("undefined"==typeof(g)){j.focus()}return false},getCloud:function(f,e){d.post(ajaxurl,{action:"get-tagcloud",tax:e},function(h,g){if(0===h||"success"!=g){h=wpAjax.broken}h=d('<p id="tagcloud-'+e+'" class="the-tagcloud">'+h+"</p>");d("a",h).on("click",function(){mlaModal.tagBox.flushTags(d(this).closest(".mla-taxonomy-field").children(".tagsdiv"),this);return false});d("#"+f).after(h)})},init:function(i,e,g){var h,f;h=d("#mla-taxonomy-"+e,g);f=d("div.ajaxtag",h);mlaModal.tagBox.quickClicks(h);d("input.tagadd",f).on("click",function(){mlaModal.tagBox.flushTags(d(this).closest(".tagsdiv"))});d("input.newtag",f).on("keyup",function(j){if(13==j.which){mlaModal.tagBox.flushTags(h);return false}}).on("keypress",function(j){if(13==j.which){j.preventDefault();return false}}).each(function(){d(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+e,{delay:500,resultsClass:"mla_ac_results",selectClass:"mla_ac_over",matchClass:"mla_ac_match",minchars:2,multiple:true,multipleSep:mlaModal.settings.comma+" "})});h.siblings(":first").on("click",function(){mlaModal.tagBox.getCloud(d("a",this).attr("id"),e);d("a",this).unbind().on("click",function(){d(this).siblings(".the-tagcloud").toggle();return false});return false});d(".compat-field-"+e+" td",g).on("mouseleave",function(){var m,k=this,j=mlaModal.utility.arrayCleanup(d(".server-tags",k).val()),l=mlaModal.utility.arrayCleanup(d(".the-tags",k).val());if(j===l){return}d(k).css("opacity","0.5");m={id:i};m[e]=l;wp.media.post(mlaModal.settings.ajaxUpdateCompatAction,m).done(function(o){var p,n,q;for(n in o){if("object"===typeof(o[n]["object-terms"])){if(null!==mlaModal.utility.mlaAttachmentsBrowser){mlaModal.utility.mlaAttachmentsBrowser.updateFilters(n,o[n]["object-terms"])}delete o[n]["object-terms"]}for(q in o[n]){d("#"+q,k).replaceWith(o[n][q])}p=d("#mla-taxonomy-"+n,k);mlaModal.tagBox.quickClicks(p)}d(k).css("opacity","1.0")})});h.on("change",function(j){j.stopPropagation();return false});d(".the-tags, .server-tags .newtag",h).on("change",function(j){j.stopPropagation();return false})}};if(mlaModal.settings.enableDetailsCategory||mlaModal.settings.enableDetailsTag){wp.media.view.AttachmentCompat=wp.media.view.AttachmentCompat.extend({render:function(){b.prototype.render.apply(this,arguments);mlaModal.utility.hookCompatTaxonomies(this.model.get("id"),this.el);return this}})}if(mlaModal.settings.enableDetailsCategory||mlaModal.settings.enableDetailsTag){wp.media.model.Selection=wp.media.model.Selection.extend({initialize:function(){a.prototype.initialize.apply(this,arguments);this.on("selection:reset",function(){mlaModal.cid=null});this.on("selection:unsingle",function(){mlaModal.cid=null});this.on("selection:single",function(e){mlaModal.cid=e.cid});this.on("change:uploading",function(){mlaModal.uploading=true});this.on("change",function(e){var f=false,g;if(mlaModal.uploading&&mlaModal.cid===e.cid){mlaModal.uploading=false;f=true}else{if(false===e.attributes.uploading){g=_.clone(e.changed);delete g.title;delete g.caption;delete g.alt;delete g.description;if(!_.isEmpty(g)){f=true}}}if(true===f){mlaModal.utility.hookCompatTaxonomies(e.get("id"),mlaModal.settings.$el)}})}})}mlaModal.utility.hookCompatTaxonomies=function(h,f){var e,g=null;d(".mla-taxonomy-field .categorydiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));if(-1!=mlaModal.settings.enhancedTaxonomies.indexOf(e)){d(".compat-field-"+e+" th",f).on("click",{id:h,currentTaxonomy:e,el:f},function(i){mlaModal.utility.fillCompatTaxonomies(i.data)});d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).show()}else{d(this).remove()}});if(null===g){g=e}}else{d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).remove()}})}});d(".mla-taxonomy-field .tagsdiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));if(-1!=mlaModal.settings.enhancedTaxonomies.indexOf(e)){d(".compat-field-"+e+" th",f).on("click",{id:h,currentTaxonomy:e,el:f},function(i){mlaModal.utility.fillCompatTaxonomies(i.data)});d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).show()}else{d(this).remove()}});if(null===g){g=e}}else{d("tr.compat-field-"+e,f).each(function(){if(d(this).hasClass("mla-taxonomy-row")){d(this).remove()}})}});if(mlaModal.settings.enableTermsAutofill&&null!==g){d(".compat-field-"+g+" th",f).trigger("click")}};mlaModal.utility.fillCompatTaxonomies=function(i){var f=i.el,h=[],e,g;d(".mla-taxonomy-field .categorydiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));h[h.length]=e;g=".compat-field-"+e;if("undefined"===typeof(mlaModal.initialHTML[e])){mlaModal.initialHTML[e]=d(g,f).html()}else{d(g,f).html(mlaModal.initialHTML[e])}d(g+" .categorydiv",f).html(mlaModal.strings.loadingText)});d(".mla-taxonomy-field .tagsdiv",f).each(function(){e=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));h[h.length]=e;g=".compat-field-"+e;if("undefined"===typeof(mlaModal.initialHTML[e])){mlaModal.initialHTML[e]=d(g,f).html()}else{d(g,f).html(mlaModal.initialHTML[e])}d(g+" .tagsdiv",f).html(mlaModal.strings.loadingText)});if(h.length){wp.media.post(mlaModal.settings.ajaxFillCompatAction,{id:i.id,query:h}).done(function(k){var j,l;for(j in k){l=".compat-field-"+j;d(l,f).html(k[j])}mlaModal.utility.supportCompatTaxonomies(i);d(".compat-field-"+i.currentTaxonomy+" td",f).show()})}};mlaModal.utility.supportCompatTaxonomies=function(g){var f=g.id,e=g.el;if(mlaModal.settings.enableDetailsCategory){d(".mla-taxonomy-field .categorydiv",e).each(function(){var j=d(this),h,k,i,n,l,p,o,m;i=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));n=i+"_tab";l="#mla-"+i;p="#mla-new-"+i;o="#mla-search-"+i;m="#mla-attachments-"+f+"-"+i;if(i=="category"){n="cats"}j.find(".category-tabs").show();d(".compat-field-"+i+" th",e).on("click",function(){d(this).siblings("td").slideToggle()});j.on("mouseleave",function(){var t,q,s=[],r=j.find(l+"-checklist input:checked");r.each(function(){s[s.length]=d(this).val()});s.sort(function(v,u){return v-u});s=s.join(",");q=j.siblings(m).val();if(q===s){return}j.siblings(m).val(s);j.prop("disabled",true);t={id:f};t[i]=s;wp.media.post(mlaModal.settings.ajaxUpdateCompatAction,t).done(function(v){var u,w;for(u in v){for(w in v[u]){j.find("#"+w).html(v[u][w])}}j.find(o).val("");j.find(l+"-searcher").addClass("mla-hidden-children");j.prop("disabled",false)})});j.on('change input[type="checkbox"]',function(q){q.stopPropagation();return false});j.find(l+"-tabs a").on("click",function(){var q=d(this).attr("href");d(this).parent().addClass("tabs").siblings("li").removeClass("tabs");j.find(l+"-tabs").siblings(".tabs-panel").hide();j.find(q).show();d(this).focus();if("#mla-"+i+"-all"==q){deleteUserSetting(n)}else{setUserSetting(n,"pop")}return false});if(getUserSetting(n)){j.find(l+'-tabs a[href="#mla-'+i+'-pop"]').trigger("click")}j.find(l+"-add-toggle").on("click",function(){j.find(l+"-searcher").addClass("mla-hidden-children");j.find(l+"-adder").toggleClass("mla-hidden-children");j.find(l+'-tabs a[href="#mla-'+i+'-all"]').trigger("click");j.find(l+"-checklist li").show();j.find(l+"-checklist-pop li").show();if(false===j.find(l+"-adder").hasClass("mla-hidden-children")){j.find(p).val("").removeClass("form-input-tip");j.find(p).focus()}return false});j.find(p).on("keypress",function(q){if(13===q.keyCode){q.preventDefault();j.find(l+"-add-submit").trigger("click")}});j.find(l+"-add-submit").on("click",function(){j.find(p).focus()});h=function(q){if(!j.find(p).val()){return false}q.data+="&"+j.find(l+"-checklist :checked").serialize();j.prop("disabled",true);return q};k=function(v,u){var t,q=j.find("#new"+i+"_parent");j.prop("disabled",false);if("undefined"!=u.parsed.responses[0]&&(t=u.parsed.responses[0].supplemental.newcat_parent)){q.before(t);q.remove();if(null!==mlaModal.utility.mlaAttachmentsBrowser){mlaModal.utility.mlaAttachmentsBrowser.updateFilters(i,t)}}};j.find(l+"-checklist").wpList({alt:"",response:"mla-"+i+"-ajax-response",addBefore:h,addAfter:k});j.find(l+"-checklist, "+l+"-checklist-pop").on("click",'li.popular-category > label input[type="checkbox"]',function(){var q=d(this),s=q.is(":checked"),r=q.val();if(r&&q.parents("#mla-taxonomy-"+i).length){d("#in-"+i+"-"+r+", #in-popular-"+i+"-"+r,"#mla-taxonomy-"+i).prop("checked",s)}});d.extend(d.expr.pseudos||d.expr[":"],{matchTerms:function(s,r,q,t){return(s.textContent||s.innerText||"").toLowerCase().indexOf((q[3]||"").toLowerCase())>=0}});j.find(o).on("keypress",function(q){if(13===q.keyCode){q.preventDefault();j.find(o).val("");j.find(l+"-searcher").addClass("mla-hidden-children");j.find(l+"-checklist li").show();j.find(l+"-checklist-pop li").show();return}});j.find(o).on("keyup",function(s){var u,t,v,r,q;if(13===s.keyCode){s.preventDefault();j.find(l+"-search-toggle").focus();return}u=j.find(o).val();t=j.find(l+"-checklist li");v=j.find(l+"-checklist-pop li");if(0<u.length){t.hide();v.hide()}else{t.show();v.show()}r=j.find(l+"-checklist label:matchTerms('"+u+"')");r.closest("li").find("li").andSelf().show();r.parents(l+"-checklist li").show();q=j.find(l+"-checklist-pop label:matchTerms('"+u+"')");q.closest("li").find("li").andSelf().show();q.parents(l+"-checklist li").show()});j.find(l+"-search-toggle").on("click",function(){j.find(l+"-adder ").addClass("mla-hidden-children");j.find(l+"-searcher").toggleClass("mla-hidden-children");j.find(l+'-tabs a[href="#mla-'+i+'-all"]').trigger("click");j.find(l+"-checklist li").show();j.find(l+"-checklist-pop li").show();if(false===j.find(l+"-searcher").hasClass("mla-hidden-children")){j.find(o).val("").removeClass("form-input-tip");j.find(o).focus()}return false})})}if(mlaModal.settings.enableDetailsTag){d(".mla-taxonomy-field .tagsdiv",e).each(function(){var h=mlaModal.utility.parseTaxonomyId(d(this).attr("id"));d(".compat-field-"+h+" th",e).on("click",function(){d(this).siblings("td").slideToggle()});mlaModal.tagBox.init(f,h,e)})}}}(jQuery));
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: dglingren
|
|
3 |
Donate link: http://davidlingren.com/#donate
|
4 |
Tags: media, media library, gallery, images, categories, tags, attachments, IPTC, EXIF, XMP, GPS, PDF, metadata, photos, photographs, photo albums, MIME, mime-type, icon, upload, file extensions, WPML, Polylang
|
5 |
Requires at least: 3.5.0
|
6 |
-
Tested up to:
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag:
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -187,6 +187,37 @@ All of the MLA source code has been annotated with "DocBlocks", a special type o
|
|
187 |
|
188 |
== Changelog ==
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
= 2.99 =
|
191 |
|
192 |
* New: On the Media/Add New (Upload New Media) and Media/Assistant screens, **MLA Bulk Edit Area values can be saved and recalled for future/repeated use.**
|
@@ -209,26 +240,8 @@ All of the MLA source code has been annotated with "DocBlocks", a special type o
|
|
209 |
* Fix: For `[mla_term_list]`, `current_item_class` assignments for term_id values have been restored.
|
210 |
* Fix: For the "MLA Advanced Custom Fields Example" plugin, a PHP warning message during Media/Assistant bulk actions has been eliminated.
|
211 |
|
212 |
-
= 2.98 =
|
213 |
-
|
214 |
-
* New: A new **"Attachment File Metadata" meta box on the Media/Edit Media screen** displays IPTC, EXIF, XMP, ID3, PDF and/or MSO metadata embedded in the item's file. More information in the pull-down Help menu on that screen.
|
215 |
-
* New: For `[mla_gallery]`, a special `mla_minimum` parameter lets you display an empty gallery unless a minimum number of items is selected.
|
216 |
-
* New: The "MLA Advanced Custom Fields Example" plugin now supports ACF "Select" fields, mapping between the field label and field value on the Media/Assistant submenu table and the Bulk and Quick Areas.
|
217 |
-
* New: The new "MLA Filename Issues Example" plugin creates a custom data source to help identify items with duplicate file names for cleanup consideration.
|
218 |
-
* New: The term Parent column has been added to the Settings/Media Library Assistant Debug tab "Add Tax. Columns" results.
|
219 |
-
* Fix: Custom Field Rules with an "Inactive" status are now excluded from Media/Assistant submenu table columns and the Quick and Bulk Edit areas.
|
220 |
-
* Fix: An inconsistency in counting attachments that caused the Settings/Media Library Assistant IPTC/EXIF tab "Execute" and "Execute All Rules" actions to fail has been corrected.
|
221 |
-
* Fix: An XMP metadata parsing error for empty "rdf:Description" values has been corrected.
|
222 |
-
* Fix: The "MLA Custom Field Search Example" plugin has been updated to use the latest plugin settings class file, so the class can be shared with other example plugins.
|
223 |
-
* Fix: The old "MLA ACF Checkbox Example" plugin has been flagged as obsolete, replaced by the more useful "MLA Advanced Custom Fields Example" plugin.
|
224 |
-
* Fix: For the Media/Assistant Quick Edit Area, users with the 'unfilitered_html' permission can add any HTML tag to a custom field value.
|
225 |
-
* Fix: Incorrect display of counts for `[mla_tag_cloud]` and `[mla_term_list]` terms with more than 1,000 assigned items has been corrected.
|
226 |
-
* Fix: Toolbar cropping in the "Add media" popup window for WordPress versions before 5.8 has been corrected.
|
227 |
-
* Fix: Toolbar cropping in the "Add media" popup window when the Disable Gutenberg (by Jeff Starr) plugin is active has been corrected.
|
228 |
-
* Fix: For the "gallery in" and "MLA Gallery in" reporting, PHP "trigger_error" Warning messages have been converted to MLA debug logging messages.
|
229 |
-
* Fix: For the "MLA Insert Fixit" example plugin, a PHP 8.0+ Deprecation Error has been resolved.
|
230 |
-
|
231 |
-
= 2.90 - 2.97 =
|
232 |
* 2.97 - IMPORTANT: [mla_gallery] PHP "Warning: array_key_exists()..." messages have been eliminated. WP 5.8, cropping of MMMW top row image thubmnails fixed. Description element added to mapping rules. Four enhancements in all, four fixes.
|
233 |
* 2.96 - WordPress 5.8 support! New [muie_archive_list] shortcode. CSV export item values. Support for Enhanced Media Library plugin. Donation links are back. Thirteen enhancements in all, fourteen fixes.
|
234 |
* 2.95 - Support for Real Media Library plugin in Media/Assistant and `[mla_gallery]`, MLA Insert Fixit improvements, `[mla_gallery]` simple date parameters, "Mine" filter/view. Four enhancements in all, twelve fixes.
|
@@ -348,8 +361,8 @@ All of the MLA source code has been annotated with "DocBlocks", a special type o
|
|
348 |
|
349 |
== Upgrade Notice ==
|
350 |
|
351 |
-
=
|
352 |
-
|
353 |
|
354 |
== Other Notes ==
|
355 |
|
3 |
Donate link: http://davidlingren.com/#donate
|
4 |
Tags: media, media library, gallery, images, categories, tags, attachments, IPTC, EXIF, XMP, GPS, PDF, metadata, photos, photographs, photo albums, MIME, mime-type, icon, upload, file extensions, WPML, Polylang
|
5 |
Requires at least: 3.5.0
|
6 |
+
Tested up to: 6.0
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 3.01
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
187 |
|
188 |
== Changelog ==
|
189 |
|
190 |
+
= 3.01 =
|
191 |
+
|
192 |
+
* Fix: For the Media/Assistant Bulk Edit feature, AJAX errors have been corrected.
|
193 |
+
|
194 |
+
= 3.00 =
|
195 |
+
|
196 |
+
* New: For the "MLA UI Elements Example" plugin, HTML attributes can be added to the `[muie_terms_search]` and `[muie_keyword_search]` shortcodes. The Settings/MLA UI Elements Documentation tab has details.
|
197 |
+
* New: The "MLA UI Elements Example" plugin has enhanced `[muie_terms_search]` and `[muie_keyword_search]` shortcodes that support multiple independent search boxes on a single post/page. The Settings/MLA UI Elements Documentation tab has details.
|
198 |
+
* New: The new "MLA Preset Terms Example" plugin adds "Preset Terms" to Media/Assistant rollover actions, redirecting to Media/Add New (Upload New Media) screen with terms copied from the selected item.
|
199 |
+
* New: The "MLA Substitution Parameter Hooks Example" plugin now provides a `computed_orientation` custom data source that derives "Landscape" or "Portrait" from image height and width values.
|
200 |
+
* New: For `[mla_gallery]`, a new `mla_use_featured` parameter lets you substitute an item’s Featured Image in a gallery display even if it has a native thumbnail image.
|
201 |
+
* New: The "MLA Multisite Extensions" example plugin now supports the "Multisite Global Media" plugin, which adds a "Global Media" tab to the Media Manager Modal (popup) Window.
|
202 |
+
* New: The `file_size` and `size_bytes` data sources take advantage of the `filesize` value added to attachment metadata in WP 6.0.
|
203 |
+
* Fix: For `[mla_term_list]` and `[mla_tag_cloud]`, the `include=` parameter can be used to filter the results of an `ids=` parameter.
|
204 |
+
* Fix: For `[mla_gallery]`, adding attributes to thumbnail links will work if other attributes are already present before the `href=` attribute.
|
205 |
+
* Fix: For the "MLA UI Elements Example" plugin, `mla_control_name` more completely overrides `tax_input`.
|
206 |
+
* Fix: The WordPress `wptexturize()` function is no longer applied to the data sources `absolute_path`, `path`, `absolute_file_name`, `file_name`, `name_only` and `extension`.
|
207 |
+
* Fix: To increase security, all Media/Assistant bulk actions must pass a NONCE validation.
|
208 |
+
* Fix: To increase security, file, example plugin and error log downloads now have unique NONCE action values.
|
209 |
+
* Fix: The Media/Assistant "Download" bulk action now rejects a missing list of attachment IDs.
|
210 |
+
* Fix: Some problems with pagination links when `mla_page-parameter` is specified have been corrected.
|
211 |
+
* Fix: The `class-mla-file-downloader.php` file now exits silently when called outside the WordPress context, avoiding PHP Warning messages in the error log.
|
212 |
+
* Fix: A PHP8.x deprecated array element notation in `mla_hooks-example.php` has been corrected.
|
213 |
+
* Fix: An "undefined variable" defect in support for Jordy Meow's Media File Renamer plugin has been corrected.
|
214 |
+
* Fix: Improved parsing of XMP metadata in PDF documents that do not strictly conform to the standard.
|
215 |
+
* Fix: For the Media/Assistant submenu table, filtering by a specific MIME type, e.g., `application/pdf` within a general MIME type view, e.g. `application`, has been corrected.
|
216 |
+
* Fix: On the Media/Edit Media screen, the "Attachment File Metadata" text box now allows "invalid code points" (characters), replacing them with a harmless Unicode Replacement Character.
|
217 |
+
* Fix: For the Media Manager Modal (popup) Window, thumbnails in the "Uploaded to this post" can be re-ordered by drag and drop.
|
218 |
+
* Fix: For the Media/Assistant Bulk Edit Area, failure to update a field to a value of '0' has been corrected.
|
219 |
+
* Fix: For the "MLA Simple Mapping Hooks Example" plugin, the plugin is now active when media item inserts are performed in Gutenberg blocks.
|
220 |
+
|
221 |
= 2.99 =
|
222 |
|
223 |
* New: On the Media/Add New (Upload New Media) and Media/Assistant screens, **MLA Bulk Edit Area values can be saved and recalled for future/repeated use.**
|
240 |
* Fix: For `[mla_term_list]`, `current_item_class` assignments for term_id values have been restored.
|
241 |
* Fix: For the "MLA Advanced Custom Fields Example" plugin, a PHP warning message during Media/Assistant bulk actions has been eliminated.
|
242 |
|
243 |
+
= 2.90 - 2.98 =
|
244 |
+
* 2.98 - New "Attachment File Metadata" meta box on the Media/Edit Media screen. Enhanced "MLA Advanced Custom Fields Example" and new "MLA Filename Issues Example" plugins. Five enhancements in all, eleven fixes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
* 2.97 - IMPORTANT: [mla_gallery] PHP "Warning: array_key_exists()..." messages have been eliminated. WP 5.8, cropping of MMMW top row image thubmnails fixed. Description element added to mapping rules. Four enhancements in all, four fixes.
|
246 |
* 2.96 - WordPress 5.8 support! New [muie_archive_list] shortcode. CSV export item values. Support for Enhanced Media Library plugin. Donation links are back. Thirteen enhancements in all, fourteen fixes.
|
247 |
* 2.95 - Support for Real Media Library plugin in Media/Assistant and `[mla_gallery]`, MLA Insert Fixit improvements, `[mla_gallery]` simple date parameters, "Mine" filter/view. Four enhancements in all, twelve fixes.
|
361 |
|
362 |
== Upgrade Notice ==
|
363 |
|
364 |
+
= 3.01 =
|
365 |
+
IMPORTANT: For the Media/Assistant Bulk Edit feature, AJAX errors have been corrected.
|
366 |
|
367 |
== Other Notes ==
|
368 |
|
tpls/documentation-settings-tab.tpl
CHANGED
@@ -15,7 +15,7 @@ For more information about the example plugins, jump to <a href="#mla_example_pl
|
|
15 |
<li><a href="#complex_shortcodes">Entering Long/Complex Shortcodes</a></li>
|
16 |
<li><a href="#gallery_display_style">Gallery Display Style</a></li>
|
17 |
<li><a href="#gallery_display_content">Gallery Display Content</a></li>
|
18 |
-
<li><a href="#thumbnail_substitution">Thumbnail Substitution
|
19 |
<li><a href="#order_orderby">Order, Orderby</a></li>
|
20 |
<li><a href="#size">Size</a></li>
|
21 |
<li><a href="#link">Link</a></li>
|
@@ -463,15 +463,24 @@ mla_caption='<a href="{+file_url+}" target="_blank">{+title+}</a>'<b
|
|
463 |
Note the use of the alternative "enclosing shortcode" syntax in this example, which avoids the WordPress issues with including HTML markup in shortcode parameters.
|
464 |
<a name="thumbnail_substitution"></a>
|
465 |
</p>
|
466 |
-
<h4>Thumbnail Substitution
|
467 |
<p>
|
468 |
-
|
469 |
</p>
|
470 |
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
WordPress 4.7 added thumbnail generation for PDF documents, and these "native thumbnail images" will automatically be used when available. You can also use MLA's thumbnail generation support (in the Media/Assistant Bulk Actions) to create native thumbnails for older documents.
|
472 |
</p>
|
473 |
<p>
|
474 |
-
The dynamic thumbnail image generation for PDF and Postscript documents uses the PHP <code>Imagick</code> class, which <strong>requires ImageMagick and Ghostscript</strong> to be installed on your server. If you need help installing them, look at this <a href="https://wordpress.org/support/topic/nothing-but-error-messages" title="Help with installation" target="_blank">PDF Thumbnails support topic</a>. If you don't have them on your server you can still use the Featured Image support to supply thumbnails for
|
475 |
</p>
|
476 |
<p>
|
477 |
Ten <code>[mla_gallery]</code> parameters provide an easy way to simulate thumbnail images for the non-image file types.
|
@@ -1141,6 +1150,9 @@ The <code>[mla_gallery]</code> shortcode supports five parameters for filtering
|
|
1141 |
</table>
|
1142 |
<p>
|
1143 |
These five parameters always use the "Uploaded on" date, stored in the <code>post_date</code> column of the <code>wp_posts</code> database table. Remember to use <code>post_parent=current</code> if you want to restrict your query to items attached to the current post.
|
|
|
|
|
|
|
1144 |
<a name="date_queries"></a>
|
1145 |
</p>
|
1146 |
<h4>Date and Time Queries, the "date query"</h4>
|
@@ -1154,6 +1166,20 @@ As the <a href="https://developer.wordpress.org/reference/classes/wp_query/#date
|
|
1154 |
When embedding the shortcode in the body of a post, be very careful when coding the date_query; it must be a valid PHP array specification. Read and follow the rules and guidelines in the "<a href="#complex_shortcodes">Entering Long/Complex Shortcodes</a>" Documentation section to get the results you want.
|
1155 |
</p>
|
1156 |
<p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1157 |
Remember to use <code>post_parent=current</code> if you want to restrict your query to items attached to the current post.
|
1158 |
<a name="custom_field_parameters"></a>
|
1159 |
</p>
|
@@ -3278,7 +3304,7 @@ Here is a simple example of a dropdown control for the Att. Categories taxonomy:
|
|
3278 |
<code>
|
3279 |
<form id="mla-text-form" action="." method="post" class="row"><br />
|
3280 |
<strong>Att. Categories</strong><br />
|
3281 |
-
[mla_term_list taxonomy=attachment_category mla_output=dropdown mla_option_value="{+slug+}" show_count=true pad_counts=false ]<br />
|
3282 |
<br />
|
3283 |
<input id="text-form-submit" name="text_form_submit" type="submit" value="Search" /><br />
|
3284 |
</form><br />
|
@@ -3787,7 +3813,7 @@ This example is even simpler that the two earlier examples because there's just
|
|
3787 |
</p>
|
3788 |
<h3>Support for Other Gallery-generating Shortcodes</h3>
|
3789 |
<p>
|
3790 |
-
The <code>[mla_gallery]</code> shortcode can be used in combination with other gallery-generating shortcodes to give you the data selection power of <code>[mla_gallery]</code> and the formatting/display power of popular alternatives such as the WordPress.com Jetpack Carousel and Tiled Galleries modules. Any shortcode that accepts "ids=" or a similar parameter listing the attachment ID values for the gallery can be used.
|
3791 |
</p>
|
3792 |
<table>
|
3793 |
<tr>
|
@@ -3873,7 +3899,7 @@ You can also use the "enclosing shortcode" form if the alternate shortcode, such
|
|
3873 |
The <a href="http://wordpress.org/extend/plugins/photonic/" title="Photonic Gallery plugin directory page" target="_blank">Photonic Gallery for Flickr, Picasa, SmugMug, 500px and Instagram</a> plugin adds several new parameters to the <code>[mla_gallery]</code> shortcode to enhance your galleries. All you have to do is install the plugin, then add a "style=" parameter to your <code>[mla_gallery]</code> shortcode to use the Photonic styling and markup in place of the native <code>[mla_gallery]</code> style and markup templates.
|
3874 |
</p>
|
3875 |
<p>
|
3876 |
-
You can use the "Photonic" screen of the Insert Media dialog to build the display portion of your shortcode parameters. After you click "Insert into post", change the shortcode name from "gallery" to "mla_gallery" and add the query parameters you need to select the attachments for the gallery. The <code>[mla_gallery]</code> code will compile the list of attachments for your gallery, then hand control over to Photonic to format the results.
|
3877 |
<a name="real_media_library"></a>
|
3878 |
</p>
|
3879 |
<p>
|
@@ -4642,11 +4668,11 @@ Eight "format" values help you reformat fields or encode them for use in HTML at
|
|
4642 |
</tr>
|
4643 |
<tr>
|
4644 |
<td class="mla-doc-table-label" style="white-space:nowrap">,timestamp(f,m)</td>
|
4645 |
-
<td>Many date and time values such as <code>[+meta:image_meta.created_timestamp+]</code> are stored as a UNIX timestamp. The ",timestamp" format converts a timestamp into a variety of date and/or time string formats, using the PHP date() function. Details on the "f" (format string) argument can be found at: <a href="
|
4646 |
</tr>
|
4647 |
<tr>
|
4648 |
<td class="mla-doc-table-label" style="white-space:nowrap">,date(f,m)</td>
|
4649 |
-
<td>Many EXIF date and time values such as DateTimeOriginal and DateTimeDigitized are stored as strings with a format of "YYYY:MM:DD HH:MM:SS". You can parse this format and just about any English textual datetime description into a Unix timestamp, then format the result by using the ",date" format. This format first uses the PHP strtotime() function, then the date() function.
|
4650 |
</tr>
|
4651 |
</table>
|
4652 |
<p>
|
@@ -4945,11 +4971,11 @@ Each Media Library attachment item has a row in the "posts" database table that
|
|
4945 |
</tr>
|
4946 |
<tr>
|
4947 |
<td class="mla-doc-table-label">featured_in</td>
|
4948 |
-
<td>the title, post/page type and id number of each post/page for which this item is the "
|
4949 |
</tr>
|
4950 |
<tr>
|
4951 |
<td class="mla-doc-table-label">featured_in_title</td>
|
4952 |
-
<td>the title of each post/page for which this item is the "
|
4953 |
</tr>
|
4954 |
<tr>
|
4955 |
<td class="mla-doc-table-label">inserted_in</td>
|
@@ -6035,6 +6061,18 @@ The following hooks are defined in <code>/media-library-assistant/includes/class
|
|
6035 |
</p>
|
6036 |
<table>
|
6037 |
<tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6038 |
<td class="mla-doc-hook-label">mla_list_table_inline_fields</td>
|
6039 |
<td class="mla-doc-hook-definition">Gives you an opportunity to name the fields passed to the JavaScript functions for Quick editing.</td>
|
6040 |
</tr>
|
@@ -6067,14 +6105,6 @@ The following hooks are defined in <code>/media-library-assistant/includes/class
|
|
6067 |
<td class="mla-doc-hook-definition">Gives you an opportunity to post-process an MLA_List_Table bulk action, standard or custom. The filter is called once after all of the items in $_REQUEST['cb_attachment'] are processed.</td>
|
6068 |
</tr>
|
6069 |
<tr>
|
6070 |
-
<td class="mla-doc-hook-label">mla_list_table_admin_action</td>
|
6071 |
-
<td class="mla-doc-hook-definition">Gives you an opportunity to pre-process an MLA_List_Table item-level action, standard or custom, before the MLA handler. This filter is called before anything is output for the Media/Assistant submenu, so you can redirect to another admin screen if desired.</td>
|
6072 |
-
</tr>
|
6073 |
-
<tr>
|
6074 |
-
<td class="mla-doc-hook-label">mla_list_table_custom_admin_action</td>
|
6075 |
-
<td class="mla-doc-hook-definition">Gives you an opportunity to process an MLA_List_Table item-level action that MLA does not recognize. This filter is called before anything is output for the Media/Assistant submenu, so you can redirect to another admin screen if desired.</td>
|
6076 |
-
</tr>
|
6077 |
-
<tr>
|
6078 |
<td class="mla-doc-hook-label">mla_list_table_single_action</td>
|
6079 |
<td class="mla-doc-hook-definition">Gives you an opportunity to pre-process an MLA_List_Table item-level action, standard or custom, before the MLA handler. This filter is called after the Media/Assistant submenu screen header is output but before the messages and submenu table are displayed.</td>
|
6080 |
</tr>
|
@@ -6108,6 +6138,13 @@ The Media/Assistant Bulk Edit area has three copies of field-level values. The "
|
|
6108 |
</p>
|
6109 |
<table>
|
6110 |
<tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6111 |
<td class="mla-doc-hook-label">mla_list_table_inline_blank_values,<br />
|
6112 |
mla_list_table_inline_initial_values,<br />
|
6113 |
mla_list_table_inline_preset_values
|
@@ -6172,7 +6209,7 @@ The following hooks are defined in <code>/media-library-assistant/includes/class
|
|
6172 |
</tr>
|
6173 |
<tr>
|
6174 |
<td class="mla-doc-hook-label">mla_list_table_prepare_items</td>
|
6175 |
-
<td class="mla-doc-hook-definition">Gives you an opportunity to record or modify the results of the prepare_items database query
|
6176 |
</tr>
|
6177 |
<tr>
|
6178 |
<td class="mla-doc-hook-label">mla_list_table_build_rollover_actions</td>
|
@@ -6209,6 +6246,13 @@ The Media/Add New (Upload New Media) Bulk Edit area has three copies of field-le
|
|
6209 |
</p>
|
6210 |
<table>
|
6211 |
<tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6212 |
<td class="mla-doc-hook-label">mla_upload_bulk_edit_form_blank_values,<br />
|
6213 |
mla_upload_bulk_edit_form_initial_values,<br />
|
6214 |
mla_upload_bulk_edit_form_preset_values
|
@@ -6298,6 +6342,10 @@ The following hooks are defined in <code>/wp-admin/includes/class-mla-media-moda
|
|
6298 |
<td class="mla-doc-table-label">mla_media_modal_query_filtered_terms</td>
|
6299 |
<td class="mla-doc-hook-definition">Change the terms of the Media Manager Modal Window "Query Attachments" query after they are pre-processed by the AJAX handler</td>
|
6300 |
</tr>
|
|
|
|
|
|
|
|
|
6301 |
</table>
|
6302 |
<p>
|
6303 |
The following hooks are defined in <code>/wp-admin/includes/class-mla-data-query.php</code>:
|
@@ -6656,7 +6704,7 @@ Contains a list of data elements you can map to the custom field. You can also s
|
|
6656 |
If you just want to add a custom field to the Media/Assistant submenu, the quick edit area and/or the bulk edit area you can bypass the mapping logic by leaving the Data Source value as "-- None (select a value) --".
|
6657 |
<br /> <br />
|
6658 |
Most of the data elements are static, i.e., they do not change after the attachment is added to the Media Library.
|
6659 |
-
The parent/reference information (parent_type, parent_title, parent_issues, reference_issues) and the "where-used" information (featured in, inserted in, gallery in and MLA gallery in) is dynamic; it will change as you define galleries, insert images in posts, define
|
6660 |
<br /> <br />
|
6661 |
Several of the data elements are sourced from the WordPress "image_meta" array. The credit, caption, copyright and title elements are taken from the IPTC/EXIF metadata (if any), but they go through a number of filtering rules that are not easy to replicate with the MLA IPTC/EXIF processing rules. You may find these "image_meta" elements more useful than the raw IPTC/EXIF metadata.
|
6662 |
</dd>
|
15 |
<li><a href="#complex_shortcodes">Entering Long/Complex Shortcodes</a></li>
|
16 |
<li><a href="#gallery_display_style">Gallery Display Style</a></li>
|
17 |
<li><a href="#gallery_display_content">Gallery Display Content</a></li>
|
18 |
+
<li><a href="#thumbnail_substitution">Thumbnail Substitution,<br />Featured Images and mla_viewer</a></li>
|
19 |
<li><a href="#order_orderby">Order, Orderby</a></li>
|
20 |
<li><a href="#size">Size</a></li>
|
21 |
<li><a href="#link">Link</a></li>
|
463 |
Note the use of the alternative "enclosing shortcode" syntax in this example, which avoids the WordPress issues with including HTML markup in shortcode parameters.
|
464 |
<a name="thumbnail_substitution"></a>
|
465 |
</p>
|
466 |
+
<h4>Thumbnail Substitution, Featured Images and mla_viewer</h4>
|
467 |
<p>
|
468 |
+
There are two ways you can provide a thumbnail image for gallery display: 1) you can add a Featured Image to any Media Library item or 2) you can use the <code>mla_viewer</code> parameter to have one generated when the gallery is displayed.
|
469 |
</p>
|
470 |
<p>
|
471 |
+
You can assign a "Featured Image" to any Media Library item. Simply go to the Media/Edit Media screen, scroll down to the "Featured Image" meta box and select an image as you would for a post or page. For non-image items such as Microsoft Office documents the Featured Image will replace the MIME-type icon or document title in a gallery display. For items which have a native thumbnail (generated by WordPress) you can add a shortcode parameter to the <code>[mla_gallery]</code> shortcode to have the Featured Image override the native thimbnail:
|
472 |
+
</p>
|
473 |
+
<table>
|
474 |
+
<tr>
|
475 |
+
<td class="mla-doc-table-label">mla_use_featured</td>
|
476 |
+
<td>set to "true" to substitute Featured Images for items which have a native thumbnail. The default value is "false"; native thumbnails will always be used when present.</td>
|
477 |
+
</tr>
|
478 |
+
</table>
|
479 |
+
<p>
|
480 |
WordPress 4.7 added thumbnail generation for PDF documents, and these "native thumbnail images" will automatically be used when available. You can also use MLA's thumbnail generation support (in the Media/Assistant Bulk Actions) to create native thumbnails for older documents.
|
481 |
</p>
|
482 |
<p>
|
483 |
+
The <code>mla_viewer</code> solution supports dynamic thumbnail image generation for PDF and Postscript documents on your site's server. The dynamic thumbnail image generation uses the PHP <code>Imagick</code> class, which <strong>requires ImageMagick and Ghostscript</strong> to be installed on your server. If you need help installing them, look at this <a href="https://wordpress.org/support/topic/nothing-but-error-messages" title="Help with installation" target="_blank">PDF Thumbnails support topic</a>. If you don't have them on your server you can still use the Featured Image support to supply thumbnails for your non-image items.
|
484 |
</p>
|
485 |
<p>
|
486 |
Ten <code>[mla_gallery]</code> parameters provide an easy way to simulate thumbnail images for the non-image file types.
|
1150 |
</table>
|
1151 |
<p>
|
1152 |
These five parameters always use the "Uploaded on" date, stored in the <code>post_date</code> column of the <code>wp_posts</code> database table. Remember to use <code>post_parent=current</code> if you want to restrict your query to items attached to the current post.
|
1153 |
+
</p>
|
1154 |
+
<p>
|
1155 |
+
You can use the <code>current_timestamp</code>, <code>current_datetime</code> and <code>current_getdate</code> field-level data sources to, for example, return items uploaded in the current year. Code something like <code>year="{+current_timestamp,timestamp( Y )+}"</code>.
|
1156 |
<a name="date_queries"></a>
|
1157 |
</p>
|
1158 |
<h4>Date and Time Queries, the "date query"</h4>
|
1166 |
When embedding the shortcode in the body of a post, be very careful when coding the date_query; it must be a valid PHP array specification. Read and follow the rules and guidelines in the "<a href="#complex_shortcodes">Entering Long/Complex Shortcodes</a>" Documentation section to get the results you want.
|
1167 |
</p>
|
1168 |
<p>
|
1169 |
+
You can use the <code>current_timestamp</code>, <code>current_datetime</code> and <code>current_getdate</code> field-level data sources to, for example, return items uploaded in the current month. Code something like:
|
1170 |
+
</p>
|
1171 |
+
<p>
|
1172 |
+
<code>[mla_gallery]<br />
|
1173 |
+
date_query="array(<br />
|
1174 |
+
array(<br />
|
1175 |
+
'year' => {+current_timestamp,timestamp( Y )+},<br />
|
1176 |
+
'month' => {+current_timestamp,timestamp( m )+},<br />
|
1177 |
+
),<br />
|
1178 |
+
)"<br />
|
1179 |
+
[/mla_gallery]
|
1180 |
+
</code>
|
1181 |
+
</p>
|
1182 |
+
<p>
|
1183 |
Remember to use <code>post_parent=current</code> if you want to restrict your query to items attached to the current post.
|
1184 |
<a name="custom_field_parameters"></a>
|
1185 |
</p>
|
3304 |
<code>
|
3305 |
<form id="mla-text-form" action="." method="post" class="row"><br />
|
3306 |
<strong>Att. Categories</strong><br />
|
3307 |
+
[mla_term_list post_mime_type=image taxonomy=attachment_category mla_output=dropdown mla_option_value="{+slug+}" show_count=true pad_counts=false ]<br />
|
3308 |
<br />
|
3309 |
<input id="text-form-submit" name="text_form_submit" type="submit" value="Search" /><br />
|
3310 |
</form><br />
|
3813 |
</p>
|
3814 |
<h3>Support for Other Gallery-generating Shortcodes</h3>
|
3815 |
<p>
|
3816 |
+
The <code>[mla_gallery]</code> shortcode can be used in combination with other gallery-generating shortcodes to give you the data selection power of <code>[mla_gallery]</code> and the formatting/display power of popular alternatives such as the WordPress.com Jetpack Carousel and Tiled Galleries modules. Any shortcode that accepts "ids=" or a similar parameter listing the attachment ID values for the gallery can be used. The <code>[mla_gallery]</code> code will compile the list of attachments for your gallery, then hand control over to the alternate shortcode to format the results. Note that MLA does not play any role in formatting the gallery display, so MLA-specific parameters such as <code>mla_caption</code> and <code>mla_link_href</code> are not processed. Five parameters implement this feature:
|
3817 |
</p>
|
3818 |
<table>
|
3819 |
<tr>
|
3899 |
The <a href="http://wordpress.org/extend/plugins/photonic/" title="Photonic Gallery plugin directory page" target="_blank">Photonic Gallery for Flickr, Picasa, SmugMug, 500px and Instagram</a> plugin adds several new parameters to the <code>[mla_gallery]</code> shortcode to enhance your galleries. All you have to do is install the plugin, then add a "style=" parameter to your <code>[mla_gallery]</code> shortcode to use the Photonic styling and markup in place of the native <code>[mla_gallery]</code> style and markup templates.
|
3900 |
</p>
|
3901 |
<p>
|
3902 |
+
You can use the "Photonic" screen of the Insert Media dialog to build the display portion of your shortcode parameters. After you click "Insert into post", change the shortcode name from "gallery" to "mla_gallery" and add the query parameters you need to select the attachments for the gallery. The <code>[mla_gallery]</code> code will compile the list of attachments for your gallery, then hand control over to Photonic to format the results. Note that MLA does not play any role in formatting the gallery display, so MLA-specific parameters such as <code>mla_caption</code> and <code>mla_link_href</code> are not processed.
|
3903 |
<a name="real_media_library"></a>
|
3904 |
</p>
|
3905 |
<p>
|
4668 |
</tr>
|
4669 |
<tr>
|
4670 |
<td class="mla-doc-table-label" style="white-space:nowrap">,timestamp(f,m)</td>
|
4671 |
+
<td>Many date and time values such as <code>[+meta:image_meta.created_timestamp+]</code> are stored as a UNIX timestamp. The ",timestamp" format converts a timestamp into a variety of date and/or time string formats, using the PHP <code>date()</code> function. Details on the "f" (format string) argument can be found at: <a href="https://www.php.net/manual/en/datetime.format.php" title="PHP Date format parameter valuess" target="_blank">http://php.net/manual/en/datetime.format.php</a>.<br /> <br />The default format string is "d/m/Y H:i:s", e.g., "31/12/2014 23:59:00" (just before midnight on new year's eve). You could code <code>[+meta:image_meta.created_timestamp,timestamp('j F, Y')+]</code> to display "31 December, 2014".<br /> <br />The "m" (modifier) argument is optional. If present and set to "i18n" the displayed value will be localized using the site's locale value.<br /> <br />If the "m" (modifier) argument is set to "age" it will return a human-readable difference between the source value and the current date/time. In this case you must also code "%s" in the format string, e.g., <code>[+meta:image_meta.created_timestamp,timestamp('%s ago')+]</code> to display something like "2 months ago".</td>
|
4672 |
</tr>
|
4673 |
<tr>
|
4674 |
<td class="mla-doc-table-label" style="white-space:nowrap">,date(f,m)</td>
|
4675 |
+
<td>Many EXIF date and time values such as DateTimeOriginal and DateTimeDigitized are stored as strings with a format of "YYYY:MM:DD HH:MM:SS". You can parse this format and just about any English textual datetime description into a Unix timestamp, then format the result by using the ",date" format. This format first uses the PHP <code>strtotime()</code> function, then the <code>date()</code> function. Details on the "f" (format string) argument can be found at: <a href="https://www.php.net/manual/en/datetime.format.php" title="PHP Date format parameter values" target="_blank">http://php.net/manual/en/datetime.format.php</a>.<br /> <br />The default "f" (format string) argument is "d/m/Y H:i:s", e.g., "31/12/2014 23:59:00" (just before midnight on new year's eve). You could code <code>[+exif:DateTimeOriginal,date('j F, Y')+]</code> to display "31 December, 2014".<br /> <br />The "m" (modifier) argument is optional. If present and set to "i18n" the displayed value will be localized using the site's locale value.<br /> <br />If the "m" (modifier) argument is set to "age" it will return a human-readable difference between the source value and the current date/time. In this case you must also code "%s" in the format string, e.g., <code>[+exif:DateTimeOriginal,date('%s ago')+]</code> to display something like "2 months ago".</td>
|
4676 |
</tr>
|
4677 |
</table>
|
4678 |
<p>
|
4971 |
</tr>
|
4972 |
<tr>
|
4973 |
<td class="mla-doc-table-label">featured_in</td>
|
4974 |
+
<td>the title, post/page type and id number of each post/page for which this item is the "Featured Image"</td>
|
4975 |
</tr>
|
4976 |
<tr>
|
4977 |
<td class="mla-doc-table-label">featured_in_title</td>
|
4978 |
+
<td>the title of each post/page for which this item is the "Featured Image"</td>
|
4979 |
</tr>
|
4980 |
<tr>
|
4981 |
<td class="mla-doc-table-label">inserted_in</td>
|
6061 |
</p>
|
6062 |
<table>
|
6063 |
<tr>
|
6064 |
+
<td class="mla-doc-hook-label">mla_list_table_help_template</td>
|
6065 |
+
<td class="mla-doc-hook-definition">Gives you an opportunity to modify the pull-down Help menu on the Media/Assistant screen.</td>
|
6066 |
+
</tr>
|
6067 |
+
<tr>
|
6068 |
+
<td class="mla-doc-hook-label">mla_list_table_admin_action</td>
|
6069 |
+
<td class="mla-doc-hook-definition">Gives you an opportunity to pre-process an MLA_List_Table item-level action, standard or custom, before the MLA handler. This filter is called before anything is output for the Media/Assistant submenu, so you can redirect to another admin screen if desired.</td>
|
6070 |
+
</tr>
|
6071 |
+
<tr>
|
6072 |
+
<td class="mla-doc-hook-label">mla_list_table_custom_admin_action</td>
|
6073 |
+
<td class="mla-doc-hook-definition">Gives you an opportunity to process an MLA_List_Table item-level action that MLA does not recognize. This filter is called before anything is output for the Media/Assistant submenu, so you can redirect to another admin screen if desired.</td>
|
6074 |
+
</tr>
|
6075 |
+
<tr>
|
6076 |
<td class="mla-doc-hook-label">mla_list_table_inline_fields</td>
|
6077 |
<td class="mla-doc-hook-definition">Gives you an opportunity to name the fields passed to the JavaScript functions for Quick editing.</td>
|
6078 |
</tr>
|
6105 |
<td class="mla-doc-hook-definition">Gives you an opportunity to post-process an MLA_List_Table bulk action, standard or custom. The filter is called once after all of the items in $_REQUEST['cb_attachment'] are processed.</td>
|
6106 |
</tr>
|
6107 |
<tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6108 |
<td class="mla-doc-hook-label">mla_list_table_single_action</td>
|
6109 |
<td class="mla-doc-hook-definition">Gives you an opportunity to pre-process an MLA_List_Table item-level action, standard or custom, before the MLA handler. This filter is called after the Media/Assistant submenu screen header is output but before the messages and submenu table are displayed.</td>
|
6110 |
</tr>
|
6138 |
</p>
|
6139 |
<table>
|
6140 |
<tr>
|
6141 |
+
<td class="mla-doc-hook-label">mla_list_table_inline_blank_fieldset_values,<br />
|
6142 |
+
mla_list_table_inline_initial_fieldset_values,<br />
|
6143 |
+
mla_list_table_inline_preset_fieldset_values
|
6144 |
+
</td>
|
6145 |
+
<td class="mla-doc-hook-definition">Give you a chance to modify the data values that populate the Bulk Edit form.</td>
|
6146 |
+
</tr>
|
6147 |
+
<tr>
|
6148 |
<td class="mla-doc-hook-label">mla_list_table_inline_blank_values,<br />
|
6149 |
mla_list_table_inline_initial_values,<br />
|
6150 |
mla_list_table_inline_preset_values
|
6209 |
</tr>
|
6210 |
<tr>
|
6211 |
<td class="mla-doc-hook-label">mla_list_table_prepare_items</td>
|
6212 |
+
<td class="mla-doc-hook-definition">Gives you an opportunity to record or modify the results of the prepare_items database query.</td>
|
6213 |
</tr>
|
6214 |
<tr>
|
6215 |
<td class="mla-doc-hook-label">mla_list_table_build_rollover_actions</td>
|
6246 |
</p>
|
6247 |
<table>
|
6248 |
<tr>
|
6249 |
+
<td class="mla-doc-hook-label">mla_upload_bulk_edit_form_blank_fieldset_values,<br />
|
6250 |
+
mla_upload_bulk_edit_form_initial_fieldset_values,<br />
|
6251 |
+
mla_upload_bulk_edit_form_preset_fieldset_values
|
6252 |
+
</td>
|
6253 |
+
<td class="mla-doc-hook-definition">Give you a chance to modify the data values that populate the Bulk Edit form.</td>
|
6254 |
+
</tr>
|
6255 |
+
<tr>
|
6256 |
<td class="mla-doc-hook-label">mla_upload_bulk_edit_form_blank_values,<br />
|
6257 |
mla_upload_bulk_edit_form_initial_values,<br />
|
6258 |
mla_upload_bulk_edit_form_preset_values
|
6342 |
<td class="mla-doc-table-label">mla_media_modal_query_filtered_terms</td>
|
6343 |
<td class="mla-doc-hook-definition">Change the terms of the Media Manager Modal Window "Query Attachments" query after they are pre-processed by the AJAX handler</td>
|
6344 |
</tr>
|
6345 |
+
<tr>
|
6346 |
+
<td class="mla-doc-table-label">mla_media_modal_query_items</td>
|
6347 |
+
<td class="mla-doc-hook-definition">Record or modify the results of the "mla_query_media_modal_items" query</td>
|
6348 |
+
</tr>
|
6349 |
</table>
|
6350 |
<p>
|
6351 |
The following hooks are defined in <code>/wp-admin/includes/class-mla-data-query.php</code>:
|
6704 |
If you just want to add a custom field to the Media/Assistant submenu, the quick edit area and/or the bulk edit area you can bypass the mapping logic by leaving the Data Source value as "-- None (select a value) --".
|
6705 |
<br /> <br />
|
6706 |
Most of the data elements are static, i.e., they do not change after the attachment is added to the Media Library.
|
6707 |
+
The parent/reference information (parent_type, parent_title, parent_issues, reference_issues) and the "where-used" information (featured in, inserted in, gallery in and MLA gallery in) is dynamic; it will change as you define galleries, insert images in posts, define Featured Images, etc. Because of the database processing required to update this information, <strong><em>parent, where-used and reference data are NOT automatically refreshed</em></strong>. If you use these elements, you must manually refresh them with the "map data" buttons on the Settings screen, the bulk edit area or the Edit Media screen.
|
6708 |
<br /> <br />
|
6709 |
Several of the data elements are sourced from the WordPress "image_meta" array. The credit, caption, copyright and title elements are taken from the IPTC/EXIF metadata (if any), but they go through a number of filtering rules that are not easy to replicate with the MLA IPTC/EXIF processing rules. You may find these "image_meta" elements more useful than the raw IPTC/EXIF metadata.
|
6710 |
</dd>
|