diff --git a/src/classes/repositories/class-tainacan-items.php b/src/classes/repositories/class-tainacan-items.php index 8d8369cfc..bd255e3ca 100644 --- a/src/classes/repositories/class-tainacan-items.php +++ b/src/classes/repositories/class-tainacan-items.php @@ -525,14 +525,14 @@ class Items extends Repository { * @return bool */ public function hook_comments_open($open_comment, $post_id) { - $item = self::get_entity_by_post($post_id); + $item = self::get_entity_by_post($post_id); - if($item != false && $item instanceof Entities\Item) { - $collection = $item->get_collection(); - if( $collection->get_allow_comments() !== 'open' ) return false; - } + if($item != false && $item instanceof Entities\Item) { + $collection = $item->get_collection(); + if( $collection != null && $collection->get_allow_comments() !== 'open' ) return false; + } - return $open_comment; + return $open_comment; } /** diff --git a/src/classes/traits/class-tainacan-entity-collection-relation.php b/src/classes/traits/class-tainacan-entity-collection-relation.php index 572800f02..a36628de6 100644 --- a/src/classes/traits/class-tainacan-entity-collection-relation.php +++ b/src/classes/traits/class-tainacan-entity-collection-relation.php @@ -36,6 +36,19 @@ trait Entity_Collection_Relation { if($this->collection instanceof Entities\Collection){ return $this->collection; } + } else { + $post = get_post($this->get_id()); + if (!$post || !$post->post_type) + return null; + $post_type = $post->post_type; + $matches = array(); + $regex = '/' . Collection::$db_identifier_prefix . '([a-zA-Z0-9_]*)' . Collection::$db_identifier_sufix . '/'; + preg_match($regex, $post_type, $matches); + $collection_id = $matches[1]; + if (is_numeric($collection_id)) { + $this->set_collection_id($collection_id); + return $this->get_collection(); + } } return null; diff --git a/src/views/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme-unit.vue b/src/views/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme-unit.vue index d6377fb09..8755a4bb6 100644 --- a/src/views/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme-unit.vue +++ b/src/views/gutenberg-blocks/tainacan-facets/facets-list/facets-list-theme-unit.vue @@ -110,7 +110,7 @@

- {{ $root.__( 'This facet children terms do not contain items.', 'tainacan' ) }} + {{ $root.__( 'The child terms of this facet do not contain items.', 'tainacan' ) }}

diff --git a/src/views/gutenberg-blocks/tainacan-facets/facets-list/index.js b/src/views/gutenberg-blocks/tainacan-facets/facets-list/index.js index ab2828670..2d811132e 100644 --- a/src/views/gutenberg-blocks/tainacan-facets/facets-list/index.js +++ b/src/views/gutenberg-blocks/tainacan-facets/facets-list/index.js @@ -311,7 +311,7 @@ registerBlockType('tainacan/facets-list', { return prepareFacet(aChildTermFacet); }) : -

{ __( 'This facet children terms do not contain items.', 'tainacan' )}

+

{ __( 'The child terms of this facet do not contain items.', 'tainacan' )}

} : null ) diff --git a/tests/bin/install-wp-tests.sh b/tests/bin/install-wp-tests.sh index c78371036..ef94343ea 100755 --- a/tests/bin/install-wp-tests.sh +++ b/tests/bin/install-wp-tests.sh @@ -91,6 +91,7 @@ install_test_suite() { sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "$ a if ( ! defined( 'WP_RUN_CORE_TESTS' ) ) define('WP_RUN_CORE_TESTS', false);" "$WP_TESTS_DIR"/wp-tests-config.php fi }