Twitter_Helpers::twitter_connect_html( $content,  $active,  $tab )


Parameters Parameters

$content

(Required)

$active

(Required)

$tab

(Required)


Top ↑

Return Return

(false|mixed|string)


Source Source

File: src/integrations/twitter/helpers/twitter-helpers.php

	public function twitter_connect_html( $content, $active, $tab ) {

		if ( 'twitter_api' === $active ) {

			$tab_url = admin_url( 'edit.php' ) . '?post_type=uo-recipe&page=uncanny-automator-settings&tab=' . $this->setting_tab;

			$twitter_client = $this->get_client();

			if ( $twitter_client ) {
				$button_text  = __( 'Disconnect account', 'uncanny-automator' );
				$button_class = 'uo-disconnect-button';
				$button_url   = $tab_url . '&disconnect=1';
			} else {
				$nonce      = wp_create_nonce( 'automator_twitter_api_authentication' );
				$plugin_ver = AUTOMATOR_PLUGIN_VERSION;
				$api_ver    = '1.0';

				$action       = 'twitter_authorization_request';
				$redirect_url = urlencode( $tab_url );
				$button_url   = "https://api.automatorplugin.com/twitter/?action={$action}&redirect_url={$redirect_url}&nonce={$nonce}&api_ver={$api_ver}&plugin_ver={$plugin_ver}";
				$button_text  = __( 'Connect an account', 'uncanny-automator' );
				$button_class = 'uo-connect-button';
			}

			ob_start();
			?>

			<a href="<?php echo $button_url; ?>"
			   class="uo-settings-btn uo-settings-btn--secondary <?php echo $button_class; ?>">
				<?php
				echo $button_text;
				?>
			</a>

			<style>
				button[name="uap_automator_twitter_api_save"] {
					display: none;
				}

				.uo-connect-button {
					color: #fff;
					background-color: #4fb840;
				}

				.uo-disconnect-button {
					color: #fff;
					background-color: #f58933;
				}
			</style>
			<?php
			$content = ob_get_contents();
			ob_end_clean();
		}

		return $content;
	}