• Is there a simple way – in functions.php – to say:

    if (condition met) {
    $forceSSL = false;
    }

    ?

    I’ve been trying to figure out a way to programmatically disable or enable the plugin without touching the plugin code, and am having some difficulty… but I don’t want it disabled for the entire site, just specific pages based on specific criteria.

    $forceSSL = get_post_meta($post->ID, 'force_ssl', true);
    				if ( !$this->is_ssl() && $forceSSL ) {
    					$this->redirect('https');
    				} else if ( get_option('wordpress-https_exclusive_https') == 1 && !$forceSSL ) {
    					$this->redirect('http');
    				}

    There is no filter available for post meta content, therefore, I cannot change it based on specific parameters (which would be defined in functions.php).

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author mvied

    (@mvied)

    Hey ururk,

    Not that I can think of. However, I really like the idea of being able to override the plugin’s functionality programmatically. Off the top of my head, I’m not sure how I’d go about doing that, but I’ll definitely put some thought into it. If I can figure it out soon, I’ll get it into the next version.

    Thanks,
    Mike

    Plugin Author mvied

    (@mvied)

    Hey ururk,

    The next version will feature a filter called ‘force_ssl’ that you will be able to hook into to programmatically force a page to HTTP or HTTPS based on whatever criteria you want.

    Thanks,
    Mike

    Plugin Author mvied

    (@mvied)

    Basically, beneath this line:
    $force_ssl = get_post_meta($post->ID, 'force_ssl', true);

    I’ve added:
    $force_ssl = apply_filters( 'force_ssl', $post->ID, $force_ssl );

    Here is a simple example on how you could use the filter.

    function custom_force_ssl( $post_id, $force_ssl ) {
    	if ( $post_id == 5 ) {
    		return true
    	}
    	return $force_ssl;
    }
    add_filter('force_ssl' , 'custom_force_ssl', 10, 2);

    Returning true in the filter forces the page to SSL, returning false will force it to HTTP.

    Thanks,
    Mike

    Thread Starter ururk

    (@ururk)

    Thanks!

    I ended up hacking the plugin, but this is great news, as I can move my ‘customization’ to the theme.

    (BTW – this is a great plugin overall!)

    Plugin Author mvied

    (@mvied)

    Hey ururk,

    Yep, that’s why I posted the change. I figured you could get your code in place and when you update to the next version, it’ll keep working.

    Thanks!

    Mike

    Plugin Author mvied

    (@mvied)

    Hey ururk,

    I had to change it up slightly since I created the filter incorrectly.
    $force_ssl = apply_filters( ‘force_ssl’, $force_ssl, $post->ID );

    function custom_force_ssl( $force_ssl, $post_id ) {
    	if ( $post_id == 5 ) {
    		return true
    	}
    	return $force_ssl;
    }
    add_filter('force_ssl' , 'custom_force_ssl', 10, 2);

    Thanks,
    Mike

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: WordPress HTTPS] Disable temporarily for specific page’ is closed to new replies.