new file: olm-login.php
This commit is contained in:
@@ -111,7 +111,18 @@ final class PageRepository
|
||||
|
||||
public function findFrontendPage(string $productSlug, string $versionSlug, string $pageSlug): ?\WP_Post
|
||||
{
|
||||
return $this->findFrontendPageInProducts([$productSlug], $versionSlug, $pageSlug);
|
||||
}
|
||||
|
||||
public function findFrontendPageInProducts(array $productSlugs, string $versionSlug, string $pageSlug): ?\WP_Post
|
||||
{
|
||||
$productSlugs = array_values(array_filter(array_map('sanitize_title', $productSlugs)));
|
||||
$pageSlug = $pageSlug ?: '';
|
||||
|
||||
if (! $productSlugs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$query = new \WP_Query([
|
||||
'post_type' => 'kb_doc_page',
|
||||
'post_status' => 'publish',
|
||||
@@ -119,10 +130,12 @@ final class PageRepository
|
||||
'no_found_rows' => true,
|
||||
'meta_query' => [
|
||||
'relation' => 'AND',
|
||||
['key' => '_kb_product_slug', 'value' => $productSlug],
|
||||
['key' => '_kb_version_slug', 'value' => $versionSlug],
|
||||
['key' => '_kb_page_slug', 'value' => $pageSlug],
|
||||
],
|
||||
'tax_query' => [
|
||||
['taxonomy' => 'kb_product', 'field' => 'slug', 'terms' => $productSlugs],
|
||||
],
|
||||
]);
|
||||
|
||||
return $query->have_posts() ? $query->posts[0] : null;
|
||||
|
||||
Reference in New Issue
Block a user