diff --git a/includes/class-partnerexpo-core-user-fields.php b/includes/class-partnerexpo-core-user-fields.php
new file mode 100644
index 0000000..425e0eb
--- /dev/null
+++ b/includes/class-partnerexpo-core-user-fields.php
@@ -0,0 +1,51 @@
+
+ */
+class Partnerexpo_Core_User_Fields {
+ public function activate_fields() {
+ add_action( 'show_user_profile', [$this, 'add_custom_user_fields'] );
+ add_action( 'edit_user_profile', [$this, 'add_custom_user_fields'] );
+ add_action( 'personal_options_update', [$this, 'save_custom_user_fields'] );
+ add_action( 'edit_user_profile_update', [$this, 'save_custom_user_fields'] );
+ add_action( 'user_register', [$this, 'add_value_after_reg'] );
+ }
+
+ public function add_custom_user_fields( $user ) {
+ $company = get_user_meta( $user->ID, 'company', true );
+ ?>
+
Additional Information
+
+ loader = new Partnerexpo_Core_Loader();
+ $user_fields = new Partnerexpo_Core_User_Fields();
+ $user_fields->activate_fields();
}
@@ -209,7 +219,7 @@ class Partnerexpo_Core {
'public' => true,
'has_archive' => false,
'show_in_rest' => true,
- 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt' ],
+ 'supports' => [ 'title', 'editor', 'thumbnail', 'excerpt', 'author' ],
'rewrite' => [
'slug' => __( 'partnerek', 'partnerexpo-core' ),
'pages' => false,
diff --git a/public/class-partnerexpo-core-public.php b/public/class-partnerexpo-core-public.php
index 3f97736..6e46607 100644
--- a/public/class-partnerexpo-core-public.php
+++ b/public/class-partnerexpo-core-public.php
@@ -70,6 +70,15 @@ class Partnerexpo_Core_Public {
$params['tags'] = str_replace(',', '+', $params['tags']);
}
+ $companies = explode(',', $params['companies'] ?? '');
+
+ $authors = get_users([
+ 'meta_key' => 'company',
+ 'meta_value' => $companies,
+ 'meta_compare' => 'IN',
+ 'fields' => 'ID',
+ ]);
+
$args = [
'post_type' => 'pexpo_partners',
'posts_per_page' => $params['resultsPerPage'] ?? 10,
@@ -79,6 +88,10 @@ class Partnerexpo_Core_Public {
'pexpo_tags' => $params['tags'] ?? '',
];
+ if (!empty($authors)) {
+ $args['author__in'] = array_values($authors);
+ }
+
if ( ! empty( $params['tags'] ) ) {
$tag_string = $params['tags'];
$operator = 'IN';
diff --git a/public/js/searchbox.js b/public/js/searchbox.js
index 3a09f37..86fe613 100644
--- a/public/js/searchbox.js
+++ b/public/js/searchbox.js
@@ -14,6 +14,7 @@ class PartnerExpoSearch {
drawerBackdrop: document.getElementById("pexpo-core-drawerBackdrop"),
filterFTag: document.getElementById("pexpo-core-tag-toggle"),
filterTags: document.getElementById("pexpo-core-tags"),
+ filterCompanies: document.getElementById("pexpo-core-companies"),
qInput: document.getElementById("pexpo-core-q"),
masonry: document.getElementById("pexpo-core-masonry"),
measure: document.getElementById("pexpo-core-measure"),
@@ -33,6 +34,7 @@ class PartnerExpoSearch {
sort: "relevance",
force_tags: false,
tags: [],
+ companies: [],
resultsPerPage: 20,
page: 1,
},
@@ -72,7 +74,6 @@ class PartnerExpoSearch {
initMultiSelect() {
if (typeof MultiSelect !== 'undefined') {
new MultiSelect(this.els.filterTags, {
- placeholder: 'Címkék kiválasztása',
search: true,
selectAll: false,
onSelect: (value) => {
@@ -84,6 +85,19 @@ class PartnerExpoSearch {
this.state.filters.tags = this.state.filters.tags.filter(tag => tag !== value);
}
});
+
+ new MultiSelect(this.els.filterCompanies, {
+ search: true,
+ selectAll: false,
+ onSelect: (value) => {
+ if (!this.state.filters.companies.includes(value)) {
+ this.state.filters.companies.push(value);
+ }
+ },
+ onUnselect: (value) => {
+ this.state.filters.companies = this.state.filters.companies.filter(company => company !== value);
+ }
+ });
} else {
console.warn("MultiSelect library not found.");
}
diff --git a/public/partials/partnerexpo-core-public-searchbox.php b/public/partials/partnerexpo-core-public-searchbox.php
index 54bb1ae..db1810d 100644
--- a/public/partials/partnerexpo-core-public-searchbox.php
+++ b/public/partials/partnerexpo-core-public-searchbox.php
@@ -15,8 +15,28 @@ $tags = get_terms([
'hide_empty' => false,
]);
-?>
+$users = get_users([
+ 'meta_key' => 'company',
+ 'meta_compare' => 'EXISTS',
+]);
+$companies = [];
+foreach ($users as $user) {
+ $company = get_user_meta($user->ID, 'company', true);
+ if (!empty($company)) {
+ $companies[$company] = $company;
+ }
+}
+
+$authors = get_users([
+ 'meta_key' => 'company',
+ 'meta_value' => array_keys($companies) ?? [],
+ 'meta_compare' => 'IN',
+ 'fields' => 'ID',
+ ]);
+
+
+?>
@@ -64,6 +84,12 @@ $tags = get_terms([
+
+