Plugin Directory

Changeset 485904


Ignore:
Timestamp:
01/06/2012 11:45:44 PM (14 years ago)
Author:
manfer
Message:

Added support for custom theme.
Better integration with BWP Recaptcha.

Location:
contact-form-7-bwp-recaptcha-extension/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • contact-form-7-bwp-recaptcha-extension/trunk/contact-form-7-bwp-recaptcha-extension.php

    r476973 r485904  
    44Plugin URI: http://www.manfersite.tk/cf7bwpcapt
    55Description: Provides Better WordPress reCAPTCHA possibilities to the Contact Form 7 plugin. Requires both.
    6 Version: 0.2
     6Version: 0.3
    77Author: Fernando San Julián
    88Email: manfer.site@gmail.com
     
    3131// this is the 'driver' file that instantiates the object
    3232define( 'ALLOW_CF7_BWP_CAPT_INCLUDE', true );
    33 define( 'CF7BWPRECAPT_VERSION', '0.2' );
     33define( 'CF7BWPRECAPT_VERSION', '0.3' );
    3434define( 'CF7BWPRECAPT_URL', 'http://www.manfersite.tk/cf7bwpcapt' );
    3535define( 'CF7BWPRECAPT_TITLE', 'Contact Form 7 BWP reCAPTCHA Extension' );
  • contact-form-7-bwp-recaptcha-extension/trunk/includes/CF7bwpCAPT.class.php

    r476971 r485904  
    173173                'white'      => __( 'White',       $this->textdomain ),
    174174                'blackglass' => __( 'Black Glass', $this->textdomain ),
    175                 'clean'      => __( 'Clean',       $this->textdomain )
     175                'clean'      => __( 'Clean',       $this->textdomain ),
     176                'custom'     => __( 'Custom',      $this->textdomain )
    176177            );
    177178
     
    197198                __( 'White',       $this->textdomain ) => 'white',
    198199                __( 'Black Glass', $this->textdomain ) => 'blackglass',
    199                 __( 'Clean',       $this->textdomain ) => 'clean'
     200                __( 'Clean',       $this->textdomain ) => 'clean',
     201                __( 'Custom',      $this->textdomain ) => 'custom'
    200202            );
    201203
     
    293295                'white',
    294296                'blackglass',
    295                 'clean'
     297                'clean',
     298                'custom'
    296299            );
    297300
     
    411414            global $wpcf7_contact_form, $bwp_capt;
    412415
    413             if ( $bwp_capt->user_can_bypass() ) return '';
    414 
    415416            $name = $tag[ 'name' ];
    416417
    417             // Get Better Wordpress Recaptcha options to obtain current language
    418             $bwp_capt_options = get_option( 'bwp_capt_theme' );
    419 
    420             // default options if not configured
    421             $used_theme = 'red';
    422             $used_language = 'en';
    423 
    424             if ( $this->options[ 'select_theme' ] === 'bwp_capt'
    425             && isset( $bwp_capt_options[ 'select_theme' ] ) ) {
    426                 $used_theme = $bwp_capt_options[ 'select_theme' ];
    427             } elseif ( $this->options[ 'select_theme' ] === 'cf7'
     418            // set bwp recaptcha options to cf7 bwp recaptcha options
     419            $bwp_capt_theme = $bwp_capt->options['select_theme'];
     420            $bwp_capt_lang  = $bwp_capt->options['select_lang'];
     421
     422            if ( $this->options[ 'select_theme' ] === 'cf7'
    428423            && isset( $this->options[ 'cf7_theme' ] ) ) {
    429                 $used_theme = $this->options[ 'cf7_theme' ];
    430             }
    431 
    432             if ( $this->options[ 'select_lang' ] === 'bwp_capt'
    433             && isset( $bwp_capt_options[ 'select_lang' ] ) ) {
    434                 $used_language = $bwp_capt_options[ 'select_lang' ];
    435             } elseif ( $this->options[ 'select_lang' ] === 'cf7'
     424                $bwp_capt->options['select_theme'] = $this->options[ 'cf7_theme' ];
     425            }
     426
     427            if ( $this->options[ 'select_lang' ] === 'cf7'
    436428            && isset( $this->options[ 'cf7_lang' ] ) ) {
    437                 $used_language = $this->options[ 'cf7_lang' ];
    438             }
    439 
    440             $js_options = <<<JSOPTS
    441 <script type='text/javascript'>
    442 var RecaptchaOptions = { theme : '{$used_theme}', lang : '{$used_language}'};
    443 </script>
    444 JSOPTS;
    445 
    446             $html = $js_options;
    447 
    448             if ( function_exists( 'recaptcha_get_html' ) && !defined( 'BWP_CAPT_ADDED' ) ) {
    449 
    450                 // make sure we add only one recaptcha instance
    451                 define( 'BWP_CAPT_ADDED', true );
    452 
    453                 $captcha_error = '';
    454                 if ( ! empty( $_GET[ 'cerror' ] ) && 'incorrect-captcha-sol' == $_GET[ 'cerror' ] )
    455                     $captcha_error = $_GET[ 'cerror' ];
    456 
    457                 if ( ! empty( $_SESSION[ 'bwp_capt_akismet_needed' ]) && 'yes' == $_SESSION[ 'bwp_capt_akismet_needed' ] ) {
    458                     $html .= '<p class="bwp-capt-spam-identified">' . _e( 'Your comment was identified as spam, please complete the CAPTCHA below:', 'bwp-recaptcha' ) . '</p>';
    459                 }
    460 
    461                 do_action( 'bwp_capt_before_add_captcha' );
    462 
    463                 if ( 'redirect' == $bwp_capt->options[ 'select_response' ]  && ! is_admin() ) {
    464                     $html .= '<input type="hidden" name="error_redirect_to" value="' . esc_attr_e( $bwp_capt->get_current_comment_page_link() ) . '" />';
    465                 }
    466 
    467                 $use_ssl = ( isset( $_SERVER[ 'HTTPS' ]) && 'on' == $_SERVER[ 'HTTPS' ] ) ? true : false;
    468                 if ( ! empty( $bwp_capt->options[ 'input_pubkey' ] ) )
    469                     $html .= recaptcha_get_html( $bwp_capt->options[ 'input_pubkey' ], $captcha_error, $use_ssl );
    470                 elseif ( current_user_can( 'manage_options' ) )
    471                     $html .= _e( "To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>", 'bwp-recaptcha' );
    472             }
     429                $bwp_capt->options['select_lang'] = $this->options[ 'cf7_lang' ];
     430            }
     431
     432            // add_recaptcha function outputs directly so we have to buffer
     433            // that to store it in a variable instead.
     434            ob_start();
     435            $bwp_capt->add_recaptcha();
     436            $html = ob_get_contents();
     437            ob_end_clean();
     438
     439            // restore bwp recaptcha options
     440            $bwp_capt->options['select_theme'] = $bwp_capt_theme;
     441            $bwp_capt->options['select_lang']  = $bwp_capt_lang;
     442
    473443
    474444            $validation_error = '';
    475445            if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) )
    476             $validation_error = $wpcf7_contact_form->validation_error( $name );
     446                $validation_error = $wpcf7_contact_form->validation_error( $name );
    477447
    478448            $html .= '<span class="wpcf7-form-control-wrap ' . $name . '">' . $validation_error . '</span>';
    479 
    480449            return $html;
     450
    481451        }
    482452
  • contact-form-7-bwp-recaptcha-extension/trunk/readme.txt

    r476973 r485904  
    55Requires at least: 2.9
    66Tested up to: 3.1.3
    7 Stable tag: 0.2
     7Stable tag: 0.3
    88
    99This plugin provides a new tag for the Contact Form 7 Plugin. It allows the usage of a reCAPTCHA field provided by the BWP reCAPTCHA Plugin.
     
    6666== Changelog ==
    6767
     68= 0.3 (20120106) =
     69* Added support for custom theme.
     70* Better integration with BWP Recaptcha.
     71
     72= 0.2 (20111218) =
     73* Updated language file.
     74
    6875= 0.1 (20111217) =
    6976* Total rewrite to stop using some code I don't want to use anymore.
Note: See TracChangeset for help on using the changeset viewer.