-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed the bug related to mime_type on ajax request #4
Conversation
larodiel
commented
Nov 9, 2023
- Added the languages pt_BR and es_ES
- Fixed the bug where the library on AJAX requests was broking because it was expecting a string and the server was returning an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @larodiel - please find my feedback from the comment.
$mime_types = is_array( $vars['post_mime_type'] ) ? $vars['post_mime_type'] : [ $vars['post_mime_type'] ]; | ||
$like_clauses = array(); | ||
|
||
foreach( $mime_types as $mime_type ) { | ||
$mime_type_like = '%' . $wpdb->esc_like( $mime_type ) . '%'; | ||
$like_clauses[] = "$wpdb->posts.post_mime_type LIKE '$mime_type_like'"; | ||
} | ||
|
||
$pieces['where'] .= " AND (" . implode( ' OR ', $like_clauses ) . ")"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the indents here a bit off?
Also, mind if changing $like_clauses[] = "$wpdb->posts.post_mime_type LIKE '$mime_type_like'";
to use $wpdb->prepare()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yoren
prepare has been added and indentation fixed.
Would be great if we had a .editorconfig
or prettier file to keep the pattern .prettierrc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I'll do some test and merge if no further issues + do the release to wp.org over the weekend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@larodiel Thanks! Can you give me an example that when will the post_mime_type
be an array? The default Media Library doesn't seem to have an UI to make it so. I wanted to make it clear in the change log or also add some information in README.
@yoren When the user add an image using the Gutenberg block |
@larodiel Thanks - that information was very valuable! If you have a wp.org account, feel free to add yourself to the "Contributors" list in README. I'll release 0.8.2 soon |
Hey @larodiel - It's been a while but I finally published the new release today. Thank you! |