Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wcfmmp_store_tabs', function ($store_tabs, $id) {
- $store_tabs['store-joblists'] = __('Job Lists', 'wc-multivendor-marketplace');
- return $store_tabs;
- }, 10, 2);
- add_filter('wcfmp_store_tabs_url', function ($store_tab_url, $tab) {
- switch ($tab) {
- case 'store-joblists':
- $store_tab_url = $store_tab_url . 'store-joblists';
- break;
- }
- return $store_tab_url;
- }, 10, 2);
- add_filter('query_vars', function ($vars) {
- $vars[] = 'store-joblists';
- return $vars;
- }, 21);
- add_filter('wcfmp_store_default_query_vars', function ($query_var) {
- if (get_query_var('store-joblists')) {
- $query_var = 'store-joblists';
- }
- return $query_var;
- });
- add_action('wcfmmp_rewrite_rules_loaded', function ($wcfm_store_url) {
- global $WCFMmp;
- add_rewrite_rule($wcfm_store_url . '/([^/]+)/' . $WCFMmp->wcfmmp_rewrite->store_endpoint('store-joblists') . '?$', 'index.php?post_type=job_listing&' . $wcfm_store_url . '=$matches[1]&' . $WCFMmp->wcfmmp_rewrite->store_endpoint('store-joblists') . '=true', 'top');
- add_rewrite_rule($wcfm_store_url . '/([^/]+)/' . $WCFMmp->wcfmmp_rewrite->store_endpoint('store-joblists') . '/page/?([0-9]{1,})/?$', 'index.php?post_type=job_listing&' . $wcfm_store_url . '=$matches[1]&paged=$matches[2]&' . $WCFMmp->wcfmmp_rewrite->store_endpoint('store-joblists') . '=true', 'top');
- }, 8);
- add_action('init', function () {
- add_rewrite_endpoint('store-joblists', EP_ROOT | EP_PAGES);
- }, 12);
- add_filter('pre_get_posts', function ($query, $that = null) {
- global $WCFMmp;
- $store_name = apply_filters('wcfmmp_store_query_var', get_query_var($WCFMmp->wcfmmp_rewrite->wcfm_store_url));
- if (!is_admin() && $query->is_main_query() && !empty($store_name)) {
- $seller_info = get_user_by('slug', $store_name);
- if ($seller_info) {
- if (get_query_var('store-joblists')) {
- $query->set('author__in', $seller_info->data->ID);
- $query->set('post_type', 'job_listing');
- }
- }
- }
- }, 9999, 2);
- add_filter('wcfmmp_store_default_template', function ($template, $tab) {
- if ($tab == 'store-joblists') {
- $template = 'store/wcfmmp-view-store-joblists.php';
- }
- return $template;
- }, 50, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement