• Hello again, and thanks for your plugin, i had a few adjustments that if can be integrated will assist in hooking to your plugin where needed,

    Simplify with a display function that handle both versions.

    // display that handle both options
    	function display( ) {
    		$sgrDisplay = $this->getOptionValue(Entity::VERSION) === 3 ? 'v3Display' : 'v2Display';
    		$this->$sgrDisplay();
    	}

    Add 2 apply_filters to enable hook for the required scripts and the verify

    // Commented this since added generic display() function that already checkes the version
                //$sgrDisplay = $this->getOptionValue(Entity::VERSION) === 3 ? 'v3Display' : 'v2Display';
    
    			// add filter to allow hook on other plugins
                foreach ( apply_filters( 'sgr_recaptcha_display_list', $sgr_display_list ) as $sgr_display) {
                    add_action($sgr_display, [$this, 'enqueueScripts']);
                    add_action($sgr_display, [$this, 'display'] );
                }
    
    			// add filter to allow hook on other plugins
                foreach ( apply_filters( 'sgr_recaptcha_verify_list', $sgr_verify_list ) as $sgr_verify) {
                    add_action($sgr_verify, [$this, 'verify']);
                }
Viewing 1 replies (of 1 total)
  • Plugin Author Minor

    (@minor)

    Hi @idokd,

    Thank you for another good advice! I thought about this for a long time. Finally I delivered it in new version 4.0. You can try it now.

    Render hook: sgr_render_list
    Verify hook: sgr_verify_list

    Example:

    function customSgrRenderList(array $list): array //Where reCAPTCHA is rendered
    {
        //unset($list[0]);
        $list[] = 'register_form';
    
        return $list;
    }
    
    add_action('sgr_render_list', 'customSgrRenderList');
    
    function customSgrVerifyList(array $list): array //Where reCAPTCHA is verified
    {
        //unset($list[0]);
        $list[] = 'lostpassword_post';
    
        return $list;
    }
    
    add_action('sgr_verify_list', 'customSgrVerifyList');
Viewing 1 replies (of 1 total)
  • The topic ‘Hooks to extend your plugin’ is closed to new replies.