public function display_settings()
    {
        $displayname = __('Flickr', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('flickr user id', 'reclaim');
        ?>
</th>
            <td><input type="text" name="flickr_user_id" value="<?php 
        echo get_option('flickr_user_id');
        ?>
" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('(optional) flickr api key', 'reclaim');
        ?>
</th>
            <td><input type="text" name="flickr_api_key" value="<?php 
        echo get_option('flickr_api_key');
        ?>
" />
            <p class="description">Get your Flickr API key <a href="http://www.flickr.com/services/apps/by/me">here</a>.
            If you don't have a flickr app yet, <a href="http://www.flickr.com/services/apps/create/apply">apply for a noncommercial app key</a>.
            After successful registration, click on "view app key" and copy it here.
            This will pull your public photos only.</p>
            <p class="description">If you don't enter an API key, only the latest 20 pictures will be copied and the full ajax sync won't work.</p>

            </td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        $displayname = __('Vine', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('vine email', 'reclaim');
        ?>
</th>
            <td><input type="text" name="vine_user_id" value="<?php 
        echo get_option('vine_user_id');
        ?>
" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('vine password', 'reclaim');
        ?>
</th>
            <td><input type="text" type="password" name="vine_password" value="<?php 
        echo get_option('vine_password');
        ?>
" /></td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        $displayname = __('Bookmarks', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row">
                Bookmarks settings
            </th>
            <td>
                <label for="bookmarks_api_url"><?php 
        _e('Bookmarks URL', 'reclaim');
        ?>
</label>
                <input type="text" name="bookmarks_api_url" class="widefat" value="<?php 
        echo get_option('bookmarks_api_url');
        ?>
" />
                <p class="description"><?php 
        _e('Enter a Feed URL for delicious.com or pinboard.in. (i.e. <code>http://feeds.pinboard.in/rss/u:{username}/t:{tag}/t:{tag}/</code> or <code>http://feeds.delicious.com/v2/rss/{username}/{tag[+tag+...+tag]}</code>)', 'reclaim');
        ?>
</p>
            </td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        $displayname = __('Yelp', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row">
                <label for="yelp_user_id"><?php 
        _e('Yelp User ID', 'reclaim');
        ?>
</label>
            </th>
            <td>
                <input type="text" name="yelp_user_id" class="widefat" value="<?php 
        echo get_option('yelp_user_id');
        ?>
" />
                <p class="description"><?php 
        _e('Enter your Yelp User ID (not name). (i.e. a2Q607M2qn7Ik3XS3fzmvQ)', 'reclaim');
        ?>
</p>
            </td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        $displayname = __('GitHub', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('GitHub username', 'reclaim');
        ?>
</th>
            <td><input type="text" name="github_username" value="<?php 
        echo get_option('github_username');
        ?>
" /></td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        $displayname = __('Goodreads', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Goodreads User ID (6196450)', 'reclaim');
        ?>
</th>
            <td><input type="text" name="goodreads_user_id" value="<?php 
        echo get_option('goodreads_user_id');
        ?>
" /></td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        $displayname = __('TwitPic', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('TwitPic user name (same as on Twitter)', 'reclaim');
        ?>
</th>
            <td><input type="text" name="twitpic_user_name" value="<?php 
        echo get_option('twitpic_user_name');
        ?>
" /></td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        $displayname = __('Google+', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row">
                Google+ App settings
            </th>
            <td>
                <label for="google_plus_user_id"><?php 
        _e('Google+ User ID', 'reclaim');
        ?>
</label>
                <input type="text" name="google_plus_user_id" class="widefat" value="<?php 
        echo get_option('google_plus_user_id');
        ?>
" />
                <p class="description"><?php 
        _e('Your Google+ profile ID is the long number at the end of your page or profile URL.', 'reclaim');
        ?>
</p>
                <hr />
                <label for="google_api_key"><?php 
        _e('Google API Key', 'reclaim');
        ?>
</label>
                <input type="text" name="google_api_key" class="widefat" value="<?php 
        echo get_option('google_api_key');
        ?>
" />
                <p class="description">
                <?php 
        echo sprintf(__('Read more info about the G+ API <a href="%s" target="_blank">here</a>', 'reclaim'), 'https://github.com/espresto/reclaim-social-media/wiki/Get-API-keys-for-Google-');
        ?>
                </p>
            </td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        if (isset($_GET['link']) && strtolower($_GET['mod']) == 'facebook' && isset($_SESSION['login'])) {
            $user_profile = json_decode($_SESSION['hybridauth_user_profile']);
            $user_access_tokens = json_decode($_SESSION['hybridauth_user_access_tokens']);
            $login = $_SESSION['login'];
            $error = $_SESSION['e'];
            if ($error != "") {
                echo '<div class="error"><p>' . esc_html($error) . '</p></div>';
            } else {
                update_option('facebook_user_id', $user_profile->identifier);
                update_option('facebook_username', $user_profile->displayName);
                update_option('facebook_oauth_token', $user_access_tokens->access_token);
            }
            if ($login == 0) {
                update_option('facebook_user_id', '');
                update_option('facebook_username', '');
                update_option('facebook_oauth_token', '');
            }
            //            print_r($_SESSION);
            //            echo "<pre>" . print_r( $user_profile, true ) . "</pre>" ;
            //            echo $user_access_token->accessToken;
            //            $user_profile->displayName
            if (session_id()) {
                session_destroy();
            }
        }
        $displayname = __('Facebook', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Facebook user ID', 'reclaim');
        ?>
</th>
            <td><?php 
        //echo get_option('facebook_user_id');
        ?>
            <input type="text" name="facebook_user_id" value="<?php 
        echo get_option('facebook_user_id');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Facebook user name', 'reclaim');
        ?>
</th>
            <td><?php 
        //echo get_option('facebook_username');
        ?>
            <input type="text" name="facebook_username" value="<?php 
        echo get_option('facebook_username');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><label for="facebook_app_id"><?php 
        _e('Facebook app id', 'reclaim');
        ?>
</label></th>
            <td><input type="text" name="facebook_app_id" value="<?php 
        echo get_option('facebook_app_id');
        ?>
" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><label for="facebook_app_secret"><?php 
        _e('Facebook app secret', 'reclaim');
        ?>
</label></th>
            <td><input type="text" name="facebook_app_secret" value="<?php 
        echo get_option('facebook_app_secret');
        ?>
" />
            <input type="hidden" name="facebook_oauth_token" value="<?php 
        echo get_option('facebook_oauth_token');
        ?>
" />
            <p class="description"><?php 
        echo sprintf(__('Some help on how to get the keys and secrets <a href="%s">here</a>.', 'reclaim'), 'https://github.com/espresto/reclaim-social-media/wiki/Get-App-Credentials-for-Facebook');
        ?>
</p>
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"></th>
            <td>
<?php 
        if (get_option('facebook_app_id') != "" && get_option('facebook_app_secret') != "") {
            $link_text = __('Authorize with Facebook', 'reclaim');
            // && (get_option('facebook_oauth_token')!="")
            if (get_option('facebook_user_id') != "" && get_option('facebook_oauth_token') != "") {
                echo sprintf(__('<p>Facebook is authorized as %s</p>', 'reclaim'), get_option('facebook_username'));
                $link_text = __('Authorize again', 'reclaim');
            }
            // send to helper script
            // put all configuration into session
            // todo
            $config = self::construct_hybridauth_config();
            $callback = urlencode(get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=reclaim/reclaim.php&link=1&mod=' . $this->shortname);
            $_SESSION[$this->shortname]['config'] = $config;
            //                $_SESSION[$this->shortname]['mod'] = $this->shortname;
            echo '<a class="button button-secondary" href="' . plugins_url('/helper/hybridauth/hybridauth_helper.php', dirname(__FILE__)) . '?' . '&mod=' . $this->shortname . '&callbackUrl=' . $callback . '">' . $link_text . '</a>';
            echo '<a class="button button-secondary" href="' . plugins_url('/helper/hybridauth/hybridauth_helper.php', dirname(__FILE__)) . '?' . '&mod=' . $this->shortname . '&callbackUrl=' . $callback . '&login=0' . '">logout</a>';
        } else {
            echo 'enter facebook app id and facebook app secret';
        }
        ?>
            </td>
        </tr>

<?php 
    }
    public function display_settings()
    {
        $displayname = __('YouTube', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Get Favs?', 'reclaim');
        ?>
</th>
            <td><input type="checkbox" name="youtube_import_favs" value="1" <?php 
        checked(get_option('youtube_import_favs'));
        ?>
 />
            <?php 
        if (get_option('youtube_import_favs')) {
            ?>
<input type="submit" class="button button-primary <?php 
            echo $this->shortName();
            ?>
_resync_items" value="<?php 
            _e('Resync favs with ajax', 'reclaim');
            ?>
" data-resync="{type:'favs'}" /><?php 
        }
        ?>
            <?php 
        if (get_option('youtube_import_favs')) {
            ?>
<input type="submit" class="button button-secondary <?php 
            echo $this->shortName();
            ?>
_count_all_items" value="<?php 
            _e('Count with ajax', 'reclaim');
            ?>
" data-resync="{type:'favs'}" /><?php 
        }
        ?>
            <p class="description"><?php 
        _e('Count value returned by YouTube API might not be accurate.', 'reclaim');
        ?>
</p>
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Category for Favs', 'reclaim');
        ?>
</th>
            <td><?php 
        wp_dropdown_categories(array('hierarchical' => 1, 'name' => 'youtube_favs_category', 'hide_empty' => 0, 'selected' => get_option('youtube_favs_category')));
        ?>
</td>
        </tr>
<?php 
        if (get_option('google_api_key')) {
            ?>
        <tr valign="top">
            <th scope="row"><?php 
            _e('Get activity? (i.e. videos you gave a thumbs up)', 'reclaim');
            ?>
</th>
            <td><input type="checkbox" name="youtube_import_activity" value="1" <?php 
            checked(get_option('youtube_import_activity'));
            ?>
 />
            <?php 
            if (get_option('youtube_import_activity')) {
                ?>
<input type="submit" class="button button-primary <?php 
                echo $this->shortName();
                ?>
_resync_items" value="<?php 
                _e('Resync activity with ajax', 'reclaim');
                ?>
" data-resync="{type:'activity'}" /><?php 
            }
            ?>
            <?php 
            if (get_option('youtube_import_activity')) {
                ?>
<input type="submit" class="button button-secondary <?php 
                echo $this->shortName();
                ?>
_count_all_items" value="<?php 
                _e('Count with ajax', 'reclaim');
                ?>
" data-resync="{type:'activity'}" /><?php 
            }
            ?>
            <p class="description"><?php 
            _e('Count value returned by YouTube API might not be accurate.', 'reclaim');
            ?>
</p>
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
            _e('Category for activity', 'reclaim');
            ?>
</th>
            <td><?php 
            wp_dropdown_categories(array('hierarchical' => 1, 'name' => 'youtube_activity_category', 'hide_empty' => 0, 'selected' => get_option('youtube_activity_category')));
            ?>
</td>
        </tr>
<?php 
        }
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('YouTube username', 'reclaim');
        ?>
</th>
            <td><input type="text" name="youtube_username" value="<?php 
        echo get_option('youtube_username');
        ?>
" /></td>
        </tr>
<?php 
    }
    public function display_settings()
    {
        if (isset($_GET['link']) && strtolower($_GET['mod']) == 'instagram' && isset($_SESSION['login'])) {
            //&& (isset($_SESSION['hybridauth_user_profile']))
            $user_profile = json_decode($_SESSION['hybridauth_user_profile']);
            $user_access_tokens = json_decode($_SESSION['hybridauth_user_access_tokens']);
            $login = $_SESSION['login'];
            $error = $_SESSION['e'];
            if ($error) {
                echo '<div class="error"><p>' . esc_html($error) . '</p></div>';
            } else {
                update_option('instagram_user_id', $user_profile->identifier);
                update_option('instagram_user_name', $user_profile->displayName);
                update_option('instagram_access_token', $user_access_tokens->access_token);
            }
            if ($login == 0) {
                update_option('instagram_user_id', '');
                update_option('instagram_user_name', '');
                update_option('instagram_access_token', '');
            }
            //            print_r($_SESSION);
            //            echo "<pre>" . print_r( $user_profile, true ) . "</pre>" ;
            //            echo "<pre>" . print_r( $_SESSION, true ) . "</pre>" ;
            //            echo $user_access_tokens->accessToken;
            //            echo $user_profile->displayName;
            if (session_id()) {
                session_destroy();
            }
        }
        $displayname = __('instagram', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Get Favs?', 'reclaim');
        ?>
</th>
            <td><input type="checkbox" name="instagram_import_favs" value="1" <?php 
        checked(get_option('instagram_import_favs'));
        ?>
 />
            <?php 
        if (get_option('instagram_import_favs')) {
            ?>
<input type="submit" class="button button-primary <?php 
            echo $this->shortName();
            ?>
_resync_items" value="<?php 
            _e('Resync favs with ajax', 'reclaim');
            ?>
" data-resync="{type:'favs'}" /><?php 
        }
        ?>
            <?php 
        if (get_option('instagram_import_favs')) {
            ?>
<input type="submit" class="button button-secondary <?php 
            echo $this->shortName();
            ?>
_count_all_items" value="<?php 
            _e('Count with ajax', 'reclaim');
            ?>
" data-resync="{type:'favs'}" /><?php 
        }
        ?>
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Category for Favs', 'reclaim');
        ?>
</th>
            <td><?php 
        wp_dropdown_categories(array('hierarchical' => 1, 'name' => 'instagram_favs_category', 'hide_empty' => 0, 'selected' => get_option('instagram_favs_category')));
        ?>
</td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Instagram user id', 'reclaim');
        ?>
</th>
            <td><p><?php 
        echo get_option('instagram_user_id');
        ?>
</p>
            <input type="hidden" name="instagram_user_id" value="<?php 
        echo get_option('instagram_user_id');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Instagram user name', 'reclaim');
        ?>
</th>
            <td><p><?php 
        echo get_option('instagram_user_name');
        ?>
</p>
            <input type="hidden" name="instagram_user_name" value="<?php 
        echo get_option('instagram_user_name');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Instagram client id', 'reclaim');
        ?>
</th>
            <td><input type="text" type="password" name="instagram_client_id" value="<?php 
        echo get_option('instagram_client_id');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Instagram client secret', 'reclaim');
        ?>
</th>
            <td><input type="text" type="password" name="instagram_client_secret" value="<?php 
        echo get_option('instagram_client_secret');
        ?>
" />
            <input type="hidden" name="instagram_access_token" value="<?php 
        echo get_option('instagram_access_token');
        ?>
" />
            <p class="description">
            
            <?php 
        echo sprintf(__('Get your Instagram client and credentials <a href="%s">here</a>. ', 'reclaim'), 'http://instagram.com/developer/');
        echo sprintf(__('Use <code>%s</code> as "Redirect URI"', 'reclaim'), plugins_url('reclaim/vendor/hybridauth/hybridauth/hybridauth/'));
        ?>
            </p>
           </td>
        </tr>

        <tr valign="top">
            <th scope="row"></th>
            <td>
            <?php 
        if (get_option('instagram_client_id') != "" && get_option('instagram_client_secret') != "") {
            $link_text = __('Authorize with Instagram', 'reclaim');
            // && (get_option('facebook_oauth_token')!="")
            if (get_option('instagram_user_id') != "" && get_option('instagram_access_token') != "") {
                echo sprintf(__('<p>Instagram authorized as %s</p>', 'reclaim'), get_option('instagram_user_name'));
                $link_text = __('Authorize again', 'reclaim');
            }
            // send to helper script
            // put all configuration into session
            // todo
            $config = self::construct_hybridauth_config();
            $callback = urlencode(get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=reclaim/reclaim.php&link=1&mod=' . $this->shortname);
            $_SESSION[$this->shortname]['config'] = $config;
            //                $_SESSION[$this->shortname]['mod'] = $this->shortname;
            echo '<a class="button button-secondary" href="' . plugins_url('/helper/hybridauth/hybridauth_helper.php', dirname(__FILE__)) . '?' . '&mod=' . $this->shortname . '&callbackUrl=' . $callback . '">' . $link_text . '</a>';
            echo '<a class="button button-secondary" href="' . plugins_url('/helper/hybridauth/hybridauth_helper.php', dirname(__FILE__)) . '?' . '&mod=' . $this->shortname . '&callbackUrl=' . $callback . '&login=0' . '">logout</a>';
        } else {
            echo _e('enter instagram app id and secret', 'reclaim');
        }
        ?>
            </td>
        </tr>

<?php 
    }
    public function display_settings()
    {
        if (isset($_GET['link']) && strtolower($_GET['mod']) == 'moves' && isset($_SESSION['hybridauth_user_profile'])) {
            $user_profile = json_decode($_SESSION['hybridauth_user_profile']);
            $user_access_tokens = json_decode($_SESSION['hybridauth_user_access_tokens']);
            $error = $_SESSION['e'];
            if ($error) {
                echo '<div class="error"><p><strong>Error:</strong> ', esc_html($error), '</p></div>';
            } else {
                update_option('moves_user_id', $user_profile->identifier);
                update_option('moves_access_token', $user_access_tokens->access_token);
            }
            if (session_id()) {
                session_destroy();
            }
        }
        $displayname = __('moves', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
         <tr valign="top">
            <th scope="row"><?php 
        _e('Show moves diagram', 'reclaim');
        ?>
</th>
            <td><input type="checkbox" name="reclaim_show_moves_dataset" value="1" <?php 
        checked(get_option('reclaim_show_moves_dataset'));
        ?>
 /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Moves client id', 'reclaim');
        ?>
</th>
            <td><input type="text" name="moves_client_id" value="<?php 
        echo get_option('moves_client_id');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Moves client secret', 'reclaim');
        ?>
</th>
            <td><input type="text" name="moves_client_secret" value="<?php 
        echo get_option('moves_client_secret');
        ?>
" />
            <input type="hidden" name="moves_user_id" value="<?php 
        echo get_option('moves_user_id');
        ?>
" />
            <input type="hidden" name="moves_access_token" value="<?php 
        echo get_option('moves_access_token');
        ?>
" />
            <p class="description">
            <?php 
        echo sprintf(__('Get your Moves client and credentials <a href="%s">here</a>. ', 'reclaim'), 'https://dev.moves-app.com/apps');
        echo sprintf(__('Use <code>%s</code> as "Redirect URI"', 'reclaim'), plugins_url('reclaim/vendor/hybridauth/hybridauth/hybridauth/'));
        ?>
            </p>
            </td>
        </tr>

        <tr valign="top">
            <th scope="row"></th>
            <td>
            <?php 
        if (get_option('moves_client_id') != "" && get_option('moves_client_secret') != "") {
            $link_text = __('Authorize with Moves', 'reclaim');
            if (get_option('moves_user_id') != "" && get_option('moves_access_token') != "") {
                echo sprintf(__('<p>Moves is authorized</p>', 'reclaim'), get_option('moves_user_id'));
                $link_text = __('Authorize again', 'reclaim');
            }
            // send to helper script
            // put all configuration into session
            // todo
            $config = $this->construct_hybridauth_config();
            $callback = urlencode(get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=reclaim/reclaim.php&link=1&mod=' . $this->shortname);
            $_SESSION[$this->shortname]['config'] = $config;
            echo '<a class="button button-secondary" href="' . plugins_url('/helper/hybridauth/hybridauth_helper.php', dirname(__FILE__)) . '?' . '&mod=' . $this->shortname . '&callbackUrl=' . $callback . '">' . $link_text . '</a>';
        } else {
            _e('enter moves app id and secret', 'reclaim');
        }
        ?>
            </td>
        </tr>

<?php 
    }
    public function display_settings()
    {
        if (isset($_GET['link']) && strtolower($_GET['mod']) == 'tumblr' && isset($_SESSION['login'])) {
            //&& (isset($_SESSION['hybridauth_user_profile']))
            $user_profile = json_decode($_SESSION['hybridauth_user_profile']);
            $full_user_profile = json_decode($_SESSION['hybridauth_full_user_profile']);
            $user_access_tokens = json_decode($_SESSION['hybridauth_user_access_tokens']);
            $login = $_SESSION['login'];
            $error = $_SESSION['e'];
            if ($error) {
                echo '<div class="error"><p>' . esc_html($error) . '</p></div>';
            } else {
                update_option('tumblr_user_id', $user_profile->identifier);
                update_option('tumblr_user_name', $user_profile->displayName);
                update_option('tumblr_access_token', $user_access_tokens->access_token);
                update_option('tumblr_full_user_profile', $full_user_profile);
                update_option('tumblr_user_avatar', $user_profile->photoURL);
            }
            if ($login == 0) {
                update_option('tumblr_user_id', '');
                update_option('tumblr_user_name', '');
                update_option('tumblr_access_token', '');
                update_option('tumblr_full_user_profile', '');
                update_option('tumblr_user_avatar', '');
            }
            //print_r($_SESSION);
            //            echo "<pre>" . print_r( $user_profile, true ) . "</pre>" ;
            //            echo "<pre>" . print_r( $_SESSION, true ) . "</pre>" ;
            //            echo $user_access_tokens->accessToken;
            //            echo $user_profile->displayName;
            if (session_id()) {
                session_destroy();
            }
        }
        $displayname = __('tumblr', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Primary Tumblr blog', 'reclaim');
        ?>
</th>
            <td><p><?php 
        echo get_option('tumblr_user_id');
        ?>
</p>
            <input type="hidden" name="tumblr_user_id" value="<?php 
        echo get_option('tumblr_user_id');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Primary Tumblr user name', 'reclaim');
        ?>
</th>
            <td><p><?php 
        echo get_option('tumblr_user_name');
        ?>
</p>
            <input type="hidden" name="tumblr_user_name" value="<?php 
        echo get_option('tumblr_user_name');
        ?>
" />
            </td>
        </tr>
<?php 
        // show secondary blogs
        $full_user_profile = get_option('tumblr_full_user_profile');
        if (isset($full_user_profile)) {
            foreach ($full_user_profile->response->user->blogs as $blog) {
                if (!$blog->primary) {
                    ?>

        <tr valign="top">
            <th scope="row"><?php 
                    echo sprintf(__('Synchronise secondary blog %s?', 'reclaim'), $blog->name);
                    ?>
</th>
            <td><input type="checkbox" name="tumblr_import_blog_<?php 
                    echo $blog->name;
                    ?>
" value="1" <?php 
                    checked(get_option('tumblr_import_blog_<?php echo $blog->name; ?>'));
                    ?>
 />
            <?php 
                    if (get_option('tumblr_import_blog_<?php echo $blog->name; ?>')) {
                        ?>
<input type="submit" class="button button-primary <?php 
                        echo $this->shortName();
                        ?>
_resync_items" value="<?php 
                        _e('Resync favs with ajax', 'reclaim');
                        ?>
" data-resync="{type:'favs'}" /><?php 
                    }
                    ?>
            <?php 
                    if (get_option('tumblr_import_blog_<?php echo $blog->name; ?>')) {
                        ?>
<input type="submit" class="button button-secondary <?php 
                        echo $this->shortName();
                        ?>
_count_all_items" value="<?php 
                        _e('Count with ajax', 'reclaim');
                        ?>
" data-resync="{type:'favs'}" /><?php 
                    }
                    ?>
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
                    echo sprintf(__('Category for %s', 'reclaim'), $blog->name);
                    ?>
</th>
            <td><?php 
                    wp_dropdown_categories(array('hierarchical' => 1, 'name' => 'tumblr_blog_<?php echo $blog->name; ?>_category', 'hide_empty' => 0, 'selected' => get_option('tumblr_blog_<?php echo $blog->name; ?>_category')));
                    ?>
</td>
        </tr>
		    
<?php 
                }
            }
        }
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Tumblr OAuth Consumer Key', 'reclaim');
        ?>
</th>
            <td><input type="text" type="password" name="tumblr_client_id" value="<?php 
        echo get_option('tumblr_client_id');
        ?>
" />
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Tumblr Secret Key', 'reclaim');
        ?>
</th>
            <td><input type="text" type="password" name="tumblr_client_secret" value="<?php 
        echo get_option('tumblr_client_secret');
        ?>
" />
            <input type="hidden" name="tumblr_access_token" value="<?php 
        echo get_option('tumblr_access_token');
        ?>
" />
            <p class="description">
            
            <?php 
        echo sprintf(__('Get your Tumblr client and credentials <a href="%s">here</a>. ', 'reclaim'), 'http://www.tumblr.com/oauth/apps');
        echo sprintf(__('Use <code>%s</code> as "Redirect URI"', 'reclaim'), plugins_url('reclaim/vendor/hybridauth/hybridauth/hybridauth/'));
        ?>
            </p>
           </td>
        </tr>

        <tr valign="top">
            <th scope="row"></th>
            <td>
            <?php 
        if (get_option('tumblr_client_id') != "" && get_option('tumblr_client_secret') != "") {
            $link_text = __('Authorize with Tumblr', 'reclaim');
            // && (get_option('facebook_oauth_token')!="")
            if (get_option('tumblr_user_id') != "" && get_option('tumblr_access_token') != "") {
                echo sprintf(__('<p><img src="%s" class="reclaim_avatar" width="32" height="32" align="left">Tumblr authorized as <span class="name">%s</span></li></p>', 'reclaim'), get_option('tumblr_user_avatar'), get_option('tumblr_user_name'));
                $link_text = __('Authorize again', 'reclaim');
            }
            // send to helper script
            // put all configuration into session
            // todo
            $config = self::construct_hybridauth_config();
            $callback = urlencode(get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=reclaim/reclaim.php&link=1&mod=' . $this->shortname);
            $_SESSION[$this->shortname]['config'] = $config;
            //                $_SESSION[$this->shortname]['mod'] = $this->shortname;
            echo '<a class="button button-secondary" href="' . plugins_url('/helper/hybridauth/hybridauth_helper.php', dirname(__FILE__)) . '?' . '&mod=' . $this->shortname . '&callbackUrl=' . $callback . '">' . $link_text . '</a>';
            echo '<a class="button button-secondary" href="' . plugins_url('/helper/hybridauth/hybridauth_helper.php', dirname(__FILE__)) . '?' . '&mod=' . $this->shortname . '&callbackUrl=' . $callback . '&login=0' . '">logout</a>';
        } else {
            echo _e('enter Tumblr app id and secret', 'reclaim');
        }
        ?>
            </td>
        </tr>

<?php 
    }
    public function display_settings()
    {
        $displayname = __('Twitter', 'reclaim');
        parent::display_settings($this->shortname, $displayname);
        ?>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Get Favs?', 'reclaim');
        ?>
</th>
            <td><input type="checkbox" name="twitter_import_favs" value="1" <?php 
        checked(get_option('twitter_import_favs'));
        ?>
 />
            <?php 
        if (get_option('twitter_import_favs')) {
            ?>
<input type="submit" class="button button-primary <?php 
            echo $this->shortName();
            ?>
_resync_items" value="<?php 
            _e('Resync favs with ajax', 'reclaim');
            ?>
" data-resync="{type:'favs'}" /><?php 
        }
        ?>
            <?php 
        if (get_option('twitter_import_favs')) {
            ?>
<input type="submit" class="button button-secondary <?php 
            echo $this->shortName();
            ?>
_count_all_items" value="<?php 
            _e('Count with ajax', 'reclaim');
            ?>
" data-resync="{type:'favs'}" /><?php 
        }
        ?>
            </td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('Category for Favs', 'reclaim');
        ?>
</th>
            <td><?php 
        wp_dropdown_categories(array('hierarchical' => 1, 'name' => 'twitter_favs_category', 'hide_empty' => 0, 'selected' => get_option('twitter_favs_category')));
        ?>
</td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('twitter username', 'reclaim');
        ?>
</th>
            <td><input type="text" name="twitter_username" value="<?php 
        echo get_option('twitter_username');
        ?>
" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('twitter consumer key', 'reclaim');
        ?>
</th>
            <td><input type="text" name="twitter_consumer_key" value="<?php 
        echo get_option('twitter_consumer_key');
        ?>
" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('twitter consumer secret', 'reclaim');
        ?>
</th>
            <td><input type="text" name="twitter_consumer_secret" value="<?php 
        echo get_option('twitter_consumer_secret');
        ?>
" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('twitter user token', 'reclaim');
        ?>
</th>
            <td><input type="text" name="twitter_user_token" value="<?php 
        echo get_option('twitter_user_token');
        ?>
" /></td>
        </tr>
        <tr valign="top">
            <th scope="row"><?php 
        _e('twitter user secret', 'reclaim');
        ?>
</th>
            <td><input type="text" name="twitter_user_secret" value="<?php 
        echo get_option('twitter_user_secret');
        ?>
" />
            <p class="description"><?php 
        echo sprintf(__('Some help on how to get the keys and secrets <a href="%s">here</a>.', 'reclaim'), 'https://github.com/espresto/reclaim-social-media/wiki/Get-API-keys-for-Twitter');
        ?>
</p>
            </td>
        </tr>
<?php 
    }