Plugin Directory

Changeset 3414300


Ignore:
Timestamp:
12/08/2025 12:57:28 PM (4 months ago)
Author:
bestwebsoft
Message:

"V1.85 - * The compatibility with new WordPress version updated. "

Location:
google-captcha
Files:
180 added
6 edited

Legend:

Unmodified
Added
Removed
  • google-captcha/trunk/bws_menu/bws_functions.php

    r3350451 r3414300  
    806806            $jquery_ui_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1';
    807807            WP_Filesystem();
    808             if ( ! $wp_filesystem->exists( dirname( __FILE__ ) . '/css/jquery-ui-styles/' . $jquery_ui_version . '/' ) ) {
     808            if ( ! empty( $wp_filesystem->link ) && ! $wp_filesystem->exists( dirname( __FILE__ ) . '/css/jquery-ui-styles/' . $jquery_ui_version . '/' ) ) {
    809809                $jquery_ui_version = '1.12.1';
    810810            }
  • google-captcha/trunk/google-captcha.php

    r3350451 r3414300  
    77Text Domain: google-captcha
    88Domain Path: /languages
    9 Version: 1.84
     9Version: 1.85
    1010Author URI: https://bestwebsoft.com/
    1111License: GPLv3 or later
     
    138138            gglcptch_add_actions();
    139139        }
    140     }
     140
     141        if ( isset( $gglcptch_options['hide_login'] ) && isset( $gglcptch_options['slug_login'] ) && ! empty( $gglcptch_options['slug_login'] ) ) {
     142            $request_url = sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ) );
     143            add_filter( 'site_url', 'gglcptch_check_login_url', 10, 4 );
     144            add_action( 'login_init', 'gglcptch_login_head', 10 );
     145            add_action( 'login_form', 'gglcptch_add_field' );
     146
     147            add_filter( 'lostpassword_url',  'gglcptch_lostpassword', 10 );
     148            add_filter( 'lostpassword_redirect', 'gglcptch_lostpassword_redirect', 100 );
     149           
     150            global $pagenow;
     151            if ( ( false !== strpos( $request_url, '/admin' ) || false !== strpos( $request_url, '/wp-admin' ) || false !== strpos( $request_url, '/dashboard' ) ) && 'index.php' === $pagenow ) {
     152                $url = get_site_url() . '/?' . $gglcptch_options['slug_login'];
     153                wp_safe_redirect( $url );
     154                exit();
     155            }
     156
     157            if ( false !== strpos( wp_parse_url( $request_url, PHP_URL_QUERY ), $gglcptch_options['slug_login'] ) && false === strpos( $request_url, 'wp-login.php' ) ) {
     158                $pagenow = 'wp-login.php';
     159                require_once( ABSPATH . 'wp-login.php' );
     160        exit;
     161            }
     162        }
     163    }
     164}
     165
     166if ( ! function_exists( 'gglcptch_check_login_url' ) ) {
     167    /**
     168     * Change login URI
     169     */
     170    function gglcptch_check_login_url( $url, $path, $scheme, $blog_id ) {
     171        global $gglcptch_options;
     172        $parsed_url = wp_parse_url( $url );
     173
     174        if ( strpos( $url, 'wp-login.php' ) === false || empty( $gglcptch_options['slug_login'] ) ) {
     175            return $url;
     176        }
     177
     178        $args = explode( '?', $url );
     179
     180        if ( isset( $args[1] ) ) {
     181            parse_str( $args[1], $args );
     182            if ( ! array_key_exists( $gglcptch_options['slug_login'], $args ) ) {
     183                $args[ $gglcptch_options['slug_login'] ] = 1;
     184            }
     185            $url = add_query_arg( $args, get_site_url() . '/?' . $gglcptch_options['slug_login'] );
     186        } else {
     187            $url = get_site_url() . '/?' . $gglcptch_options['slug_login'];
     188        }
     189        return $url;
     190    }
     191}
     192
     193if ( ! function_exists( 'gglcptch_login_head' ) ) {
     194    /**
     195     * Changed for login page
     196     */
     197    function gglcptch_login_head() {
     198    global $gglcptch_options;
     199    if ( isset( $_GET['action'] ) && ( isset( $_GET['key'] ) || 'resetpass' === sanitize_text_field( wp_unslash( $_GET['action'] ) ) || 'rp' === sanitize_text_field( $_GET['action'] ) ) ) {
     200            return;
     201        }
     202 
     203    if ( isset( $_POST['redirect_slug'] ) && $gglcptch_options['slug_login'] === sanitize_text_field( wp_unslash( $_POST['redirect_slug'] ) ) ) {
     204            return false;
     205        }
     206
     207    $request_url = sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ) );
     208
     209    if ( false !== strpos( $request_url, 'action=logout' ) ) {
     210      check_admin_referer( 'log-out' );
     211      wp_logout();
     212      wp_safe_redirect( home_url(), 302 );
     213      die;
     214    }
     215    if ( false === strpos( $request_url, $gglcptch_options['slug_login'] ) && ( false !== strpos( $request_url, 'wp-login' ) || false !== strpos( $request_url, 'login' ) ) ) {
     216      wp_safe_redirect( home_url( $gglcptch_options['login_error_redirection'] ), 302 );
     217      exit();
     218    }
     219  }
     220}
     221
     222if ( ! function_exists( 'gglcptch_add_field' ) ) {
     223    /**
     224     * Add field for login form
     225     */
     226  function gglcptch_add_field() {
     227        global $gglcptch_options;
     228    echo '<input type="hidden" name="redirect_slug" value="' . esc_attr( $gglcptch_options['slug_login'] ) . '" />';
     229  }
     230}
     231
     232if ( ! function_exists( 'gglcptch_lostpassword_redirect' ) ) {
     233    /**
     234     * Change lost password link in email
     235     */
     236  function gglcptch_lostpassword_redirect( $lostpassword_redirect ) {
     237    global $gglcptch_options;
     238    return 'wp-login.php?checkemail=confirm&redirect=false&' . $gglcptch_options['slug_login'];
     239  }
     240}
     241
     242if ( ! function_exists( 'gglcptch_lostpassword' ) ) {
     243    /**
     244     * Change lost password link
     245     */
     246  function gglcptch_lostpassword() {
     247    global $gglcptch_options;
     248    return site_url( 'wp-login.php?action=lostpassword&' . $gglcptch_options['slug_login'] . '&redirect=false' );
     249  }
    141250}
    142251
     
    512621            'all_day'                 => array( 1, 2, 3, 4, 5, 6, 7 ),
    513622            'hours'                   => array(),
    514         );
     623            'hide_login'              => 0,
     624            'slug_login'              => '',
     625            'login_error_redirection' => '404',
     626    );
    515627
    516628        if ( function_exists( 'get_editable_roles' ) ) {
     
    14491561add_action( 'admin_menu', 'gglcptch_admin_menu' );
    14501562
    1451 add_action( 'init', 'gglcptch_init' );
     1563add_action( 'init', 'gglcptch_init', 10 );
    14521564add_action( 'admin_init', 'gglcptch_admin_init' );
    14531565
  • google-captcha/trunk/includes/class-gglcptch-settings-tabs.php

    r3350451 r3414300  
    2323            $tabs = array(
    2424                'settings'    => array( 'label' => __( 'Settings', 'google-captcha' ) ),
     25                'hide_login'  => array( 'label' => __( 'Hide Login', 'google-captcha' ) ),
    2526                'misc'        => array( 'label' => __( 'Misc', 'google-captcha' ) ),
    2627                'custom_code' => array( 'label' => __( 'Custom Code', 'google-captcha' ) ),
     
    143144                        $this->options[ $role ] = isset( $_POST[ 'gglcptch_' . $role ] ) ? 1 : 0;
    144145                    }
     146                }
     147
     148                $this->options['hide_login']  = isset( $_POST['gglcptch_hide_login'] ) ? 1 : 0;
     149                $new_login_slug = isset( $_POST['gglcptch_slug_login'] ) ? sanitize_text_field( wp_unslash( $_POST['gglcptch_slug_login'] ) ) : '';
     150                if ( 1 === $this->options['hide_login'] && empty( $new_login_slug ) ) {
     151                    $error = __( 'Cannot set Slug for Login page to home page.', 'google-captcha' );
     152                } elseif ( in_array( $new_login_slug, [ $this->options['login_error_redirection'], 'wp-admin', 'wp-login', 'wp-login.php', 'login'] ) ) {
     153                    $error = __( 'Cannot set login to reserved URLs or the redirection page.', 'google-captcha' );
     154                } else {
     155                    $this->options['slug_login'] = $new_login_slug;
     156                }
     157                $login_error_redirection = isset( $_POST['gglcptch_login_error_redirection'] ) ? sanitize_text_field( wp_unslash( $_POST['gglcptch_login_error_redirection'] ) ) : '';
     158                if ( in_array( $login_error_redirection, [ $this->options['slug_login'], 'wp-admin', 'wp-login', 'wp-login.php', 'login'] ) ) {
     159                    $error = __( 'Cannot set redirection to reserved URLs or the new login page.', 'google-captcha' );
     160                } else {
     161                    $this->options['login_error_redirection'] = $login_error_redirection;
    145162                }
    146163
     
    514531
    515532        /**
     533         * Displays 'hide login' menu-tab
     534         *
     535         * @access public
     536         * @param void
     537         * @return void
     538         */
     539        public function tab_hide_login() {
     540            global $gglcptch_languages, $wp_version, $gglcptch_options;
     541            ?>
     542            <h3 class="bws_tab_label"><?php esc_html_e( 'Hide Login Settings', 'google-captcha' ); ?></h3>
     543            <?php $this->help_phrase(); ?>
     544            <hr>
     545            <table class="form-table gglcptch_settings_form">
     546                <tr valign="top">
     547                    <th scope="row">
     548                        <?php esc_html_e( 'Hide Login page', 'google-captcha' ); ?>
     549                    </th>
     550                    <td>
     551                        <input id="gglcptch_hide_login" name="gglcptch_hide_login" type="checkbox" value="1" <?php echo checked( $this->options['hide_login'] ); ?>>
     552                    </td>
     553                </tr>
     554                <tr class="gglcptch_login_slug" valign="top" <?php echo empty( $this->options['hide_login'] ) || 0 === $this->options['hide_login'] ? 'style="display:none;"' : '';  ?>>
     555                    <th scope="row">
     556                        <?php esc_html_e( 'Slug for Login page', 'google-captcha' ); ?>
     557                    </th>
     558                    <td>
     559                        <input name="gglcptch_slug_login" type="text" value="<?php echo $this->options['slug_login']; ?>">
     560                        <span class="bws_info" style="display: block;"><?php printf( __( 'Access to the login page will only be possible from this URL: %s', 'google-captcha' ), home_url( ! empty( $this->options['slug_login'] ) ? '?' . $this->options['slug_login'] : '?slug_page' ) ); ?></span>
     561                        <span class="bws_info warning" style="display: block;"><?php _e( 'The slug must be unique to the site.', 'google-captcha' ); ?></span>
     562                    </td>
     563                </tr>
     564                <tr class="gglcptch_login_slug" <?php echo empty( $this->options['hide_login'] ) || 0 === $this->options['hide_login'] ? 'style="display:none;"' : '';  ?>>
     565                    <th scope="row">
     566                        <?php esc_html_e( 'Redirection', 'google-captcha' ); ?>
     567                    </th>
     568                    <td>
     569                        <input name="gglcptch_login_error_redirection" type="text" value="<?php echo $this->options['login_error_redirection']; ?>">
     570                        <span class="bws_info" style="display: block;"><?php _e( 'This page shown when accessing the login page with the wrong URL, leaving it empty will redirect to the home page', 'google-captcha' ); ?></span>
     571                    </td>
     572                   
     573                </tr>
     574            </table>
     575            <?php
     576        }
     577
     578        /**
    516579         * Display custom error\message\notice
    517580         *
  • google-captcha/trunk/js/admin_script.js

    r3236168 r3414300  
    7979            }
    8080        } );
     81
     82        /*  Hide login block */
     83        $( '#gglcptch_hide_login' ).on( 'change', function() {
     84            if ( $( this ).is( ':checked' ) ) {
     85                $( '.gglcptch_login_slug' ).show();
     86            } else {
     87                $( '.gglcptch_login_slug' ).hide();
     88            }
     89        } );
    8190    } );
    8291
  • google-captcha/trunk/js/script.js

    r3153390 r3414300  
    4242         */
    4343        if ( 'v2' == gglcptch.options.version || 'invisible' == gglcptch.options.version ) {
    44             $( '.g-recaptcha' ).each( function() {
    45                 /* reCAPTCHA will be generated into the empty block only */
    46                 if ( $( this ).html() === '' && $( this ).text() === '' ) {
    47 
    48                     /* get element`s ID */
    49                     var container = $( this ).attr( 'id' );
    50 
    51                     if ( typeof container == 'undefined' ) {
    52                         container = get_id();
    53                         $( this ).attr( 'id', container );
    54                     }
    55 
    56                     /* get reCapatcha parameters */
    57                     var sitekey  = $( this ).attr( 'data-sitekey' ),
    58                         theme    = $( this ).attr( 'data-theme' ),
    59                         lang     = $( this ).attr( 'data-lang' ),
    60                         size     = $( this ).attr( 'data-size' ),
    61                         type     = $( this ).attr( 'data-type' ),
    62                         tabindex = $( this ).attr( 'data-tabindex' ),
    63                         callback = $( this ).attr( 'data-callback' ),
    64                         ex_call  = $( this ).attr( 'data-expired-callback' ),
    65                         stoken   = $( this ).attr( 'data-stoken' ),
    66                         params   = [];
    67 
    68                     params['sitekey'] = sitekey ? sitekey : gglcptch.options.sitekey;
    69                     if ( !! theme ) {
    70                         params['theme'] = theme;
    71                     }
    72                     if ( !! lang ) {
    73                         params['lang'] = lang;
    74                     }
    75                     if ( !! size ) {
    76                         params['size'] = size;
    77                     }
    78                     if ( !! type ) {
    79                         params['type'] = type;
    80                     }
    81                     if ( !! tabindex ) {
    82                         params['tabindex'] = tabindex;
    83                     }
    84                     if ( !! callback ) {
    85                         params['callback'] = callback;
    86                     }
    87                     if ( !! ex_call ) {
    88                         params['expired-callback'] = ex_call;
    89                     }
    90                     if ( !! stoken ) {
    91                         params['stoken'] = stoken;
    92                     }
    93 
    94                     gglcptch.display( container, params );
    95                 }
    96             } );
    97 
    9844            /*
    9945             * count the number of reCAPTCHA blocks in the form
  • google-captcha/trunk/readme.txt

    r3350451 r3414300  
    44Tags: anti-spam security, antispam, recaptcha, captcha, captha, Invisible reCaptcha, Invisible captcha, Invisibl reCaptcha, comment, cpatcha, google catcha, Invisible re captcha, recaptcha version3
    55Requires at least: 5.6
    6 Tested up to: 6.8
    7 Stable tag: 1.84
     6Tested up to: 6.9
     7Stable tag: 1.85
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    5252* Multilingual and RTL ready
    5353* Edit error message
     54* Hide Login page
    5455
    5556> **Pro Features**
     
    107108> * Configure all subsites on the network
    108109> * Block disposable emails
     110> * Administrator Login notification
    109111> * Get answer to your support question within one business day ([Support Policy](https://bestwebsoft.com/support-policy/))
    110112>
     
    297299== Changelog ==
    298300
     301= V1.85 - 08.12.2025 =
     302* Pro : The Administrator Login notification functionality has been added.
     303* NEW : The Hide Login page functionality has been added.
     304* Update : BWS Panel section was updated.
     305* Bugfix : Minor bugs fixed.
     306* Update : All functionality was updated for WordPress 6.8.3.
     307
    299308= V1.84 - 26.08.2025 =
    300309* Pro : The Block disposable emails functionality has been added.
     
    676685== Upgrade Notice ==
    677686
     687= V1.85 =
     688* The compatibility with new WordPress version updated.
     689* New features added.
     690* Bug fixed.
     691
    678692= V1.84 =
    679693* The compatibility with new WordPress version updated.
Note: See TracChangeset for help on using the changeset viewer.