Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('wcfmmp_rewrite_rules_loaded', function ($wcfm_store_url) {
- add_rewrite_rule($wcfm_store_url . '/([^/]+)/location?$', 'index.php?' . $wcfm_store_url . '=$matches[1]&location=true', 'top');
- }, 50);
- add_filter('query_vars', function ($vars) {
- $vars[] = 'location';
- return $vars;
- }, 50);
- function change_store_widget_content( $widget_content, $widget ) {
- global $WCFMmp;
- if(! wcfmmp_is_store_page()) return $widget_content;
- $wcfm_store_url = wcfm_get_option( 'wcfm_store_url', 'store' );
- $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
- $store_id = 0;
- if ( ! empty( $store_name ) ) {
- $store_user = get_user_by( 'slug', $store_name );
- $store_id = $store_user->ID;
- }
- if(!$store_id) return $widget_content;
- if ( 'wcfmem-store-tabs' === $widget->get_name()) {
- $location_tab_url = home_url( '/' . $wcfm_store_url . '/' . $store_name . '/location' );
- $location_tab = '<li class="elementor-icon-list-item" >
- <a href="' . esc_url($location_tab_url) . '">
- <span class="elementor-icon-list-text">Location</span>
- </a>
- </li>';
- $widget_content = str_replace('</ul>', $location_tab . '</ul>', $widget_content);
- } elseif( 'wcfmem-store-tab-contents' === $widget->get_name() && get_query_var( $WCFMmp->wcfmmp_rewrite->store_endpoint('location'))) {
- $widget_content = do_shortcode('[wcfm_store_info id="'.$store_id.'" data="store_name"]');
- }
- return $widget_content;
- }
- add_filter( 'elementor/widget/render_content', 'change_store_widget_content', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement