Support » Plugin: Translate Multilingual sites - TranslatePress » Filter for is_admin_link method

  • Resolved Maya

    (@tdgu)


    Hello,
    I’m one of the WP Hide developers https://wordpress.org/plugins/wp-hide-security-enhancer/ Currently we have 2 users encountering a login form URL error, when both plugins are active and a custom login URL has been set. This appears to be caused by the is_admin_link() method in your TRP_Translation_Render class, which returns a wrong response if there is a custom login URL set.
    Can you add a custom filter before the function return, which we can use to add a compatibility file on our code?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Cristian Antohe

    (@sareiodata)

    Hi,

    That function return a bool:

    protected function is_admin_link( $url, $admin_url = '', $wp_login_url = '' ){
    
            if( empty( $admin_url ) )
                $admin_url = admin_url();
    
            if( empty( $wp_login_url ) )
                $wp_login_url = wp_login_url();
    
            if ( strpos( $url, $admin_url ) !== false || strpos( $url, $wp_login_url ) !== false ){
                return true;
            }
            return false;
    
        }

    Would something like this work?

    protected function is_admin_link( $url, $admin_url = '', $wp_login_url = '' ){
    
    	if( empty( $admin_url ) )
    		$admin_url = admin_url();
    
    	if( empty( $wp_login_url ) )
    		$wp_login_url = wp_login_url();
    
    	if ( strpos( $url, $admin_url ) !== false || strpos( $url, $wp_login_url ) !== false ){
    		$is_admin_link = true;
    	} else {
    		$is_admin_link = false;
    	}
    
    	return apply_filters('trp_is_admin_link',$is_admin_link ,$admin_url, $wp_login_url);
    }
    Thread Starter Maya

    (@tdgu)

    Hi,
    The filter will work great, can you also add the $url in the arguments list?

    Thanks

    Plugin Author Cristian Antohe

    (@sareiodata)

    Yes. It will be like so in the next version:

    protected function is_admin_link( $url, $admin_url = '', $wp_login_url = '' ){
    
    	if( empty( $admin_url ) )
    		$admin_url = admin_url();
    
    	if( empty( $wp_login_url ) )
    		$wp_login_url = wp_login_url();
    
    	if ( strpos( $url, $admin_url ) !== false || strpos( $url, $wp_login_url ) !== false ){
    		$is_admin_link = true;
    	} else {
    		$is_admin_link = false;
    	}
    
    	return apply_filters('trp_is_admin_link',$is_admin_link, $url, ,$admin_url, $wp_login_url);
    }
    Thread Starter Maya

    (@tdgu)

    Great, thanks for your support.

    Plugin Author Anghel Emanuel

    (@anghelemanuel99)

    Hello again,

    If there`s anything else, please let us know!

    Kind Regards,

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.