Support » Plugin: Contact Form 7 » CF7 / Really Simple Captha and HTTPS/SSL

  • I noticed that using Contact Form 7 with a Really Simple Captcha on the form placed on a SSL page attempts to load the image from a http:// only URL, triggering unsafe content notices in some browsers.

    This can be easily improved by editing the wpcf7_upload_dir() function in cf7/includes/functions.php to take SSL into account:

    function wpcf7_upload_dir( $type = false ) {
    	$uploads = wp_upload_dir();
    	$uploads = apply_filters( 'wpcf7_upload_dir', array(
    		'dir' => $uploads['basedir'],
    		'url' => $uploads['baseurl'] ) );
         // SSL mod
         if (is_ssl()):
             $uploads['url'] = str_replace("http://","https://",$uploads['url']);
         // end SSL mod
    	if ( 'dir' == $type )
    		return $uploads['dir'];
    	if ( 'url' == $type )
    		return $uploads['url'];
    	return $uploads;

    I’m sure this can be done better or safer, but this worked for me.

Viewing 1 replies (of 1 total)
  • Here is a different method that worked for me. See the following post for the source of this solution.

    Essentially, I edited wp-includes/default-constants.php and changed the wp_plugin_directory_constants function as follows:

    function wp_plugin_directory_constants( ) {
            if ( !defined('WP_CONTENT_URL') )
                    define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
            if ( !defined('WP_CONTENT_URL') )
                    define( 'WP_CONTENT_URL', site_url( 'wp-content') ); // full url - WP_CONTENT_DIR is define with https or http per connection

    Hopefully this will be helpful to others.

Viewing 1 replies (of 1 total)
  • The topic ‘CF7 / Really Simple Captha and HTTPS/SSL’ is closed to new replies.