Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • The check in main.php

    if(isset($options['oauth_access_token']) && 
       !empty($options['oauth_access_token'])) {...

    might succeed (and therefore return false) even if something is wrong.

    Why not rename the “revoke permission” tab to “API Access”
    and move the [grant permission] to the new API access tab.

    Then you could have the two buttons permanently on display under a status

    API Access: [grant/green] / [revoke/red]

    with your same

    Status: (Connected / Disconnected) UI

    Also just having a URL to cause the grant action, despite it NOT being possible, causes a 500 error. Whereas checking for can_grant_permissions could be done on the

    /wp-admin/options-general.php?page=gmail-smtp-settings&action=oauth_grant

    URL, and not proceed if check fails.

    As an aside. Currently can_grant_permission returns true by default. How about returning false by default. You code is then simplified.

    from

    function can_grant_permission(){
    $options = gmail_smtp_get_option();
    $grant_permission = true;
    if(!isset($options[‘oauth_client_id’]) || empty($options[‘oauth_client_id’])){
    $grant_permission = false;
    }
    if(!isset($options[‘oauth_client_secret’]) || empty($options[‘oa`uth_client_secret’])){
    $grant_permission = false;
    }
    if(isset($options[‘oauth_access_token’]) && !empty($options[‘oauth_access_token’])){
    $grant_permission = false;
    }
    return $grant_permission;
    }`

    to

        function can_grant_permission(){
            $options = gmail_smtp_get_option();    
            $grant_permission = false;
            if( !empty($options['oauth_client_id']) && //have id and
                !empty($options['oauth_client_secret'] && //secret and
                empty($options['oauth_access_token']) ){ //token is missing
                $grant_permission = true;
            }
            return $grant_permission;
        }

    as any other combo you either cant or dont want to grant permission

    • This reply was modified 7 years, 11 months ago by shimmyshack.

    no the reason people bad mouth open source applications is that they are ungrateful and demanding of peoples generousity and spare time.

    Thread Starter shimmyshack

    (@shimmyshack)

    my bad – kinda – I used

    register_activation_hook(
    str_replace(‘\\’,’/’,__FILE__),
    array(&$this, ‘make_table’)
    );

    str_replace(‘\\’,’/’,
    was needed on my windows test box, and
    array(&$this,
    was needed to reference themethod that would be run.

    Ta.

Viewing 3 replies - 1 through 3 (of 3 total)