@bev,
Hmm. There was a major change to how the query was made. In prior version it was using older style queries. In 3.2 the queries are called via WP_Query for efficiency.
A couple of options.
1. Revert back to 3.1.2.1 and go along your way. I personally don’t want that. I want to see if this is just your issue or related to the changes
2. Try settings the following define in your wp-config.php. This will allow Media-Tags to used the old legacy query method. If this works then we need to discuss the exact use of the Media-Tags plugin within your system so I can figure out how to replicate your issue.
Add this to your wp-config.php
define(‘MEDIA_TAGS_QUERY’, ‘legacy’);
Thread Starter
Bev
(@bstofko)
It turns out the problem is that you no longer call wp_parse_args in get_attachments_by_media_tags, so the args passed in are not parsed correctly.
@bev,
Not exactly. The function get_attachments_by_media_tags() (media_tags.php line 134) is really just an intermediate function. Depending on the query type setting that function will then call either get_attachments_by_media_tags_query() or get_attachments_by_media_tags_legacy(). Within those secondary function is where wp_parse_arge() is called.
From media_tags.php lines 161-165
if ((strtolower($args['query']) == 'wp_query')) {
return $this->get_attachments_by_media_tags_query($args);
} else if ((strtolower($args['query']) == 'legacy')) {
return $this->get_attachments_by_media_tags_legacy($args);
}
The query type defaults to ‘wp_query’ which is the new logic. As I asked from my previous post you can use the legacy query type by adding the following to your wp-config.php
define(‘MEDIA_TAGS_QUERY’, ‘legacy’);
Thread Starter
Bev
(@bstofko)
On second look, I see there is code that attempts to set $args[‘query’]. However, this doesn’t work when passed in an arg string requiring parsing. If I invoke the debug statement to display $args, it shows the passed in string.
Thread Starter
Bev
(@bstofko)
I can fix it by changing the get_attachments_by_media_tags() function to the following code:
function get_attachments_by_media_tags($args='')
{
$r = wp_parse_args( $args );
if ((!isset($r['query'])) || (empty($r['query']))) {
if (defined('MEDIA_TAGS_QUERY')) {
$r['query'] = MEDIA_TAGS_QUERY;
} else {
$r['query'] = 'wp_query';
}
}
//echo "args<pre>"; print_r($args); echo "</pre>";
if ((strtolower($r['query']) == 'wp_query')) {
return $this->get_attachments_by_media_tags_query($args);
} else if ((strtolower($r['query']) == 'legacy')) {
return $this->get_attachments_by_media_tags_legacy($args);
}
}
@bev,
Oh I guess you are correct. My fault. Will have this patched later today. Thanks.
@bev,
Thanks for the code suggestion. I think it is better and cleaner to move the wp_parse_args logic form the two secondary function and only need to large the args once.
Here is a beta with the patched code. Thanks
https://dl.dropboxusercontent.com/u/2616987/projects/wp-plugins/media-tags/media-tags-3.2.0.1-Beta1.zip