Merge branch 'develop' into 447-prevent-xss

This commit is contained in:
vnmedeiros 2021-03-23 08:42:02 -03:00
commit 59c0a9e658
5 changed files with 22 additions and 8 deletions

View File

@ -525,14 +525,14 @@ class Items extends Repository {
* @return bool * @return bool
*/ */
public function hook_comments_open($open_comment, $post_id) { 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) { if($item != false && $item instanceof Entities\Item) {
$collection = $item->get_collection(); $collection = $item->get_collection();
if( $collection->get_allow_comments() !== 'open' ) return false; if( $collection != null && $collection->get_allow_comments() !== 'open' ) return false;
} }
return $open_comment; return $open_comment;
} }
/** /**

View File

@ -36,6 +36,19 @@ trait Entity_Collection_Relation {
if($this->collection instanceof Entities\Collection){ if($this->collection instanceof Entities\Collection){
return $this->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; return null;

View File

@ -110,7 +110,7 @@
<p <p
v-else v-else
class="no-child-facet-found"> class="no-child-facet-found">
{{ $root.__( 'This facet children terms do not contain items.', 'tainacan' ) }} {{ $root.__( 'The child terms of this facet do not contain items.', 'tainacan' ) }}
</p> </p>
</ul> </ul>
</transition> </transition>

View File

@ -311,7 +311,7 @@ registerBlockType('tainacan/facets-list', {
return prepareFacet(aChildTermFacet); return prepareFacet(aChildTermFacet);
}) })
: :
<p class="no-child-facet-found">{ __( 'This facet children terms do not contain items.', 'tainacan' )}</p> <p class="no-child-facet-found">{ __( 'The child terms of this facet do not contain items.', 'tainacan' )}</p>
} }
</ul> </ul>
: null ) : null )

View File

@ -91,6 +91,7 @@ install_test_suite() {
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php 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/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 "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 fi
} }