Plugin Directory

Changeset 3274843


Ignore:
Timestamp:
04/16/2025 02:17:51 PM (12 months ago)
Author:
IQComputing
Message:

Version 1.4.9 for WordPress 6.8 | Fixes tag generation issues.

Location:
wpcf7-recaptcha/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wpcf7-recaptcha/trunk/changelog.txt

    r3186790 r3274843  
    22
    33This is to keep track of all changes the plugin undertakes. The readme.txt should only contain the most recent 3.
     4
     5= 1.4.9 =
     6
     7Release Date: April 15, 2025
     8
     9* Overview
     10    * Updated the "Tested up to" value to support 6.7+
     11    * Fixes the [recaptcha] tag generator (previously broken).
     12
     13* Code Changes
     14    * Changes the iqfix_wpcf7_add_tag_generator_recaptcha() WPCF7_TagGenerator callback to better support WPCF7_TagGenerator v2.
     15        * Now the version => 2 makes sense!
     16    * This redevelops the tag generator HTML with better attributes such as `data-tag-part` and `data-tag-option`
     17        * Doing so has now fixed the previously broken tag generation screen.
    418
    519= 1.4.8 =
  • wpcf7-recaptcha/trunk/readme.txt

    r3186790 r3274843  
    44Requires at least: 4.9
    55Tested up to: 6.7
    6 Stable tag: 1.4.8
     6Stable tag: 1.4.9
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6161== Changelog ==
    6262
     63= 1.4.9 (2025-04-15) =
     64* Updated the "Tested up to" value to support 6.8+
     65* Fixes to the [recaptcha] tag generator
     66
    6367= 1.4.8 (2024-11-13) =
    6468* Updated the "Tested up to" value to support 6.7+
  • wpcf7-recaptcha/trunk/recaptcha-v2.php

    r3186790 r3274843  
    6363    }
    6464
    65     $source = WPCF7::get_option( 'iqfix_recaptcha_source' );
     65    $source = \WPCF7::get_option( 'iqfix_recaptcha_source' );
    6666    $source = IQFix_WPCF7_Deity::verify_recaptcha_source( $source );
    6767
     
    112112    }
    113113
    114     $recaptcha = WPCF7_RECAPTCHA::get_instance();
     114    $recaptcha = \WPCF7_RECAPTCHA::get_instance();
    115115    $atts['data-sitekey'] = $recaptcha->get_sitekey();
    116116    $atts['data-type'] = $tag->get_option( 'type', '(audio|image)', true );
     
    162162    }
    163163
    164     $source = WPCF7::get_option( 'iqfix_recaptcha_source' );
     164    $source = \WPCF7::get_option( 'iqfix_recaptcha_source' );
    165165    $source = IQFix_WPCF7_Deity::verify_recaptcha_source( $source );
    166166    $url    = add_query_arg( 'k', $args['sitekey'],
     
    260260function iqfix_wpcf7_add_tag_generator_recaptcha() {
    261261
    262     $tag_generator = WPCF7_TagGenerator::get_instance();
     262    $tag_generator = \WPCF7_TagGenerator::get_instance();
    263263    $tag_generator->add(
    264264        'recaptcha',
     
    280280 *
    281281 * @param WPCF7_ContactForm $contact_form
    282  * @param Array $args
     282 * @param Array $options
    283283 *
    284284 * @return void
    285285 */
    286 function iqfix_wpcf7_tag_generator_recaptcha( $contact_form, $args = '' ) {
    287 
    288     $args       = wp_parse_args( $args, array() );
     286function iqfix_wpcf7_tag_generator_recaptcha( $contact_form, $options = array() ) {
     287
     288    $options    = wp_parse_args( $options, array() );
    289289    $recaptcha  = IQFix_ReCaptcha::get_instance();
    290 
    291     if ( ! $recaptcha->is_active() ) {
     290    $tgg        = new \WPCF7_TagGeneratorGenerator( $options['content'] );
    292291
    293292?>
    294 <div class="control-box">
    295 <fieldset>
    296 <legend><?php
    297     /* translators: %s is a link to the Contact Form 7 blog post regarding reCaptcha v3 */
    298     echo sprintf( esc_html__( "To use reCaptcha, first you need to install an API key pair. For more details, see %s.", 'wpcf7-recaptcha' ), wpcf7_link( 'https://contactform7.com/recaptcha/', esc_html__( 'reCaptcha', 'wpcf7-recaptcha' ) ) );
    299 ?></legend>
    300 </fieldset>
    301 </div>
     293<header class="description-box">
     294    <h3><?php esc_html_e( 'ReCaptcha form-tag generator', 'wpcf7-recaptcha' ); ?></h3>
     295
     296    <p><?php
     297        if ( ! $recaptcha->is_active() ) {
     298            /* translators: %s is a link to the Contact Form 7 blog post regarding reCaptcha v3 */
     299            echo sprintf( esc_html__( "To use reCaptcha, first you need to install an API key pair. For more details, see %s.", 'wpcf7-recaptcha' ), wpcf7_link( 'https://contactform7.com/recaptcha/', esc_html__( 'reCaptcha', 'wpcf7-recaptcha' ) ) );
     300        } else {
     301            /* translators: %s is a link to the Contact Form 7 blog post regarding reCaptcha v3 */
     302            $description    = esc_html__( "Generate a form-tag for a reCaptcha widget. For more details, see %s.", 'wpcf7-recaptcha' );
     303            $desc_link      = wpcf7_link( 'https://www.iqcomputing.com/support/articles/generate-google-recaptcha-v2-keys/', esc_html__( 'reCaptcha', 'wpcf7-recaptcha' ), array( 'target' => '_blank' ) );
     304            echo sprintf( $description, $desc_link );
     305        }
     306    ?></p>
     307</header>
     308
     309<div class="control-box"><?php
     310
     311    $tgg->print( 'field_type', array(
     312        'with_required'     => false,
     313        'select_options'    => array(
     314            $options['id'] => esc_html__( 'ReCaptcha v2', 'wpcf7-recaptcha' ),
     315        ),
     316    ) );
     317?>
     318
     319    <fieldset>
     320        <legend><?php esc_html_e( 'Size', 'wpcf7-recaptcha' ); ?></legend>
     321
     322        <label for="<?php echo esc_attr( $options['content'] . '-size-normal' ); ?>">
     323            <input type="radio" name="size" class="option default" id="<?php echo esc_attr( $options['content'] . '-size-normal' ); ?>" value="normal" checked="checked" data-tag-part="option" data-tag-option="" /> <?php
     324            /* translators: ReCaptcha size: normal */
     325            esc_html_e( 'Normal', 'wpcf7-recaptcha' );
     326        ?></label>
     327        <br />
     328        <label for="<?php echo esc_attr( $options['content'] . '-size-compact' ); ?>">
     329            <input type="radio" name="size" class="option" id="<?php echo esc_attr( $options['content'] . '-size-compact' ); ?>" value="compact" data-tag-part="option" data-tag-option="size:compact" /> <?php
     330            /* translators: ReCaptcha size: compact */
     331            esc_html_e( 'Compact', 'wpcf7-recaptcha' );
     332        ?></label>
     333    </fieldset>
     334
     335    <fieldset>
     336        <legend><?php esc_html_e( 'Theme', 'wpcf7-recaptcha' ); ?></legend>
     337
     338        <label for="<?php echo esc_attr( $options['content'] . '-theme-light' ); ?>">
     339            <input type="radio" name="theme" class="option default" id="<?php echo esc_attr( $options['content'] . '-theme-light' ); ?>" value="light" checked="checked" data-tag-part="option" data-tag-option="" /> <?php
     340            /* translators: ReCaptcha theme: light */
     341            esc_html_e( 'Light', 'wpcf7-recaptcha' );
     342        ?></label>
     343        <br />
     344        <label for="<?php echo esc_attr( $options['content'] . '-theme-dark' ); ?>">
     345            <input type="radio" name="theme" class="option" id="<?php echo esc_attr( $options['content'] . '-theme-dark' ); ?>" value="dark" data-tag-part="option" data-tag-option="theme:dark" /> <?php
     346            /* translators: ReCaptcha theme: dark */
     347            esc_html_e( 'Dark', 'wpcf7-recaptcha' );
     348        ?></label>
     349    </fieldset>
     350
     351
     352    <fieldset>
     353        <legend><?php esc_html_e( 'Alignment', 'wpcf7-recaptcha' ); ?></legend>
     354
     355        <label for="<?php echo esc_attr( $options['content'] . '-align-left' ); ?>">
     356            <input type="radio" name="align" class="option default" id="<?php echo esc_attr( $options['content'] . '-align-left' ); ?>" value="left" checked="checked" data-tag-part="option" data-tag-option="" /> <?php
     357            /* translators: ReCaptcha alignment: left */
     358            esc_html_e( 'Left', 'wpcf7-recaptcha' );
     359        ?></label>
     360        <br />
     361        <label for="<?php echo esc_attr( $options['content'] . '-align-center' ); ?>">
     362            <input type="radio" name="align" class="option" id="<?php echo esc_attr( $options['content'] . '-align-center' ); ?>" value="center" data-tag-part="option" data-tag-option="align:center" /> <?php
     363            /* translators: ReCaptcha alignment: center */
     364            esc_html_e( 'Center', 'wpcf7-recaptcha' );
     365        ?></label>
     366        <br />
     367        <label for="<?php echo esc_attr( $options['content'] . '-align-right' ); ?>">
     368            <input type="radio" name="align" class="option" id="<?php echo esc_attr( $options['content'] . '-align-right' ); ?>" value="right" data-tag-part="option" data-tag-option="align:right" /> <?php
     369            /* translators: ReCaptcha alignment: right */
     370            esc_html_e( 'Right', 'wpcf7-recaptcha' );
     371        ?></label>
     372    </fieldset>
     373
    302374<?php
    303375
    304         return;
    305     }
    306 
    307     /* translators: %s is a link to the Contact Form 7 blog post regarding reCaptcha v3 */
    308     $description    = esc_html__( "Generate a form-tag for a reCaptcha widget. For more details, see %s.", 'wpcf7-recaptcha' );
    309     $desc_link      = wpcf7_link( 'https://contactform7.com/recaptcha/', esc_html__( 'reCaptcha', 'wpcf7-recaptcha' ) );
    310 
    311 ?>
    312 <div class="control-box">
    313 <fieldset>
    314 <legend><?php echo sprintf( $description, $desc_link ); ?></legend>
    315 
    316 <table class="form-table">
    317 <tbody>
    318     <tr>
    319     <th scope="row"><?php
    320         /* translators: ReCaptcha size (normal or compact) */
    321         esc_html_e( 'Size', 'wpcf7-recaptcha' );
    322     ?></th>
    323     <td>
    324         <fieldset>
    325         <legend class="screen-reader-text"><?php
    326             /* translators: Screen reader text, reCaptcha size (normal or compact) */
    327             esc_html_e( 'Size', 'wpcf7-recaptcha' );
    328         ?></legend>
    329         <label for="<?php echo esc_attr( $args['content'] . '-size-normal' ); ?>"><input type="radio" name="size" class="option default" id="<?php echo esc_attr( $args['content'] . '-size-normal' ); ?>" value="normal" checked="checked" /> <?php /* translators: ReCaptcha size: normal */ esc_html_e( 'Normal', 'wpcf7-recaptcha' ); ?></label>
    330         <br />
    331         <label for="<?php echo esc_attr( $args['content'] . '-size-compact' ); ?>"><input type="radio" name="size" class="option" id="<?php echo esc_attr( $args['content'] . '-size-compact' ); ?>" value="compact" /> <?php /* translators: ReCaptcha size: compact */ esc_html_e( 'Compact', 'wpcf7-recaptcha' ); ?></label>
    332         </fieldset>
    333     </td>
    334     </tr>
    335 
    336     <tr>
    337     <th scope="row"><?php
    338         /* translators: ReCaptcha theme (light or dark) */
    339         esc_html_e( 'Theme', 'wpcf7-recaptcha' );
    340     ?></th>
    341     <td>
    342         <fieldset>
    343         <legend class="screen-reader-text"><?php
    344             /* translators: Screen reader text, reCaptcha theme (light or dark) */
    345             esc_html_e( 'Theme', 'wpcf7-recaptcha' );
    346         ?></legend>
    347         <label for="<?php echo esc_attr( $args['content'] . '-theme-light' ); ?>"><input type="radio" name="theme" class="option default" id="<?php echo esc_attr( $args['content'] . '-theme-light' ); ?>" value="light" checked="checked" /> <?php /* translators: ReCaptcha theme: light */ esc_html_e( 'Light', 'wpcf7-recaptcha' ); ?></label>
    348         <br />
    349         <label for="<?php echo esc_attr( $args['content'] . '-theme-dark' ); ?>"><input type="radio" name="theme" class="option" id="<?php echo esc_attr( $args['content'] . '-theme-dark' ); ?>" value="dark" /> <?php /* translators: ReCaptcha theme: dark */ esc_html_e( 'Dark', 'wpcf7-recaptcha' ); ?></label>
    350         </fieldset>
    351     </td>
    352     </tr>
    353 
    354     <tr>
    355     <th scope="row"><?php
    356         /* translators: ReCaptcha theme (light or dark) */
    357         esc_html_e( 'Alignment', 'wpcf7-recaptcha' );
    358     ?></th>
    359     <td>
    360         <fieldset>
    361         <legend class="screen-reader-text"><?php
    362             /* translators: Alignment of the reCaptcha box (left, center, right) */
    363             esc_html_e( 'Alignment', 'wpcf7-recaptcha' );
    364         ?></legend>
    365         <label for="<?php echo esc_attr( $args['content'] . '-align-left' ); ?>"><input type="radio" name="align" class="option default" id="<?php echo esc_attr( $args['content'] . '-align-left' ); ?>" value="left" checked="checked" /> <?php /* translators: ReCaptcha alignment: left */ esc_html_e( 'Left', 'wpcf7-recaptcha' ); ?></label>
    366         <br />
    367         <label for="<?php echo esc_attr( $args['content'] . '-align-center' ); ?>"><input type="radio" name="align" class="option" id="<?php echo esc_attr( $args['content'] . '-align-center' ); ?>" value="center" /> <?php /* translators: ReCaptcha alignment: center */ esc_html_e( 'Center', 'wpcf7-recaptcha' ); ?></label>
    368         <br />
    369         <label for="<?php echo esc_attr( $args['content'] . '-align-right' ); ?>"><input type="radio" name="align" class="option" id="<?php echo esc_attr( $args['content'] . '-align-right' ); ?>" value="right" /> <?php /* translators: ReCaptcha alignment: right */ esc_html_e( 'Right', 'wpcf7-recaptcha' ); ?></label>
    370         </fieldset>
    371     </td>
    372     </tr>
    373 
    374     <tr>
    375     <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php
    376         /* translators: HTML Attribute ID for reCaptcha box */
    377         esc_html_e( 'Id attribute', 'wpcf7-recaptcha' );
    378     ?></label></th>
    379     <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-id' ); ?>" /></td>
    380     </tr>
    381 
    382     <tr>
    383     <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php
    384         /* translators: HTML Attribute class for reCaptcha box */
    385         esc_html_e( 'Class attribute', 'wpcf7-recaptcha' );
    386     ?></label></th>
    387     <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr( $args['content'] . '-class' ); ?>" /></td>
    388     </tr>
    389 
    390 </tbody>
    391 </table>
    392 </fieldset>
    393 </div>
    394 
    395 <div class="insert-box">
    396     <input type="text" name="recaptcha" class="tag code" readonly="readonly" onfocus="this.select()" />
    397 
    398     <div class="submitbox">
    399     <input type="button" class="button button-primary insert-tag" value="<?php
    400         /* translators: Insert shortcode tag into the page content */
    401         esc_attr_e( 'Insert Tag', 'wpcf7-recaptcha' );
    402     ?>" />
    403     </div>
    404 </div>
     376    $tgg->print( 'id_attr' );
     377
     378    $tgg->print( 'class_attr' );
     379
     380
     381?></div>
     382
     383<footer class="insert-box">
     384    <?php $tgg->print( 'insert_box_content' ); ?>
     385</footer>
    405386<?php
    406387
     
    421402    }
    422403
    423     Class IQFix_ReCaptcha extends WPCF7_RECAPTCHA {
     404    Class IQFix_ReCaptcha extends \WPCF7_RECAPTCHA {
    424405
    425406        private static $instance;
     
    441422                $this->sitekeys = array( WPCF7_RECAPTCHA_SITEKEY => WPCF7_RECAPTCHA_SECRET );
    442423            } else {
    443                 $this->sitekeys = WPCF7::get_option( 'recaptcha' );
     424                $this->sitekeys = \WPCF7::get_option( 'recaptcha' );
    444425            }
    445426
     
    541522            }
    542523
    543             $source     = WPCF7::get_option( 'iqfix_recaptcha_source' );
     524            $source     = \WPCF7::get_option( 'iqfix_recaptcha_source' );
    544525            $source     = IQFix_WPCF7_Deity::verify_recaptcha_source( $source );
    545526            $endpoint   = sprintf( 'https://www.%s/recaptcha/api/siteverify', $source );
  • wpcf7-recaptcha/trunk/wpcf7-recaptcha.php

    r3186790 r3274843  
    33 * Plugin Name: ReCaptcha v2 for Contact Form 7
    44 * Description: ReCaptcha v2 Fix for Contact Form 7 5.1 and later.
    5  * Version: 1.4.8
     5 * Version: 1.4.9
    66 * Author: IQComputing
    77 * Author URI: http://www.iqcomputing.com/
     
    2525     * @var String
    2626     */
    27     public static $version = '1.4.8';
     27    public static $version = '1.4.9';
    2828
    2929
     
    6969    private function include_files() {
    7070
    71         $selection      = WPCF7::get_option( 'iqfix_recaptcha' );
    72         $cf7_version    = ( defined( 'WPCF7_VERSION' ) ) ? WPCF7_VERSION : WPCF7::get_option( 'version', '0' );
     71        $selection      = \WPCF7::get_option( 'iqfix_recaptcha' );
     72        $cf7_version    = ( defined( 'WPCF7_VERSION' ) ) ? WPCF7_VERSION : \WPCF7::get_option( 'version', '0' );
    7373
    7474        // Prevent update from v2 to v3 notice.
    75         WPCF7::update_option( 'recaptcha_v2_v3_warning', false );
     75        \WPCF7::update_option( 'recaptcha_v2_v3_warning', false );
    7676
    7777        if( empty( $selection ) || version_compare( $cf7_version, '5.1', '<' ) ) {
     
    7979        }
    8080
    81         include_once( plugin_dir_path( __FILE__ ) . 'recaptcha-v2.php' );
     81        include_once plugin_dir_path( __FILE__ ) . 'recaptcha-v2.php';
    8282
    8383        if( class_exists( 'Flamingo_Contact' ) ) {
    84             include_once( plugin_dir_path( __FILE__ ) . 'flamingo.php' );   // Flamingo updates
     84            include_once plugin_dir_path( __FILE__ ) . 'flamingo.php';  // Flamingo updates
    8585        }
    8686
     
    126126        } else {
    127127
    128             WPCF7::update_option( 'iqfix_recaptcha',        $selection  );
    129             WPCF7::update_option( 'iqfix_recaptcha_source', $source     );
     128            \WPCF7::update_option( 'iqfix_recaptcha',       $selection  );
     129            \WPCF7::update_option( 'iqfix_recaptcha_source', $source    );
    130130
    131131        }
     
    209209
    210210        $updated        = $this->save_recaptcha_settings();
    211         $cf7_version    = ( defined( 'WPCF7_VERSION' ) ) ? WPCF7_VERSION : WPCF7::get_option( 'version', '0' );
     211        $cf7_version    = ( defined( 'WPCF7_VERSION' ) ) ? WPCF7_VERSION : \WPCF7::get_option( 'version', '0' );
    212212
    213213        // Grab Network Settings
     
    223223        } else {
    224224
    225             $selection  = WPCF7::get_option( 'iqfix_recaptcha' );
    226             $source     = WPCF7::get_option( 'iqfix_recaptcha_source' );
     225            $selection  = \WPCF7::get_option( 'iqfix_recaptcha' );
     226            $source     = \WPCF7::get_option( 'iqfix_recaptcha_source' );
    227227
    228228        }
Note: See TracChangeset for help on using the changeset viewer.