array( 'label' => __( 'Settings', 'google-captcha' ) ),
'misc' => array( 'label' => __( 'Misc', 'google-captcha' ) ),
'custom_code' => array( 'label' => __( 'Custom Code', 'google-captcha' ) ),
'license' => array( 'label' => __( 'License Key', 'google-captcha' ) ),
);
parent::__construct(
array(
'plugin_basename' => $plugin_basename,
'plugins_info' => $gglcptch_plugin_info,
'prefix' => 'gglcptch',
'default_options' => gglcptch_get_default_options(),
'options' => $gglcptch_options,
'tabs' => $tabs,
'doc_link' => 'https://bestwebsoft.com/documentation/recaptcha/recaptcha-user-guide/',
'doc_video_link' => 'https://www.youtube.com/watch?v=ZFv6txtic0Y/',
'wp_slug' => 'google-captcha',
'link_key' => 'b850d949ccc1239cab0da315c3c822ab',
'link_pn' => '109',
)
);
$this->all_plugins = get_plugins();
/* Private and public keys */
$this->keys = array(
'public' => array(
'display_name' => __( 'Site Key', 'google-captcha' ),
'form_name' => 'gglcptch_public_key',
'error_msg' => '',
),
'private' => array(
'display_name' => __( 'Secret Key', 'google-captcha' ),
'form_name' => 'gglcptch_private_key',
'error_msg' => '',
),
);
$this->versions = array(
'v2' => sprintf( '%s 2', __( 'Version', 'google-captcha' ) ),
'v3' => sprintf( '%s 3', __( 'Version', 'google-captcha' ) ),
'invisible' => __( 'Invisible', 'google-captcha' ),
);
/* Supported forms */
$this->forms = gglcptch_get_forms();
$this->sections = gglcptch_get_sections();
add_action( get_parent_class( $this ) . '_display_custom_messages', array( $this, 'display_custom_messages' ) );
add_action( get_parent_class( $this ) . '_additional_misc_options', array( $this, 'additional_misc_options' ) );
add_action( get_parent_class( $this ) . '_display_metabox', array( $this, 'display_metabox' ) );
add_action( get_parent_class( $this ) . '_information_postbox_bottom', array( $this, 'information_postbox_bottom' ) );
}
/**
* Save plugin options to the database
*
* @access public
* @param void
* @return array The action results
*/
public function save_options() {
$message = $notice = $error = '';
if ( ! isset( $_POST['gglcptch_save_field'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['gglcptch_save_field'] ) ), 'gglcptch_save_action' ) ) {
print esc_html__( 'Sorry, your nonce did not verify.', 'google-captcha' );
exit;
} else {
/* Save data for settings page */
if ( empty( $_POST['gglcptch_public_key'] ) ) {
$this->keys['public']['error_msg'] = __( 'Enter site key', 'google-captcha' );
$error = __( 'WARNING: The captcha will not be displayed until you fill key fields.', 'google-captcha' );
} else {
$this->keys['public']['error_msg'] = '';
}
if ( empty( $_POST['gglcptch_private_key'] ) ) {
$this->keys['private']['error_msg'] = __( 'Enter secret key', 'google-captcha' );
$error = __( 'WARNING: The captcha will not be displayed until you fill key fields.', 'google-captcha' );
} else {
$this->keys['private']['error_msg'] = '';
}
if ( sanitize_text_field( wp_unslash( $_POST['gglcptch_public_key'] ) ) !== $this->options['public_key'] || sanitize_text_field( wp_unslash( $_POST['gglcptch_private_key'] ) ) !== $this->options['private_key'] ) {
$this->options['keys_verified'] = false;
}
if ( isset( $_POST['gglcptch_recaptcha_version'] ) && sanitize_text_field( wp_unslash( $_POST['gglcptch_recaptcha_version'] ) ) !== $this->options['recaptcha_version'] ) {
$this->options['keys_verified'] = false;
$this->options['need_keys_verified_check'] = true;
}
$this->options['allowlist_message'] = isset( $_POST['gglcptch_allowlist_message'] ) ? sanitize_text_field( wp_unslash( $_POST['gglcptch_allowlist_message'] ) ) : '';
$this->options['public_key'] = isset( $_POST['gglcptch_public_key'] ) ? sanitize_text_field( wp_unslash( $_POST['gglcptch_public_key'] ) ) : '';
$this->options['private_key'] = isset( $_POST['gglcptch_private_key'] ) ? sanitize_text_field( wp_unslash( $_POST['gglcptch_private_key'] ) ) : '';
$this->options['recaptcha_version'] = in_array( sanitize_text_field( wp_unslash( $_POST['gglcptch_recaptcha_version'] ) ), array( 'v2', 'invisible', 'v3' ), true ) ? sanitize_text_field( wp_unslash( $_POST['gglcptch_recaptcha_version'] ) ) : $this->options['recaptcha_version'];
$this->options['theme_v2'] = isset( $_POST['gglcptch_theme_v2'] ) && in_array( sanitize_text_field( wp_unslash( $_POST['gglcptch_theme_v2'] ) ), array( 'light', 'dark' ), true ) ? sanitize_text_field( wp_unslash( $_POST['gglcptch_theme_v2'] ) ) : $this->options['theme_v2'];
$this->options['score_v3'] = isset( $_POST['gglcptch_score_v3'] ) ? (float) sanitize_text_field( wp_unslash( $_POST['gglcptch_score_v3'] ) ) : 0.5;
$this->options['disable_submit'] = isset( $_POST['gglcptch_disable_submit'] ) ? 1 : 0;
$this->options['hide_badge'] = isset( $_POST['gglcptch_hide_badge'] ) ? 1 : 0;
$this->options['disable_submit_button'] = isset( $_POST['gglcptch_disable_submit_button'] ) ? 1 : 0;
$this->options['use_globally'] = isset( $_POST['gglcptch_use_globally'] ) ? intval( sanitize_text_field( wp_unslash( $_POST['gglcptch_use_globally'] ) ) ) : 0;
foreach ( $this->forms as $form_slug => $form_data ) {
$this->options[ $form_slug ] = isset( $_POST[ 'gglcptch_' . $form_slug ] ) ? 1 : 0;
}
if ( function_exists( 'get_editable_roles' ) ) {
foreach ( get_editable_roles() as $role => $fields ) {
$this->options[ $role ] = isset( $_POST[ 'gglcptch_' . $role ] ) ? 1 : 0;
}
}
$this->options = apply_filters( 'gglcptch_before_save_options', $this->options );
update_option( 'gglcptch_options', $this->options );
$message = __( 'Settings saved.', 'google-captcha' );
}
return compact( 'message', 'notice', 'error' );
}
/**
* Displays 'settings' menu-tab
*
* @access public
* @return void
*/
public function tab_settings() { ?>
help_phrase(); ?>
hide_pro_tabs ) { ?>
bws_pro_block_links(); ?>
hide_pro_tabs ) { ?>
bws_pro_block_links(); ?>
hide_pro_tabs ) { ?>
bws_pro_block_links(); ?>
hide_pro_tabs ) { ?>
bws_pro_block_links(); ?>
options['need_keys_verified_check'] ) ) {
?>
options );
}
public function information_postbox_bottom() {
?>
',
''
);
?>