Plugin Directory

Changeset 3226931


Ignore:
Timestamp:
01/22/2025 03:14:12 PM (12 months ago)
Author:
apos37
Message:

1.0.4.3

  • Update: Added plugin option to disable word boundaries in spam filtering
  • Tweak: Update info box on some plugin settings
  • Fix: Remove import link from spam list on client sites
  • Fix: Spam list showing for Client sites even though API and host site URL are missing
  • Tweak: Removed unused source columns
  • Fix: Delete All Spam button from Spam Entries section had a nonce error
Location:
gf-tools
Files:
55 added
6 edited

Legend:

Unmodified
Added
Removed
  • gf-tools/trunk/gf-tools.php

    r3218525 r3226931  
    44 * Plugin URI:          https://apos37.com/wordpress-advanced-tools-for-gravity-forms/
    55 * Description:         Unlock advanced tools to supercharge your Gravity Forms experience with enhanced features and streamlined management.
    6  * Version:             1.0.4.2
     6 * Version:             1.0.4.3
    77 * Requires at least:   5.9.0
    88 * Tested up to:        6.7.1
     
    2626define( 'GFADVTOOLS_TEXTDOMAIN', 'gf-tools' );
    2727define( 'GFADVTOOLS_DISCORD_SUPPORT_URL', 'https://discord.gg/3HnzNEJVnR' );
    28 define( 'GFADVTOOLS_VERSION', '1.0.4.2' );
     28define( 'GFADVTOOLS_VERSION', '1.0.4.3' );
    2929define( 'GFADVTOOLS_ADMIN_INCLUDES_URL', trailingslashit( ABSPATH.str_replace( site_url(), '', admin_url( 'includes/' ) ) ) );  // /abspath/.../public_html/wp-admin/includes/
    3030define( 'GFADVTOOLS_PLUGIN_ROOT', plugin_dir_path( __FILE__ ) );                                                                // /home/.../public_html/wp-content/plugins/gf-tools/
  • gf-tools/trunk/includes/class-dashboard.php

    r3217938 r3226931  
    630630            'form_id'    => __( 'Form ID', 'gf-tools' ),
    631631            'count'      => __( 'Number of Entries', 'gf-tools' ),
    632             'source'     => __( 'Source Page', 'gf-tools' )
     632            // 'source'     => __( 'Source Page', 'gf-tools' )
    633633        ];
    634634
     
    665665
    666666            // TODO: Get the source link if a page is associated with it
    667             $source_link = '';
     667            // $source_link = '';
    668668
    669669            // The data
     
    673673                'form_id'    => $form_id,
    674674                'count'      => $count,
    675                 'source'     => $source_link
     675                // 'source'     => $source_link
    676676            ];
    677677        }
     
    893893            'form_id'    => __( 'Form ID', 'gf-tools' ),
    894894            'count'      => __( 'Number of Spam Entries', 'gf-tools' ),
    895             'source'     => __( 'Source Page', 'gf-tools' ),
     895            // 'source'     => __( 'Source Page', 'gf-tools' ),
    896896            'actions'    => __( 'Actions', 'gf-tools' )
    897897        ];
     
    951951
    952952            // TODO: Get the source link if a page is associated with it
    953             $source_link = '';
     953            // $source_link = '';
    954954
    955955            // Actions
     
    974974                'form_id'    => $form_id,
    975975                'count'      => $count,
    976                 'source'     => $source_link,
     976                // 'source'     => $source_link,
    977977                'actions'    => $actions
    978978            ];
     
    993993        $is_client = ( $location == 'client' );
    994994        $host_site_url = ( $is_client && isset( $this->plugin_settings[ 'spam_list_url' ] ) ) ? sanitize_text_field( $this->plugin_settings[ 'spam_list_url' ] ) : false;
     995        $api_spam_key = ( $is_client && isset( $this->plugin_settings[ 'api_spam_key' ] ) ) ? sanitize_text_field( $this->plugin_settings[ 'api_spam_key' ] ) : false;
    995996        $home_url = home_url();
    996997        $spam_list_created = get_option( 'gfat_spam_list_table_created' );
     998
     999        if ( $is_client && ( !$host_site_url || !$api_spam_key ) ) {
     1000            echo '<em>This site is set up as a Client, but we are missing an API or home site URL. Please enter them in the Plugin Settings.</em>';
     1001            return;
     1002        }
    9971003
    9981004        // Helpers
     
    10161022        // Nonce
    10171023        $nonce = wp_create_nonce( $this->nonce );
    1018         $nonce_verified = isset( $_REQUEST[ '_wpnonce' ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash ( $_REQUEST[ '_wpnonce' ] ) ), $this->nonce );
     1024        $nonce_verified = isset( $_REQUEST[ '_wpnonce' ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST[ '_wpnonce' ] ) ), $this->nonce );
    10191025
    10201026        // Local
     
    12941300                </div>
    12951301                <input type="submit" value="<?php echo esc_html__( 'Submit', 'gf-tools' ); ?>" id="gfat-<?php echo esc_attr( $current_tab ); ?>-search-button" class="button button-primary"/>
    1296                 <a class="import-export-link" href="<?php echo esc_url( add_query_arg( [ 'page' => 'gf_export', 'subview' => 'import_spam_list' ], admin_url( 'admin.php' ) ) ); ?>">Import</a>
     1302                <?php if ( !$is_client ) { ?>
     1303                    <a class="import-export-link" href="<?php echo esc_url( add_query_arg( [ 'page' => 'gf_export', 'subview' => 'import_spam_list' ], admin_url( 'admin.php' ) ) ); ?>">Import</a>
     1304                <?php } ?>
    12971305            </form>
    12981306        </div>
     
    27502758    public function ajax_get_all_spam_entry_ids() {
    27512759        // Verify nonce
    2752         if ( !isset( $_REQUEST[ '_wpnonce' ] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash ( $_REQUEST[ '_wpnonce' ] ) ), $this->nonce ) ) {
     2760        if ( !isset( $_REQUEST[ 'nonce' ] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST[ 'nonce' ] ) ), $this->nonce ) ) {
    27532761            exit( esc_html__( 'No naughty business please.', 'gf-tools' ) );
    27542762        }
     
    27962804    public function ajax_delete_spam_entry() {
    27972805        // Verify nonce
    2798         if ( !isset( $_REQUEST[ '_wpnonce' ] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash ( $_REQUEST[ '_wpnonce' ] ) ), $this->nonce ) ) {
     2806        if ( !isset( $_REQUEST[ 'nonce' ] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST[ 'nonce' ] ) ), $this->nonce ) ) {
    27992807            exit( esc_html__( 'No naughty business please.', 'gf-tools' ) );
    28002808        }
  • gf-tools/trunk/includes/class-gf-tools.php

    r3208804 r3226931  
    525525                        'name'    => 'ajax_saving_group',
    526526                        'label'   => esc_html__( 'Disable AJAX Saving for All Forms', 'gf-tools' ),
    527                         'tooltip' => esc_html__( 'The template library is the popup that you see when you create a new form. If you always start from scratch, this just saves you a step.', 'gf-tools' ),
     527                        'tooltip' => esc_html__( 'This will disable saving the form in the form editor without having to refresh. Sometimes the AJAX will cause conflicts, so this just saves the form on refresh.', 'gf-tools' ),
    528528                        'choices' => [
    529529                            [
     
    676676                        'name'       => 'api_spam_key',
    677677                        'label'      => esc_html__( 'API Key for Remote Spam List Access', 'gf-tools' ),
    678                         'tooltip'    => esc_html__( 'On your host website, choose "Host" in the "Enable Enhanced Spam Filtering" setting above. Then generate an API Key underneath it. Copy this key and enter it here.', 'gf-tools' ),
     678                        'tooltip'    => esc_html__( 'On your client website(s), choose "Client" in the "Enable Enhanced Spam Filtering" setting above. Copy this key and enter it there.', 'gf-tools' ),
    679679                        'class'      => 'large',
    680680                    ],
     
    695695                    ],
    696696                    $incl_delete_spam_list_button,
     697                    [
     698                        'type'    => 'checkbox',
     699                        'name'    => 'disable_word_boundaries_group',
     700                        'label'   => esc_html__( 'Disable Word Boundaries in Spam Filtering', 'gf-tools' ),
     701                        'tooltip' => esc_html__( 'By default, only whole words are matched. For example, the keyword "Pekly" will match "Pekly" but not "HarryPekly." Disabling word boundaries allows matching keywords anywhere, even within other words.', 'gf-tools' ),
     702                        'choices' => [
     703                            [
     704                                'label' => esc_html__( 'Yes', 'gf-tools' ),
     705                                'name'  => 'disable_word_boundaries',
     706                            ],
     707                        ],
     708                    ],
    697709                    [
    698710                        'type'    => 'checkbox',
     
    737749                        'type'    => 'checkbox',
    738750                        'name'    => 'entries_export_roles_group',
    739                         'label'   => wp_kses( __( 'Which Addtional Roles (Besides Administrator) Can Export Entries on <code>[gfat_export_entries]</code> Shortcode', 'gf-tools' ), [ 'code' => [] ] ),
     751                        'label'   => wp_kses( __( 'Which Additional Roles (Besides Administrator) Can Export Entries on <code>[gfat_export_entries]</code> Shortcode', 'gf-tools' ), [ 'code' => [] ] ),
    740752                        'tooltip' => esc_html__( 'The [gfat_export_entries] shortcode can be used to export entries on the front-end. You must also enable "Add to Export Entries Shortcode" in the forms\' Advanced Tools settings.', 'gf-tools' ),
    741753                        'choices' => $role_choices,
  • gf-tools/trunk/includes/class-spam.php

    r3166646 r3226931  
    13411341   
    13421342        // If the field is of type email, text, or textarea
    1343         if ( in_array( $field->type, [ 'email', 'text', 'textarea' ] ) ) {
     1343        if ( in_array( $field->type, [ 'name', 'email', 'text', 'textarea' ] ) ) {
    13441344
    13451345            // $field_id = $field->id;
     
    13741374
    13751375            } else {
     1376
     1377                // Are we disabling word boundaries?
     1378                $disable_word_boundaries = isset( $plugin_settings[ 'disable_word_boundaries' ] ) && $plugin_settings[ 'disable_word_boundaries' ] == 1;
    13761379               
    13771380                // Check text and textarea fields
    13781381                foreach ( $keyword_actions as $keyword => $allowed ) {
    1379                     if ( preg_match( '/\b' . preg_quote( $keyword, '/' ) . '\b/i', $value ) && !$allowed ) {
    1380                         $result[ 'is_valid' ] = false;
    1381                         $result[ 'message' ] = "Keyword '{$keyword}' is not allowed.";
     1382                    $pattern = $disable_word_boundaries
     1383                        ? '/' . preg_quote( $keyword, '/' ) . '/i'
     1384                        : '/\b' . preg_quote( $keyword, '/' ) . '\b/i';
     1385
     1386                    if ( preg_match( $pattern, $value ) && !$allowed ) {
     1387                        $result['is_valid'] = false;
     1388                        $result['message'] = "Keyword '{$keyword}' is not allowed.";
    13821389                        return $result;
    13831390                    }
     
    14821489        }
    14831490
     1491        // Are we disabling word boundaries?
     1492        $disable_word_boundaries = isset( $plugin_settings[ 'disable_word_boundaries' ] ) && $plugin_settings[ 'disable_word_boundaries' ] == 1;
     1493
    14841494        // Initialize spam status flags
    14851495        $is_spam = false;
     
    14881498
    14891499        // Process each field
    1490         $field_types_to_filter = [ 'email', 'text', 'textarea' ];
     1500        $field_types_to_filter = [ 'name', 'email', 'text', 'textarea' ];
    14911501        foreach ( $form[ 'fields' ] as $field ) {
    14921502
     
    15311541                // Check text and textarea fields
    15321542                foreach ( $keyword_actions as $keyword => $allowed ) {
    1533                     if ( preg_match( '/\b' . preg_quote( $keyword, '/' ) . '\b/i', $value ) ) {
     1543                    $pattern = $disable_word_boundaries
     1544                        ? '/' . preg_quote( $keyword, '/' ) . '/i'
     1545                        : '/\b' . preg_quote( $keyword, '/' ) . '\b/i';
     1546
     1547                    if ( preg_match( $pattern, $value ) ) {
    15341548                        $is_spam = !$allowed;
    15351549                        $log_message = "Keyword '$keyword' found in $type field with action '" . ( $allowed ? 'allow' : 'deny' ) . "'.";
  • gf-tools/trunk/includes/js/dashboard.js

    r3166646 r3226931  
    179179
    180180        // Delete all entries
    181         const deleteAllEntries = async () => {
     181        const deleteAllEntries = async ( nonce, formID ) => {
    182182            try {
    183183                // Get the entry IDs to delete
     
    261261
    262262        // Do it
    263         deleteAllEntries();
     263        deleteAllEntries( nonce, formID );
    264264    } );
    265265
  • gf-tools/trunk/readme.txt

    r3218525 r3226931  
    55Requires PHP: 7.4
    66Tested up to: 6.7.1
    7 Stable tag: 1.0.4.2
     7Stable tag: 1.0.4.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    106106
    107107== Changelog ==
     108= 1.0.4.3 =
     109* Update: Added plugin option to disable word boundaries in spam filtering
     110* Tweak: Update info box on some plugin settings
     111* Fix: Remove import link from spam list on client sites
     112* Fix: Spam list showing for Client sites even though API and host site URL are missing
     113* Tweak: Removed unused source columns
     114* Fix: Delete All Spam button from Spam Entries section had a nonce error
     115
    108116= 1.0.4.2 =
    109117* Fix: User meta on report builder wasn't showing up correctly in the report
Note: See TracChangeset for help on using the changeset viewer.