Skip to content

Commit

Permalink
Fix add_action type hints in all files.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Jul 27, 2023
1 parent 899aa44 commit 14945f7
Show file tree
Hide file tree
Showing 33 changed files with 138 additions and 45 deletions.
2 changes: 2 additions & 0 deletions src/php/ACFE/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public function verify( $valid, string $value, array $field, string $input ) {

/**
* Enqueue scripts.
*
* @return void
*/
public function enqueue_scripts() {
$min = hcap_min_suffix();
Expand Down
3 changes: 2 additions & 1 deletion src/php/Abstracts/LoginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ public function login( string $user_login, WP_User $user ) {
*
* @return void
* @noinspection PhpUnusedParameterInspection
* @noinspection PhpMissingParamTypeInspection
*/
public function login_failed( string $username, WP_Error $error = null ) {
public function login_failed( string $username, $error = null ) {
$this->login_data[ $this->ip ][] = time();

update_option( self::LOGIN_DATA, $this->login_data );
Expand Down
2 changes: 2 additions & 0 deletions src/php/Abstracts/LostPasswordBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ protected function init_hooks() {

/**
* Add captcha.
*
* @return void
*/
public function add_captcha() {
$args = [
Expand Down
1 change: 1 addition & 0 deletions src/php/AutoVerify/AutoVerify.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static function ( $match ) {
/**
* Verify a form automatically.
*
* @return void
* @noinspection ForgottenDebugOutputInspection
*/
public function verify_form() {
Expand Down
3 changes: 3 additions & 0 deletions src/php/BBPress/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ private function init_hooks() {

/**
* Add captcha to the form.
*
* @return void
*/
public function add_captcha() {
$form_id = str_replace( 'hcaptcha_bbp_', '', static::ACTION );
Expand All @@ -52,6 +54,7 @@ public function add_captcha() {
* Verify captcha.
*
* @return bool
* @noinspection PhpUndefinedFunctionInspection
*/
public function verify(): bool {
$error_message = hcaptcha_get_verify_message( static::NAME, static::ACTION );
Expand Down
1 change: 1 addition & 0 deletions src/php/BackInStockNotifier/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function verify( array $post_data, bool $rest_api ) {
* Enqueue Back In Stock Notifier script.
*
* @return void
* @noinspection PhpUndefinedFunctionInspection
*/
public function enqueue_scripts() {
if ( is_shop() ) {
Expand Down
2 changes: 2 additions & 0 deletions src/php/BuddyPress/CreateGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ private function init_hooks() {

/**
* Add captcha to the group form.
*
* @return void
*/
public function add_captcha() {
echo '<div class="hcap_buddypress_group_form">';
Expand Down
2 changes: 2 additions & 0 deletions src/php/CF7/CF7.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ private function get_invalidated_result( WPCF7_Validation $result, string $captc

/**
* Enqueue CF7 scripts.
*
* @return void
*/
public function enqueue_scripts() {
if ( ! hcaptcha()->form_shown ) {
Expand Down
2 changes: 2 additions & 0 deletions src/php/ColorlibCustomizer/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ protected function init_hooks() {

/**
* Print styles to fit hcaptcha widget to the login form.
*
* @return void
*/
public function login_head() {
$settings = hcaptcha()->settings();
Expand Down
2 changes: 2 additions & 0 deletions src/php/Divi/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public function shortcode_attributes( $props, array $attrs, string $slug, string

/**
* Enqueue scripts.
*
* @return void
*/
public function enqueue_scripts() {
$min = hcap_min_suffix();
Expand Down
2 changes: 2 additions & 0 deletions src/php/Divi/Fix.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function init_hooks() {

/**
* Register autoload.
*
* @return void
*/
public function register_autoload() {
if ( ! defined( 'ET_BUILDER_THEME' ) ) {
Expand Down
13 changes: 13 additions & 0 deletions src/php/ElementorPro/HCaptchaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public function __construct() {

/**
* Enqueue elementor support script.
*
* @return void
*/
public function after_enqueue_scripts() {
$min = hcap_min_suffix();
Expand All @@ -69,6 +71,8 @@ public function after_enqueue_scripts() {

/**
* Add hooks.
*
* @return void
*/
public function init() {
$this->register_scripts();
Expand Down Expand Up @@ -101,6 +105,8 @@ public function init() {
* Register action.
*
* @param Module $module Module.
*
* @return void
*/
public function register_action( Module $module ) {
$module->add_component( self::FIELD_ID, $this );
Expand Down Expand Up @@ -238,6 +244,8 @@ private function register_scripts() {

/**
* Enqueue scripts.
*
* @return void
*/
public function enqueue_scripts() {
$this->main->print_inline_styles();
Expand All @@ -251,6 +259,8 @@ public function enqueue_scripts() {
*
* @param Form_Record $record Record.
* @param Ajax_Handler $ajax_handler Ajax handler.
*
* @return void
*/
public function validation( Form_Record $record, Ajax_Handler $ajax_handler ) {
$fields = $record->get_field( [ 'type' => static::get_hcaptcha_name() ] );
Expand Down Expand Up @@ -285,6 +295,8 @@ public function validation( Form_Record $record, Ajax_Handler $ajax_handler ) {
* @param array $item Item.
* @param int $item_index Item index.
* @param Widget_Base $widget Widget.
*
* @return void
*/
public function render_field( array $item, int $item_index, Widget_Base $widget ) {
$hcaptcha_html = '<div class="elementor-field" id="form-field-' . $item['custom_id'] . '">';
Expand Down Expand Up @@ -360,6 +372,7 @@ public function add_field_type( $field_types ): array {
* @param Controls_Stack $controls_stack The controls stack.
* @param array $args Section arguments.
*
* @return void
* @noinspection PhpUnusedParameterInspection
*/
public function modify_controls( Controls_Stack $controls_stack, array $args ) {
Expand Down
1 change: 1 addition & 0 deletions src/php/FluentForm/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private function init_hooks() {
* @param array $submit_button Form data and settings.
* @param stdClass $form Form data and settings.
*
* @return void
* @noinspection PhpUnusedParameterInspection
*/
public function add_captcha( array $submit_button, stdClass $form ) {
Expand Down
12 changes: 5 additions & 7 deletions src/php/Forminator/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct() {
*/
public function init_hooks() {
add_action( 'forminator_before_form_render', [ $this, 'before_form_render' ], 10, 5 );
add_action( 'forminator_render_button_markup', [ $this, 'add_hcaptcha' ], 10, 2 );
add_filter( 'forminator_render_button_markup', [ $this, 'add_hcaptcha' ], 10, 2 );
add_filter( 'forminator_cform_form_is_submittable', [ $this, 'verify' ], 10, 3 );
}

Expand All @@ -63,20 +63,18 @@ public function init_hooks() {
* @param array $form_fields Form fields.
* @param array $form_settings Form settings.
*
* @return int
* @return void
* @noinspection PhpUnusedParameterInspection
*/
public function before_form_render( int $id, string $form_type, int $post_id, array $form_fields, array $form_settings ): int {
$this->form_id = $id;

return $id;
}

/**
* Add hCaptcha.
*
* @param string $html Shortcode output.
* @param string $button Shortcode name.
* @param string|mixed $html Shortcode output.
* @param string $button Shortcode name.
*
* @return string
* @noinspection PhpUnusedParameterInspection
Expand All @@ -93,7 +91,7 @@ public function add_hcaptcha( string $html, string $button ): string {

$hcaptcha = HCaptcha::form( $args );

return str_replace( '<button ', $hcaptcha . '<button ', $html );
return str_replace( '<button ', $hcaptcha . '<button ', (string) $html );
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/php/GiveWP/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ private function init_hooks() {
* Add captcha to the form.
*
* @param int $form_id Form id.
*
* @return void
*/
public function add_captcha( int $form_id ) {
$args = [
Expand All @@ -54,6 +56,7 @@ public function add_captcha( int $form_id ) {
*
* @param bool|array $valid_data Validate fields.
*
* @return void
* @noinspection PhpUndefinedFunctionInspection
* @noinspection PhpUnusedParameterInspection
*/
Expand Down
9 changes: 4 additions & 5 deletions src/php/Mailchimp/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct() {
*/
private function init_hooks() {
add_filter( 'mc4wp_form_messages', [ $this, 'add_hcap_error_messages' ], 10, 2 );
add_action( 'mc4wp_form_content', [ $this, 'add_captcha' ], 20, 3 );
add_filter( 'mc4wp_form_content', [ $this, 'add_captcha' ], 20, 3 );
add_filter( 'mc4wp_form_errors', [ $this, 'verify' ], 10, 2 );
}

Expand Down Expand Up @@ -72,15 +72,14 @@ public function add_hcap_error_messages( $messages, MC4WP_Form $form ) {
/**
* Add hcaptcha to MailChimp form.
*
* @param string $content Content.
* @param string|mixed $content Content.
* @param MC4WP_Form $form Form.
* @param MC4WP_Form_Element $element Element.
*
* @return string
* @noinspection PhpUnusedParameterInspection
* @noinspection PhpUndefinedFieldInspection
*/
public function add_captcha( string $content, MC4WP_Form $form, MC4WP_Form_Element $element ): string {
public function add_captcha( $content, MC4WP_Form $form, MC4WP_Form_Element $element ): string {
$args = [
'action' => self::ACTION,
'name' => self::NAME,
Expand All @@ -94,7 +93,7 @@ public function add_captcha( string $content, MC4WP_Form $form, MC4WP_Form_Eleme
'<input type="submit"',
HCaptcha::form( $args ) .
'<input type="submit"',
$content
(string) $content
);
}

Expand Down
11 changes: 11 additions & 0 deletions src/php/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public function init() {

/**
* Init hooks.
*
* @return void
*/
public function init_hooks() {
$this->settings = new Settings(
Expand Down Expand Up @@ -299,6 +301,8 @@ public function csp_headers( $headers ): array {

/**
* Print inline styles.
*
* @return void
*/
public function print_inline_styles() {
$url = HCAPTCHA_URL . '/assets/images/hcaptcha-div-logo.svg';
Expand Down Expand Up @@ -419,6 +423,8 @@ public function print_inline_styles() {

/**
* Print styles to fit hcaptcha widget to the login form.
*
* @return void
*/
public function login_head() {
?>
Expand Down Expand Up @@ -473,6 +479,8 @@ public function get_api_src(): string {

/**
* Add the hCaptcha script to footer.
*
* @return void
*/
public function print_footer_scripts() {
if ( is_admin() ) {
Expand Down Expand Up @@ -624,6 +632,7 @@ static function ( $ip ) {
/**
* Load plugin modules.
*
* @return void
* @noinspection PhpFullyQualifiedNameUsageInspection
*/
public function load_modules() {
Expand Down Expand Up @@ -1031,6 +1040,8 @@ private function plugin_or_theme_active( $plugin_or_theme_names ): bool {

/**
* Load plugin text domain.
*
* @return void
*/
public function load_textdomain() {
load_plugin_textdomain(
Expand Down
6 changes: 5 additions & 1 deletion src/php/MemberPress/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ protected function init_hooks() {
parent::init_hooks();

add_action( 'mepr-login-form-before-submit', [ $this, 'add_captcha' ] );
add_action( 'wp_authenticate_user', [ $this, 'verify' ], 10, 2 );
add_filter( 'wp_authenticate_user', [ $this, 'verify' ], 10, 2 );
}

/**
* Add hCaptcha to the Register form.
*
* @return void
*/
public function add_captcha() {
if ( ! $this->is_login_limit_exceeded() ) {
Expand All @@ -59,6 +61,8 @@ public function add_captcha() {
/**
* Verify login form.
*
* @since 1.0
*
* @param WP_User|WP_Error $user WP_User or WP_Error object if a previous
* callback failed authentication.
* @param string $password Password to check against the user.
Expand Down
2 changes: 2 additions & 0 deletions src/php/MemberPress/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ private function init_hooks() {

/**
* Add hCaptcha to the Register form.
*
* @return void
*/
public function add_captcha() {
$args = [
Expand Down
2 changes: 2 additions & 0 deletions src/php/NF/NF.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public function localize_field( $field ): array {

/**
* Enqueue script.
*
* @return void
*/
public function nf_captcha_script() {
$min = hcap_min_suffix();
Expand Down
2 changes: 2 additions & 0 deletions src/php/PaidMembershipsPro/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ protected function init_hooks() {

/**
* Add captcha.
*
* @return void
*/
public function add_captcha() {
$args = [
Expand Down
2 changes: 1 addition & 1 deletion src/php/PaidMembershipsPro/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function init_hooks() {
$pmpro_page_name = 'login';

add_filter( 'pmpro_pages_shortcode_' . $pmpro_page_name, [ $this, 'add_captcha' ] );
add_action( 'wp_authenticate_user', [ $this, 'verify' ], 10, 2 );
add_filter( 'wp_authenticate_user', [ $this, 'verify' ], 10, 2 );
}

/**
Expand Down
Loading

0 comments on commit 14945f7

Please sign in to comment.