Title: Remove http://
Last modified: August 30, 2016

---

# Remove http://

 *  [James Spencer](https://wordpress.org/support/users/js-enigma/)
 * (@js-enigma)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/)
 * Hi Tijmen,
 * I have added the URL to the store listings and info window through a filter however
   the web address always shows http:// when the data doesn’t have this.
 * Is it possible to remove this using str_replace perhaps? I have tried this but
   I can’t get it to remove this for the onscreen view.
 * Do you have any thoughts at all?
 * Thanks
    James
 * [https://wordpress.org/plugins/wp-store-locator/](https://wordpress.org/plugins/wp-store-locator/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6782966)
 * I tested it, and the same thing happens with me. But I can’t find anything in
   the code that adds the [http://](https://wordpress.org/support/topic/remove-http/?output_format=md),
   I would almost start to think that the browser adds the http:// to the url.
 * What’s the url of your site?
 *  Thread Starter [James Spencer](https://wordpress.org/support/users/js-enigma/)
 * (@js-enigma)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6782987)
 * I have not quite got it live as yet.
 * Within the filter I put this into a new variable like this `$new_url = str_replace('
   http://', '', '<%= url %>');`
 * Then called this like so `$info_window_template .= "\t\t" . '<span><a href="<%
   = url %>">' . $new_url . '</span>' . "\r\n";`
 * I have tried a few different options to accomplish this including str_replace
   above and ltrim, both pass the url and show the web address but continue to tag
   the protocol first. This is fine to actually have as a link but not keen on on
   showing this on the the front end in this case.
 * Could I add the url to the filter for store_meta? If so I am assuming i can add
   to this?
 *     ```
       add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
   
       function custom_store_meta( $store_meta, $store_id ) {
   
           $terms = wp_get_post_terms( $store_id, 'wpsl_store_category' );
   
           if ( count( $terms ) > 1 ) {
               $location_terms = array();
   
               foreach ( $terms as $term ) {
                   $location_terms[] = $term->name;
               }
   
               $store_meta['terms'] = implode( ', ', $location_terms );
           } else if ( !empty( $terms ) ) {
               $store_meta['terms'] = $terms[0]->name;
           }
   
           return $store_meta;
       }
       ```
   
 * Any help would be appreciated.
 * Thanks
    James
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783065)
 * Have you checked the data that is returned with the Ajax request in something
   like firebug, or another browser console, and checked if it contains the http://
   as well?
 * If the Ajax response doesn’t contain it, then it has to be the browser that adds
   the http:// automatically to the url.
 * I also just search the wpsl-gmap.js for [http://](https://wordpress.org/support/topic/remove-http/?output_format=md),
   but the only results are comments.
 *  Thread Starter [James Spencer](https://wordpress.org/support/users/js-enigma/)
 * (@js-enigma)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783066)
 * Hi Tijmen,
 * I don’t have firebug installed at the moment but I have looked in firefox developer
   edition. Hoping I am looking in the correct area but I went into Network > Response
   and where url is returned all the url’s have http:// prior to the actual web 
   address.
 * I am assuming this is therefore returned through the ajax?
 * Can you suggest anything I can do to help this?
 * Thanks for all your help.
    James
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783067)
 * Ah, I know what happens now. Urls are going through [https://codex.wordpress.org/Function_Reference/esc_url](https://codex.wordpress.org/Function_Reference/esc_url),
   and that page says “If the URL appears to be an absolute link that does not contain
   a scheme, prepends [http://.&#8221](http://.&#8221);
 * In that case, you can use the wpsl_store_meta filter to loop through the collected
   store data, look for the ‘url’ field and remove the http:// again.
 *  Thread Starter [James Spencer](https://wordpress.org/support/users/js-enigma/)
 * (@js-enigma)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783068)
 * Hi Tijmen,
 * Glad to see I was on the right lines but I am unsure how to add this to the code
   for the meta_filter I posted before.
 * Can you point me in the right direction at all please?
 * Thanks again
    James
 *  Thread Starter [James Spencer](https://wordpress.org/support/users/js-enigma/)
 * (@js-enigma)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783069)
 * Hi Tijmen,
 * All sorted now thanks i have had to do the following and would be interested 
   to know if there is a better way to accomplish this.
 * Inside the store_meta_filter
    `$store_meta['url'] = str_replace("http://", "",
   $store_meta['url']);`
 * Then inside the custom_listing_template
    `$new_url = str_replace("http://", "","
   <%= url %>");`
 * Plus this to display
    `$listing_template .= "\t\t\t\t" . '<span><a href="http://
   <%= url %>">' . $new_url . '</a></span>' . "\r\n";`
 * This now shows the web address without the http:// protocol and also maintains
   the correct link when a user clicks.
 * Thanks again
    James
 *  Plugin Author [Tijmen Smit](https://wordpress.org/support/users/tijmensmit/)
 * (@tijmensmit)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783070)
 * This code should work, but when I tested it the url without the http:// didn’t
   work anymore ( at least on my local installation ). So maybe you just need to
   keep it.
 *     ```
       foreach ( $store_meta as $k => $meta ) {
               if ( $k == 'url' ) {
                  $store_meta[$k] = str_replace( 'http://', '', $meta );
               }
           }
       ```
   
 *  Thread Starter [James Spencer](https://wordpress.org/support/users/js-enigma/)
 * (@js-enigma)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783071)
 * HI Tijmen,
 * Thanks for the code although for now I will stick with the code I have for now
   as this seems to work for me at least.
 * Thanks again.
    James

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Remove http://’ is closed to new replies.

 * ![](https://ps.w.org/wp-store-locator/assets/icon-256x256.jpg?rev=1007784)
 * [WP Store Locator](https://wordpress.org/plugins/wp-store-locator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-store-locator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-store-locator/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-store-locator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-store-locator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-store-locator/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [James Spencer](https://wordpress.org/support/users/js-enigma/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/remove-http/#post-6783071)
 * Status: not resolved