Google_Sheet_Helpers::google_sheet_connect_html( $content, $active, $tab )
Contents
Parameters Parameters
- $content
-
(Required)
- $active
-
(Required)
- $tab
-
(Required)
Return Return
(mixed)
Source Source
File: src/integrations/google-sheet/helpers/google-sheet-helpers.php
public function google_sheet_connect_html( $content, $active, $tab ) { if ( 'googlesheets_api' === $active ) { $action = 'authorization_request'; $redirect_url = urlencode( admin_url( 'edit.php' ) . '?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab ); $nonce = wp_create_nonce( 'automator_api_google_authorize' ); set_transient( 'automator_api_google_authorize_nonce', $nonce, 3600 ); $automator_version = InitializePlugin::PLUGIN_VERSION; $auth_url = $this->automator_api . "?action={$action}&scope={$this->client_scope}&redirect_url={$redirect_url}&nonce={$nonce}&plugin_ver={$automator_version}&api_ver=1.0"; $gs_client = $this->get_google_client(); $button_text = __( 'Connect an account', 'uncanny-automator' ); $button_class = ''; if ( $gs_client ) { $button_text = __( 'Change account', 'uncanny-automator' ); $button_class = 'uo-connected-button'; } ob_start(); ?> <div class="uo-settings-content-form"> <a href="<?php echo $auth_url; ?>" class="uo-settings-btn uo-settings-btn--primary <?php echo $button_class; ?>"> <?php echo $button_text; ?> </a> <?php if ( $gs_client ) : ?> <?php $disconnect_uri = add_query_arg( array( 'action' => 'uo_google_disconnect_user', 'nonce' => wp_create_nonce( 'uo-google-user-disconnect' ), ), admin_url( 'admin-ajax.php' ) ); ?> <a href="<?php echo esc_url( $disconnect_uri ); ?>" class="uo-settings-btn uo-settings-btn--error "> <?php esc_html_e( 'Disconnect', 'uncanny-automator' ); ?> </a> <?php endif; ?> </div> <style> .uo-google-user-info { display: flex; align-items: center; margin: 20px 0; } .uo-google-user-info__avatar { display: inline-flex; align-items: center; overflow: hidden; border-radius: 32px; margin-right: 10px; } .uo-google-user-info__name { margin-left: 5px; opacity: 0.75; } .uo-connected-button { color: #fff; background-color: #0790e8; } .uo-settings-content-footer { display: none !important; } </style> <?php } return $content; }
Expand full source code Collapse full source code View on Github