WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
CF7 / Really Simple Captha and HTTPS/SSL (2 posts)

  1. theZedt
    Member
    Posted 9 months ago #

    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']);
         endif;
         // 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.

    http://wordpress.org/plugins/contact-form-7/

  2. jblakely
    Member
    Posted 5 months ago #

    Here is a different method that worked for me. See the following post for the source of this solution.

    http://wordpress.org/support/topic/wp_content_url-based-defines-do-not-work-over-ssl-https

    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.

Reply

You must log in to post.

About this Plugin

About this Topic