__('Twitter Widget', 'netjas_domain'),), // Args array('width' => 455)); } public function form($instance) { ?>

s



value="1"/>
value="TRUE"/>
value="TRUE"/>

admin_url('admin-ajax.php'), 'text_color' => $twitterOptions['TEXT_COLOR'], 'header_color' => $twitterOptions['HEADER_COLOR'], 'border_color' => $twitterOptions['BORDER_COLOR'], 'followers_count' => $twitterOptions['SHOW_FOLLOWERS'], 'font_family' => $twitterOptions['FONT_FAMILY'], 'font_size' => $twitterOptions['FONT_SIZE'], 'update_time' => $twitterOptions['UPDATE_TIME'])); $localeClass = getTranslationArray(getLanguage()); wp_localize_script('ajax-script', 'locale', $localeClass->translationArray); } function netjas_twitter_retrieve() { if (count($_GET) === 0) { header('HTTP/1.1 403 METHOD NOT ALLOWED'); return; } header('HTTP/1.1 200 OK'); header('Content-Type: application/json'); $result = ''; $lastTweets = get_transient('lastTweets'); if (FALSE === $lastTweets) { $result = get_twitter_messages(); set_transient('lastTweets', $result, get_transient('update_time')); } else { $result = get_transient('lastTweets'); } echo $result; } function validate_twitter_oauth($key, $secret) { if ($key === '' or $secret === '') { return FALSE; } $requestURL = FALSE; $to = new TwitterOAuth(ck, cs); $token = $to->getRequestToken(plugins_url('/ajax-twitter-widget/functions/callback.php')); if ($token['oauth_callback_confirmed'] === 'true') { $tokenArray = array( 'oauth_token' => $token['oauth_token'], 'oauth_token_secret' => $token['oauth_token_secret'] ); delete_transient('ttoken'); set_transient('ttoken', $tokenArray); $requestURL = $to->getAuthorizeURL($token); } return $requestURL; } function get_twitter_messages() { $tokenArray = get_transient('token'); $twitterOptions = get_twitter_options(); /* Create a TwitterOauth object with consumer/user tokens. */ $connection = new TwitterOAuth(ck, cs, $tokenArray['oauth_token'], $tokenArray['oauth_token_secret']); $newTwitters = json_encode($connection->get('statuses/user_timeline', array('screen_name' => $twitterOptions['SCREEN_NAME'], 'count' => $twitterOptions['NUMBER_OF_TWEETS'], 'exclude_replies' => 'false'))); return $newTwitters; } function get_twitter_options() { $a = get_option('widget_twitter_widget'); if ($a) { $key = key($a); if (empty($a)) { return FALSE; } else { return $a[$key]; } } return FALSE; } function admin_twitter_notices() { $twitterStatus = get_transient('twitter_status'); $errorString = __('In order to complete the installation is necessary register the Twitter Widget application.', 'ajax-twitter-widget'); $installedString = __('Twitter Widget has been installed and it is working.', 'ajax-twitter-widget'); $errorMessage = new MessageManager($errorString, TRUE); $installedMessage = new MessageManager($installedString); switch ($twitterStatus) { case "1": //Twitter widget installed but not configurated or correctly configurated. echo $errorMessage->getMessage(); break; case "2": //Twitter Correctly configurated but confirmation message has not be displayed yet. echo $installedMessage->getMessage(); set_transient('lastTweets', get_twitter_messages(), get_transient('update_time')); set_transient('twitter_status', "3"); break; case "3": //Confirmation Message displayed. // Doing nothing, the widget is installed and working; break; } } function getLanguage() { $a = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'], 1); return $a[0]; } function getLocale() { $localeClass = getTranslationArray(getLanguage()); wp_localize_script('ajax-script', 'locale', $localeClass->translationArray); } ?>