From 57316126bcd5899e1d99f249bb92eb904e1e6481 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Tue, 26 Sep 2023 10:21:54 -0300 Subject: [PATCH 1/5] Sets maximum size for search bar in desktop. --- .../blocks/faceted-search/theme-search/scss/_layout.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss index fcff907eb..8ab017360 100644 --- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss +++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss @@ -151,8 +151,8 @@ } } .search-control .search-control-item .search-area { - min-width: 13.75%; - min-width: 13.75vw; + min-width: calc(min(13.75%, 280px)); + min-width: calc(min(13.75vw, 280px)); } } From 47b53631f1a673a0b413af2a91eca8951ea5c2e6 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Mon, 2 Oct 2023 10:49:18 -0300 Subject: [PATCH 2/5] Add filter to set the thumbnail placeholder. #319. --- src/classes/theme-helper/template-tags.php | 10 +++++++++- src/views/admin/js/utilities.js | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/classes/theme-helper/template-tags.php b/src/classes/theme-helper/template-tags.php index e6c00ebeb..24bb34936 100644 --- a/src/classes/theme-helper/template-tags.php +++ b/src/classes/theme-helper/template-tags.php @@ -1019,7 +1019,15 @@ function tainacan_get_the_mime_type_icon($mime_type, $image_size = 'medium') { $icon_file = 'placeholder_square'; } - return $images_path . $icon_file . $image_size . '.png'; + /** + * Filter the image source for the empty thumbnail placeholder. + * + * @param string src The image source for the empty thumbnail placeholder. + * Default is 'placeholder_square'. + * @param string mime_type The document type of the item. + * @param string image_size The size of the image to be loaded. + */ + return apply_filters('tainacan-get-the-mime-type-icon', $images_path . $icon_file . $image_size . '.png', $mime_type, $image_size); } /** diff --git a/src/views/admin/js/utilities.js b/src/views/admin/js/utilities.js index 61c9b6345..fc7b8437d 100644 --- a/src/views/admin/js/utilities.js +++ b/src/views/admin/js/utilities.js @@ -72,7 +72,15 @@ export const ThumbnailHelperFunctions = () => { imageSrc = 'placeholder_square'; } - return this.getEmptyThumbnailPlaceholderBySize(imageSrc, tainacanSize); + /** + * Filter the image source for the empty thumbnail placeholder. + * + * @param string imageSrc The image source for the empty thumbnail placeholder. + * Default is 'placeholder_square'. + * @param string documentType The document type of the item. + * @param string size The size of the image to be loaded. + */ + return wp.hooks.applyFilters('tainacan_get_the_mime_type_icon', this.getEmptyThumbnailPlaceholderBySize(imageSrc, tainacanSize), documentType, tainacanSize); }, getEmptyThumbnailPlaceholderBySize(imageSrc, tainacanSize) { switch(tainacanSize) { From 16434d07199a4da4b1a7db9fbbe0129614860225 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Tue, 3 Oct 2023 09:07:31 -0300 Subject: [PATCH 3/5] fix: remove the sanitize text file name on 404 `template_redirect` --- src/classes/class-tainacan-private-files.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classes/class-tainacan-private-files.php b/src/classes/class-tainacan-private-files.php index 2402e64b6..c97ced581 100644 --- a/src/classes/class-tainacan-private-files.php +++ b/src/classes/class-tainacan-private-files.php @@ -191,7 +191,7 @@ class Private_Files { $upload_dir = wp_get_upload_dir(); $base_upload_url = preg_replace('/^https?:\/\//', '', $upload_dir['baseurl']); - $requested_uri = sanitize_text_field($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); + $requested_uri = ($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); if ( strpos($requested_uri, $base_upload_url) === false ) { // Not uploads @@ -228,7 +228,7 @@ class Private_Files { if ( !$existing_file && \file_exists( $prefixed_both ) ) { $existing_file = $prefixed_both; } - + echo "-----------> $file
$prefixed_file
$prefixed_collection $prefixed_both: $existing_file"; if ($existing_file) { $item = \Tainacan\Repositories\Items::get_instance()->fetch( (int) $item_id, (int) $collection_id ); From c33270e22e8fecd02818a20746806f1701aad570 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Tue, 3 Oct 2023 09:09:08 -0300 Subject: [PATCH 4/5] fix: add the TAINACAN_INDEX_PDF_CONTENT in public search --- src/classes/class-tainacan-media.php | 12 +++++------- src/classes/class-tainacan-search-engine.php | 8 +++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/classes/class-tainacan-media.php b/src/classes/class-tainacan-media.php index 75890920b..d0623f1f3 100644 --- a/src/classes/class-tainacan-media.php +++ b/src/classes/class-tainacan-media.php @@ -7,10 +7,11 @@ namespace Tainacan; class Media { private static $instance = null; - private static $file_handle = null; private static $file_name = null; private $attachment_html_url_base = 'tainacan_attachment_html'; + public static $content_index_meta = 'document_content_index'; + public static function get_instance() { if(!isset(self::$instance)) { self::$instance = new self(); @@ -246,10 +247,8 @@ class Media { return; } - $content_index_meta = 'document_content_index'; - if ($file == null) { - $meta_id = update_post_meta( $item_id, $content_index_meta, null ); + update_post_meta( $item_id, SELF::$content_index_meta, null ); return true; } @@ -274,9 +273,8 @@ class Media { $wp_charset = get_bloginfo('charset'); $content_charset = mb_detect_encoding($content); $content = mb_convert_encoding($content, $wp_charset, $content_charset); - - $meta_id = update_post_meta( $item_id, $content_index_meta, $content ); - } catch(Exception $e) { + update_post_meta( $item_id, SELF::$content_index_meta, $content ); + } catch(\Exception $e) { error_log('Caught exception: ' . $e->getMessage() . "\n"); return false; } diff --git a/src/classes/class-tainacan-search-engine.php b/src/classes/class-tainacan-search-engine.php index 05e8ea7e2..2fcdf86ee 100644 --- a/src/classes/class-tainacan-search-engine.php +++ b/src/classes/class-tainacan-search-engine.php @@ -176,10 +176,16 @@ class Search_Engine { $seperator = ' OR '; } if ( empty($search_meta_query) ) return ''; + + $content_index_meta = ''; + if ( defined('TAINACAN_INDEX_PDF_CONTENT') && true === TAINACAN_INDEX_PDF_CONTENT ) { + $content_index_meta_meta_key = \TAINACAN\Media::$content_index_meta; + $content_index_meta = "OR (m.meta_key='{$content_index_meta_meta_key}')"; + } $join = \is_user_logged_in() ? '' - : " INNER JOIN $wpdb->posts pmeta ON m.meta_key = pmeta.ID AND pmeta.post_status = 'publish'"; + : " INNER JOIN $wpdb->posts pmeta ON (m.meta_key = pmeta.ID AND pmeta.post_status = 'publish') $content_index_meta"; return "EXISTS ( SELECT m.post_id FROM $wpdb->postmeta m $join From cd44dc5bcae814c4f61e3e9112edeae512f8f0e6 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Tue, 3 Oct 2023 10:04:36 -0300 Subject: [PATCH 5/5] fix: get `comment_status` for item --- src/classes/entities/class-tainacan-item.php | 16 ++++++++++------ .../repositories/class-tainacan-items.php | 12 ++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index ede1a2681..0ce9e8ae5 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -307,7 +307,9 @@ class Item extends Entity { * @return string "open"|"closed" */ public function get_comment_status() { - return apply_filters('tainacan-item-comments_open', $this->get_mapped_property('comment_status'), $this->get_id()); + $comment_status = $this->get_mapped_property('comment_status'); + $comment_status_filtered = apply_filters('comments_open', $comment_status == 'open', $this->get_id()) == true ? 'open' : 'closed'; + return $comment_status_filtered; } /** @@ -1183,13 +1185,15 @@ class Item extends Entity { if ( $metadata_section->is_conditional_section() ) { $rules = $metadata_section->get_conditional_section_rules(); - $item_id = $this->get_id(); + if( !empty($rules) ) { + $item_id = $this->get_id(); - foreach ( $rules as $meta_id => $meta_values_conditional ) { + foreach ( $rules as $meta_id => $meta_values_conditional ) { - $meta_values = get_post_meta( $item_id, $meta_id ); - if (!array_intersect($meta_values, $meta_values_conditional)) - return $return; + $meta_values = get_post_meta( $item_id, $meta_id ); + if (!array_intersect($meta_values, $meta_values_conditional)) + return $return; + } } } diff --git a/src/classes/repositories/class-tainacan-items.php b/src/classes/repositories/class-tainacan-items.php index 0f18e3aef..9b7d4fa5e 100644 --- a/src/classes/repositories/class-tainacan-items.php +++ b/src/classes/repositories/class-tainacan-items.php @@ -26,7 +26,7 @@ class Items extends Repository { protected function __construct() { parent::__construct(); - add_filter( 'tainacan-item-comments_open', [$this, 'hook_comments_open'], 10, 2); + add_filter( 'comments_open', [$this, 'hook_comments_open'], 10, 2); add_action( 'tainacan-api-item-updated', array( &$this, 'hook_api_updated_item' ), 10, 2 ); add_filter( 'map_meta_cap', array( $this, 'map_meta_cap' ), 10, 4 ); } @@ -582,19 +582,19 @@ class Items extends Repository { /** * Return if comment are open for this item (post_id) and the collection too * - * @param string $open_comment + * @param bool $comments_open * @param integer $post_id Item id - * @return string + * @return bool */ - public function hook_comments_open($open_comment, $post_id) { + public function hook_comments_open($comments_open, $post_id) { $item = self::get_entity_by_post($post_id); if($item != false && $item instanceof Entities\Item) { $collection = $item->get_collection(); - if( $collection != null && $collection->get_allow_comments() !== 'open' ) return 'closed'; + if( $collection != null && $collection->get_allow_comments() !== 'open' ) return false; } - return $open_comment; + return $comments_open; } /**