Skip to content
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

Merged
merged 2 commits into from Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.txt
@@ -1,11 +1,11 @@
=== Media Search Enhanced ===

Contributors: 1fixdotio
Donate link: http://1fix.io/
Donate link: https://1fix.io/
Tags: media library, media, attachment
Requires at least: 3.5
Tested up to: 6.1.1
Stable tag: 0.8.1
Tested up to: 6.3.2
Stable tag: 0.8.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -65,6 +65,9 @@ Please add the following code to the `functions.php` in your theme:

== Changelog ==

= 0.8.2 =
* Fix issue where `post_mime_type` was an array

= 0.8.1 =
* Fix PHP notices and updated the "Tested up to" field.

Expand Down
Binary file added languages/media-search-enhanced-es_ES.mo
Binary file not shown.
45 changes: 45 additions & 0 deletions languages/media-search-enhanced-es_ES.po
@@ -0,0 +1,45 @@
msgid ""
msgstr ""
"Project-Id-Version: Media Search Enhanced\n"
"POT-Creation-Date: 2023-11-09 19:41-0300\n"
"PO-Revision-Date: 2023-11-09 20:31-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.1\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
"X-Poedit-WPHeader: media-search-enhanced.php\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
"_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: *.min.js\n"

#: public/class-media-search-enhanced.php:234
msgid "Search Media..."
msgstr "Buscar medios..."

#. Plugin Name of the plugin/theme
msgid "Media Search Enhanced"
msgstr "Media Search Enhanced"

#. Plugin URI of the plugin/theme
msgid "https://1fix.io/media-search-enhanced"
msgstr "https://1fix.io/media-search-enhanced"

#. Description of the plugin/theme
msgid "Search through all fields in Media Library."
msgstr "Busque en todos los campos de la biblioteca multimedia."

#. Author of the plugin/theme
msgid "1fixdotio"
msgstr "1fixdotio"

#. Author URI of the plugin/theme
msgid "https://1fix.io"
msgstr "https://1fix.io"
Binary file added languages/media-search-enhanced-pt_BR.mo
Binary file not shown.
45 changes: 45 additions & 0 deletions languages/media-search-enhanced-pt_BR.po
@@ -0,0 +1,45 @@
msgid ""
msgstr ""
"Project-Id-Version: Media Search Enhanced\n"
"POT-Creation-Date: 2023-11-09 19:39-0300\n"
"PO-Revision-Date: 2023-11-09 19:40-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.1\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
"X-Poedit-WPHeader: media-search-enhanced.php\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
"_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: *.min.js\n"

#: public/class-media-search-enhanced.php:234
msgid "Search Media..."
msgstr "Pesquisar Mídia..."

#. Plugin Name of the plugin/theme
msgid "Media Search Enhanced"
msgstr "Media Search Enhanced"

#. Plugin URI of the plugin/theme
msgid "https://1fix.io/media-search-enhanced"
msgstr "https://1fix.io/media-search-enhanced"

#. Description of the plugin/theme
msgid "Search through all fields in Media Library."
msgstr "Pesquise todos os campos na Biblioteca de Mídia."

#. Author of the plugin/theme
msgid "1fixdotio"
msgstr "1fixdotio"

#. Author URI of the plugin/theme
msgid "https://1fix.io"
msgstr "https://1fix.io"
12 changes: 7 additions & 5 deletions media-search-enhanced.php
Expand Up @@ -7,21 +7,23 @@
* @package Media_Search_Enhanced
* @author 1fixdotio <1fixdotio@gmail.com>
* @license GPL-2.0+
* @link http://1fix.io/media-search-enhanced
* @link https://1fix.io/media-search-enhanced
* @copyright 2014-19 1Fix.io
*
* @wordpress-plugin
* Plugin Name: Media Search Enhanced
* Plugin URI: http://1fix.io/media-search-enhanced
* Plugin URI: https://1fix.io/media-search-enhanced
* Description: Search through all fields in Media Library.
* Version: 0.8.1
* Version: 0.8.2
* Author: 1fixdotio
* Author URI: http://1fix.io
* Author URI: https://1fix.io
* Text Domain: media-search-enhanced
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
* GitHub Plugin URI: https://github.com/1fixdotio/media-search-enhanced
* Requires at least: 3.5
* Tested up to: 6.3.2
*/

// If this file is called directly, abort.
Expand Down
12 changes: 9 additions & 3 deletions public/class-media-search-enhanced.php
Expand Up @@ -161,9 +161,15 @@ public static function posts_clauses( $pieces ) {
}

if ( ! empty( $vars['post_mime_type'] ) ) {
// Use esc_like to escape slash
$like = '%' . $wpdb->esc_like( $vars['post_mime_type'] ) . '%';
$pieces['where'] .= $wpdb->prepare( " AND $wpdb->posts.post_mime_type LIKE %s", $like );
$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->prepare( "$wpdb->posts.post_mime_type LIKE %s", $mime_type_like );
}

$pieces['where'] .= " AND (" . implode( ' OR ', $like_clauses ) . ")";
}

if ( ! empty( $vars['m'] ) ) {
Expand Down