WordPress.org

Plugin Directory

Changeset 766287


Ignore:
Timestamp:
09/03/13 13:15:56 (8 months ago)
Author:
donncha
Message:

Use Polldaddy API Key to connect account to plugin instead of username and password

File:
1 edited

Legend:

Unmodified
Added
Removed
  • polldaddy/trunk/polldaddy.php

    r766222 r766287  
    10491049 
    10501050    function import_account() { 
    1051  
    1052  
    1053         $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID ); 
    1054         $polldaddy->reset(); 
    1055         $email = trim( stripslashes( $_POST['polldaddy_email'] ) ); 
    1056         $password = trim( stripslashes( $_POST['polldaddy_password'] ) ); 
    1057  
    1058         if ( !is_email( $email ) ) 
    1059             $this->errors->add( 'polldaddy_email', __( 'Email address required', 'polldaddy' ) ); 
    1060  
    1061         if ( !$password ) 
    1062             $this->errors->add( 'polldaddy_password', __( 'Password required', 'polldaddy' ) ); 
    1063  
    1064         if ( $this->errors->get_error_codes() ) 
    1065             return false; 
    1066  
    1067         if ( $usercode = $polldaddy->initiate( $email, $password, $this->id ) ) { 
    1068             $this->user_code = $usercode; 
     1051        if ( isset( $_POST[ 'polldaddy_key' ] ) ) { 
     1052            $polldaddy_api_key = trim( stripslashes( $_POST[ 'polldaddy_key' ] ) ); 
     1053            $polldaddy = $this->get_client( $polldaddy_api_key ); 
     1054            $polldaddy->reset(); 
     1055            if ( !$polldaddy->get_usercode( $this->id ) ) { 
     1056                $this->parse_errors( $polldaddy ); 
     1057                $this->errors->add( 'GetUserCode', __( 'Account could not be accessed.  Is your API code correct?', 'polldaddy' ) ); 
     1058                return false; 
     1059            } 
     1060            update_option( 'polldaddy_api_key', $polldaddy_api_key ); 
    10691061        } else { 
    1070             $this->parse_errors( $polldaddy ); 
    1071             $this->errors->add( 'import-account', __( 'Account could not be imported.  Are your email address and password correct?', 'polldaddy' ) ); 
     1062            $this->user_code = false; 
     1063            $this->errors->add( 'import-account', __( 'Account could not be imported. Did you enter the correct API key?', 'polldaddy' ) ); 
    10721064            return false; 
    10731065        } 
     
    48344826        <?php _e( 'Polldaddy Account Info', 'polldaddy' ); ?> 
    48354827    </h3> 
    4836     <p><?php _e( '<em>Polldaddy</em> and <em>WordPress.com</em> are now connected using <a href="http://en.support.wordpress.com/wpcc-faq/">WordPress.com Connect</a>. If you have a WordPress.com account you can use it to login to <a href="http://polldaddy.com/">Polldaddy.com</a>. Click on the Polldaddy "sign in" button, authorize the connection and create your new Polldaddy account. Use the same email and password to login on this page.', 'polldaddy' ); ?></p> 
    4837     <p><strong><?php _e( 'You must login at least once on <a href="http://polldaddy.com/">Polldaddy.com</a> before using this plugin.' ); ?></strong></p> 
    4838     <p><?php printf( __( 'Your account is currently link to this WordPress.com account: <strong>%s</strong>', 'polldaddy' ), $account_email ); ?></p> 
     4828    <p><?php _e( '<em>Polldaddy</em> and <em>WordPress.com</em> are now connected using <a href="http://en.support.wordpress.com/wpcc-faq/">WordPress.com Connect</a>. If you have a WordPress.com account you can use it to login to <a href="http://polldaddy.com/">Polldaddy.com</a>. Click on the Polldaddy "sign in" button, authorize the connection and create your new Polldaddy account.', 'polldaddy' ); ?></p> 
     4829    <p><?php _e( 'Login to the Polldaddy website and scroll to the end of your <a href="http://polldaddy.com/account/#apikey">account page</a> to create or retrieve an API key.', 'polldaddy' ); ?></p> 
     4830    <p><?php printf( __( 'Your account is currently linked to this API key: <strong>%s</strong>', 'polldaddy' ), WP_POLLDADDY__PARTNERGUID ); ?></p> 
    48394831    <br /> 
    48404832    <h3><?php _e( 'Link to a different Polldaddy account', 'polldaddy' ); ?></h3> 
     
    48494841          <th valign="top" scope="row"> 
    48504842            <label for="polldaddy-email"> 
    4851               <?php _e( 'WordPress.com Email Address', 'polldaddy' ); ?> 
     4843              <?php _e( 'Polldaddy.com API Key', 'polldaddy' ); ?> 
    48524844            </label> 
    48534845          </th> 
    48544846          <td> 
    4855           <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php if ( isset( $_POST[ 'polldaddy_email' ] ) ) echo esc_attr( $_POST[ 'polldaddy_email' ] ); ?>" /> 
    4856           </td> 
    4857         </tr> 
    4858         <tr class="form-field form-required"> 
    4859           <th valign="top" scope="row"> 
    4860             <label for="polldaddy-password"> 
    4861               <?php _e( 'WordPress.com Password', 'polldaddy' ); ?> 
    4862             </label> 
    4863           </th> 
    4864           <td> 
    4865             <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" /> 
    4866             <?php if ( $account_email ) { ?> 
    4867             <p><?php printf( __( 'Any polls or ratings created in your current account will still be available on Polldaddy.com when you login as %s.', 'polldaddy' ), $account_email ); ?></p> 
    4868             <?php } ?> 
     4847          <input type="text" name="polldaddy_key" id="polldaddy-key" aria-required="true" size="20" value="<?php if ( isset( $_POST[ 'polldaddy_key' ] ) ) echo esc_attr( $_POST[ 'polldaddy_key' ] ); ?>" /> 
    48694848          </td> 
    48704849        </tr> 
Note: See TracChangeset for help on using the changeset viewer.