This commit is contained in:
2026-04-26 23:47:49 +02:00
parent 1b95f03d1e
commit b073e009d8
5288 changed files with 1112699 additions and 55536 deletions

View File

@@ -0,0 +1,116 @@
<?php
/**
* General Configuration Settings
*/
$api_key = PPW_Recaptcha::get_instance()->get_recaptcha_v3_api_key();
$api_key_v2 = PPW_Recaptcha::get_instance()->get_recaptcha_v2_api_key();
$api_secret = PPW_Recaptcha::get_instance()->get_recaptcha_v3_api_secret();
$api_secret_v2 = PPW_Recaptcha::get_instance()->get_recaptcha_v2_api_secret();
$score = PPW_Recaptcha::get_instance()->get_limit_score();
?>
<div class="ppw_main_container" id="ppw_shortcodes_form">
<table class="ppwp_settings_table" cellpadding="4">
<td colspan="2">
<div style="margin-bottom: 1rem">
<h3 style="text-transform: none; margin-bottom: 0.5rem">
<?php echo esc_html__('Configure reCAPTCHA key','password-protect-page'); ?></h3>
<a rel="noopener" target="_blank" href="https://g.co/recaptcha/v3"><?php echo esc_html__('Get the Site Key and Secret Key','password-protect-page');?></a><?php echo esc_html__('from Google','password-protect-page')?>
</div>
</td>
</table>
<form id="wpp_external_v3_form" method="post">
<input type="hidden" id="ppw_general_form_nonce"
value="<?php echo esc_attr( wp_create_nonce( PPW_Constants::GENERAL_FORM_NONCE ) ); ?>"/>
<table class="ppwp_settings_table" cellpadding="4">
<tr id="wpp_recaptcha_configs">
<td class="feature-input">
<span class="feature-input"></span>
</td>
<td>
<p>
<label><?php echo esc_html__( 'reCAPTCHA v3', 'password-protect-page' ) ?></label>
</p>
<span>
<p>
<label><?php echo esc_html__( 'Site Key', 'password-protect-page' ) ?></label>
</p>
<span class="ppwp-recaptcha-input">
<input id="<?php echo esc_attr( PPW_Constants::RECAPTCHA_API_KEY ); ?>" type="text"
value="<?php echo esc_attr( $api_key ); ?>"/>
<div id="ppwp-error-require-v3-key" style="display: none; color: red; position: absolute; font-size: 12px;">This field is required.</div>
</span>
<p>
<label class="ppwp-title"><?php echo esc_html__( 'Secret Key', 'password-protect-page' ) ?></label>
</p>
<span class="ppwp-recaptcha-input">
<input id="<?php echo esc_attr( PPW_Constants::RECAPTCHA_API_SECRET ); ?>" type="text"
value="<?php echo esc_attr( $api_secret ); ?>"/>
</span>
<div id="ppwp-error-require-v3-secret" style="display: none; color: red; position: absolute; font-size: 12px;">This field is required.</div>
<p id="recaptcha-score-container">
<label class="ppwp-title"><?php echo esc_html__( 'Threshold', 'password-protect-page' ) ?></label>
Define users' score that will pass reCAPTCHA protection
<span class="ppw-recaptcha-score">
<select class="ppw_main_container select"
id="<?php echo esc_attr( PPW_Constants::RECAPTCHA_SCORE ); ?>">
<?php
for ( $i = 0; $i <= 10; $i ++ ) {
$s = number_format( ( $i / 10 ), 1 );
$selected = (double) $s === $score ? 'selected="selected"' : '';
echo '<option value="' . esc_attr( $s ) . '"' . esc_html( $selected ) . '>' . esc_html( $s ) . '</option>';
}
?>
</select>
</span>
</p>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="v3_submit_btn" id="submit" class="button button-primary v3_submit_btn" value="Save Changes">
</td>
</tr>
</table>
</form>
<form id="wpp_external_v2_form" method="post">
<table class="ppwp_settings_table" cellpadding="4">
<tr id="wpp_recaptcha_configs">
<td class="feature-input">
<span class="feature-input"></span>
</td>
<td>
<p>
<label><?php echo esc_html__( 'reCAPTCHA v2 - Checkbox', 'password-protect-page' ); ?></label>
</p>
<span>
<p>
<label><?php echo esc_html__( 'Site Key', 'password-protect-page' ) ?></label>
</p>
<span class="ppwp-recaptcha-input">
<input id="<?php echo esc_attr( PPW_Constants::RECAPTCHA_V2_CHECKBOX_API_KEY ); ?>" type="text"
value="<?php echo esc_attr( $api_key_v2 ); ?>"/>
</span>
<div id="ppwp-error-require-v2-key" style="display: none; color: red; position: absolute; font-size: 12px;"><?php echo esc_html__('This field is required.','password-protect-page');?> </div>
<p>
<label class="ppwp-title"><?php echo esc_html__( 'Secret Key', 'password-protect-page' ) ?></label>
</p>
<span class="ppwp-recaptcha-input">
<input id="<?php echo esc_attr( PPW_Constants::RECAPTCHA_V2_CHECKBOX_API_SECRET ); ?>" type="text"
value="<?php echo esc_attr( $api_secret_v2 ); ?>"/>
</span>
<div id="ppwp-error-require-v2-secret" style="display: none; color: red; position: absolute; font-size: 12px;"><?php echo esc_html__('This field is required.','password-protect-page');?></div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="v2_submit_btn" id="submit" class="button button-primary recaptcha-btn" value="Save Changes">
</td>
</tr>
</table>
</form>
</div>

View File

@@ -0,0 +1,80 @@
<?php
/**
* PPWP General Settings
*/
$using_recaptcha = PPW_Recaptcha::get_instance()->using_recaptcha() ? 'checked' : '';
$recaptcha_type = PPW_Recaptcha::get_instance()->get_recaptcha_type();
$password_types = PPW_Recaptcha::get_instance()->get_password_types();
$type_options = array(
PPW_Recaptcha::RECAPTCHA_V3_TYPE => __( 'reCAPTCHA v3', 'password-protect-page' ),
PPW_Recaptcha::RECAPTCHA_V2_CHECKBOX_TYPE => __( 'reCAPTCHA v2 - Checkbox', 'password-protect-page' ),
);
$password_type_options = array(
PPW_Recaptcha::SINGLE_PASSWORD => __( 'Single password form', 'password-protect-page' ),
PPW_Recaptcha::SITEWIDE_PASSWORD => __( 'Sitewide login form', 'password-protect-page' ),
PPW_Recaptcha::PCP_PASSWORD => __( 'PCP password form', 'password-protect-page' ),
);
?>
<div class="ppw_main_container" id="ppw_shortcodes_form">
<form id="wpp_external_form" method="post">
<input type="hidden" id="ppw_general_form_nonce"
value="<?php echo esc_attr( wp_create_nonce( PPW_Constants::GENERAL_FORM_NONCE ) ); ?>"/>
<table class="ppwp_settings_table" cellpadding="4">
<tr>
<td>
<label class="pda_switch" for="<?php echo esc_attr( PPW_Constants::USING_RECAPTCHA ); ?>">
<input type="checkbox"
id="<?php echo esc_attr( PPW_Constants::USING_RECAPTCHA ); ?>" <?php echo esc_html( $using_recaptcha ); ?>>
<span class="pda-slider round"></span>
</label>
</td>
<td>
<p style="margin-bottom: 6px;">
<label><?php esc_attr_e( 'Enable Google reCAPTCHA Protection', 'password-protect-page' ) ?></label>
<a rel="noopener" target="_blank" href="https://passwordprotectwp.com/docs/add-google-recaptcha-wordpress-password-form/?utm_source=user-website&utm_medium=integration-recaptcha&utm_campaign=ppwp-free"><?php echo esc_html__('Protect
your password form','password-protect-page')?></a>
<?php echo esc_html__('from abuse and spam while allowing real user access only','password-protect-page');?>
</p>
<div
<?php echo $using_recaptcha ? '' : 'style="display: none"'; ?>
id="wpp_recaptcha_options">
<div>
<p><?php esc_attr_e( 'Choose reCAPTCHA type', 'password-protect-page' ); ?></p>
<select
class="ppw_main_container select"
id="wpp_recaptcha_type">
<?php
foreach ( $type_options as $key => $value ) {
$selected = $key === $recaptcha_type ? 'selected="selected"' : '';
echo '<option value="' . esc_attr( $key ) . '" ' . esc_html( $selected ) . '>' . esc_html( $value ) . '</option>';
}
?>
<option value="recaptcha_v2_invisible"
disabled><?php echo esc_html__( 'reCAPTCHA v2 - Invisible', 'password-protect-page' ); ?></option>
</select>
</div>
<div style="max-width: 25rem;">
<p><?php esc_attr_e( 'Choose which password form to apply reCAPTCHA', 'password-protect-page' ); ?></p>
<select id="wpp_recaptcha_password_types" class="ppw_main_container select ppw_select_types" required multiple="multiple">
<?php
foreach ( $password_type_options as $key => $value ) {
$selected = in_array( $key, $password_types) ? 'selected="selected"' : '';
echo '<option value="' . esc_attr( $key ) . '" ' . esc_html( $selected ) . '>' . esc_html( $value ) . '</option>';
}
?>
</select>
</div>
</div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
</td>
</tr>
</table>
</form>
</div>