WordPress.org

Ready to get started?Download WordPress

Forums

WordPress HTTPS (SSL)
[resolved] [Plugin: WordPress HTTPS] Disable https:// for menu links (14 posts)

  1. epschmidt
    Member
    Posted 3 years ago #

    I'm using the https for wordpress plugin to force SSL on our WP E-commerce checkout page. Everything is working so I don't get any errors, but it also forces our menu's to be https, when they should link back to just regular http pages. Is there a way to alter the plugin to not affect these links? Or another way to make sure they stay http?

  2. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    Unfortunately, that is how the plugin works. The functionality of this plugin was added in WordPress 3.0, which is kind of annoying. If you have a version lower than 3.0, however, you can use my plugin, WordPress HTTPS, to fix your unencrypted elements. My plugin does not touch anchor tags. If you have 3.0, your links are going to be changed to HTTPS when any of your pages are viewed via HTTPS. I'm not sure if there is a way to disable this functionality, but maybe someone else knows?

  3. Mike Wilson
    Member
    Posted 3 years ago #

    Wow after an hour of searching I think I finally found something useful...

    WordPress Version: 3.0.1
    Core File: wp-includes/link-template.php
    Lines: 1840-1872 (for me at least)

    /**
     * Retrieve the home url for a given site.
     *
     * Returns the 'home' option with the appropriate protocol,  'https' if
     * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
     * overridden.
     *
     * @package WordPress
     * @since 3.0.0
     *
     * @param  int $blog_id   (optional) Blog ID. Defaults to current blog.
     * @param  string $path   (optional) Path relative to the home url.
     * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
     * @return string Home url link with optional path appended.
    */
    function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
    	$orig_scheme = $scheme;
    
    	if ( !in_array( $scheme, array( 'http', 'https' ) ) )
    		$scheme = is_ssl() && !is_admin() ? 'https' : 'http';
    
    	if ( empty( $blog_id ) || !is_multisite() )
    		$home = get_option( 'home' );
    	else
    		$home = get_blog_option( $blog_id, 'home' );
    
    	$url = str_replace( 'http://', "$scheme://", $home );
    
    	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
    		$url .= '/' . ltrim( $path, '/' );
    
    	return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
    }

    I don't know what the hell I'm doing really... but I just changed the following:

    $scheme = is_ssl() && !is_admin() ? 'https' : 'http';

    to

    $scheme = is_ssl() && !is_admin() ? 'http' : 'http';

    And it seemed to revert back to the standard behavior... I'm more than sure there is a better way to work around this... maybe using some sort of filter in functions.php... I'm just not at all sure where to start with something like that.

  4. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    Hey idliketofly,

    I have figured out how to disable this functionality in WordPress 3.0+.

    I have added the option to WordPress HTTPS v1.0.

    Let me know if it works for you!

  5. Mike Wilson
    Member
    Posted 3 years ago #

    Hey Mvied,

    Nope... not working for me.

    I reverted the change to link-template.php I posted above and uploaded, verified the automatic https links had indeed returned, updated your plugin, selected "Disable Automatic HTTPS", and saved. When I view any https page on my site, all the post and page links are still https.

    If I make the change to link-template.php again, all the links revert to standard HTTP.

    WordPress 3.0.1.
    WordPress HTTPS 1.0.1

  6. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    I have a feeling your theme may be using a function that I'm not filtering to build your links.

    I had it working on a fresh install of WordPress 3.0.1 using the TwentyTen theme.

    Could you do two things for me?
    1. Change your sites theme to TwentyTen and tell me if the links are fixed in that theme.
    2. Post the code from your template that is generating the links that are not changing (even if it's just a standard WordPress function).

  7. Mike Wilson
    Member
    Posted 3 years ago #

    Hi,

    I can't switch themes, but it's not likely something in my theme ...or at least not anything "odd". My functions.php for this theme is pretty sparse, containing only one function: "remove_dashboard_widgets()", which pulls specified metaboxes off the admin dashboard and doesn't have any affect on the user-facing portion of the site.

    As for the code that was generating the links that wouldn't respond to your plugin... I think I've got it narrowed down to any link containing "<?php bloginfo('url'); ?>". Hard coded links that use the static url (e.g. http://www.mysite.com/) work as expected.

    I just updated this site to 3.0 last week, so to test this issue further, I implemented the new "menu" system, and Bob's your uncle... your plugin started working for the main navigation as well.

    So as far as I can tell, any hard coded link that contains "<?php bloginfo('url'); ?>", still points to https.

  8. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    Ah, that makes sense.

    Well, that function and all of the URL's it delivers probably need to be filtered as well. I'll get it into the next update.

  9. Mike Wilson
    Member
    Posted 3 years ago #

    Thanks! I'll keep an eye out for an update and report back anything new.

  10. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    I just pushed version 1.5 to the repository. It will now fix URL's that use the bloginfo function.

    Also, I've added the ability to force certain pages to HTTPS. Additionally, there is an option to force all pages not forced to HTTPS back to HTTP. This should be quite useful to those of you who only need a single page or so forced to HTTPS.

  11. worthdesigning
    Member
    Posted 3 years ago #

    I have a page that I need forced to be https:
    https://www.vicastrology.net/faa-conference-2012/registration-form/
    I have checked "Force SSL Exclusively" on this page.

    But it is also a link on two menus on all pages (sidebar and top navigation). So if I check "Disable Automatic HTTPS" then the links to the Registration Form are now http.

    Any way around this ??

  12. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    No, this is working as intended. When clicked, the page will be redirected to HTTPS, and the end-user probably won't even notice.

    However, on your site, you seem to have a plugin interfering with the redirection. Try turning off plugins one-by-one until you can go to http://www.vicastrology.net/faa-conference-2012/registration-form/ and you are properly redirected to HTTPS. After that, let me know which one it is and I'll see if I can fix the incompatibility for you.

    Thanks!

  13. worthdesigning
    Member
    Posted 3 years ago #

    OK - thanks for the quick reply.

    Will do that tonight and let you know how it goes

  14. Mvied
    Member
    Plugin Author

    Posted 3 years ago #

    Hey Auntypizza,

    Any updates? I'm quite curious to know which plugin is incompatible with mine, as this is the first time I've seen it happen.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic