Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 162 additions & 118 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dukt/twitter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dukt/twitter/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/dukt/twitter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/dukt/twitter/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/dukt/twitter/badges/build.png?b=master)](https://scrutinizer-ci.com/g/dukt/twitter/build-status/master) [![Code Intelligence Status](https://scrutinizer-ci.com/g/dukt/twitter/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)

# Twitter for Craft CMS 3.x
# Twitter for Craft CMS 4.x

Tweet field, search widget, embeds, and authenticated Twitter API requests for Craft CMS.

## Requirements

This plugin requires Craft CMS 3.0.0 or later.
This plugin requires Craft CMS 4.0.0 or later.

## How to install Twitter 2

Expand All @@ -15,4 +15,4 @@ Installation instructions can be found in [Twitter 2 Documentation](https://dukt
## Resources

- [Twitter 2 Documentation](https://dukt.net/docs/twitter/v2)
- [Twitter 2 Overview](https://dukt.net/twitter)
- [Twitter 2 Overview](https://dukt.net/twitter)
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dukt/twitter",
"description": "Tweet field, search widget, embeds, and authenticated Twitter API requests.",
"version": "2.1.6",
"version": "2.1.7",
"type": "craft-plugin",
"license": "proprietary",
"keywords": [
Expand All @@ -23,7 +23,7 @@
"rss": "https://github.com/dukt/twitter/commits/v2.atom"
},
"require": {
"craftcms/cms": "^3.0.0",
"craftcms/cms": "^4.0",
"league/oauth1-client": "^1.10.0",
"guzzlehttp/oauth-subscriber": "^0.6.0",
"nojimage/twitter-text-php": "^2.0.3"
Expand All @@ -40,4 +40,4 @@
"documentationUrl": "https://dukt.net/docs/twitter/v2",
"changelogUrl": "https://raw.githubusercontent.com/dukt/twitter/master/CHANGELOG.md"
}
}
}
13 changes: 6 additions & 7 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace dukt\twitter;

use Craft;
use craft\base\Model;
use craft\events\RegisterCacheOptionsEvent;
use craft\events\RegisterComponentTypesEvent;
use craft\events\RegisterUrlRulesEvent;
Expand Down Expand Up @@ -44,7 +45,7 @@ class Plugin extends \craft\base\Plugin
/**
* @var bool
*/
public $hasCpSettings = true;
public bool $hasCpSettings = true;

/**
* @var \dukt\twitter\Plugin The plugin instance.
Expand All @@ -57,7 +58,7 @@ class Plugin extends \craft\base\Plugin
/**
* @inheritdoc
*/
public function init()
public function init() : void
{
parent::init();
self::$plugin = $this;
Expand Down Expand Up @@ -116,7 +117,7 @@ public function init()
/**
* @inheritdoc
*/
public function getSettings()
public function getSettings() : ?Model
{
$settings = parent::getSettings();
$configFile = Craft::$app->getConfig()->getConfigFromFile('twitter');
Expand Down Expand Up @@ -144,10 +145,8 @@ public function getSettings()

/**
* Creates and returns the model used to store the plugin’s settings.
*
* @return \craft\base\Model|null
*/
protected function createSettingsModel()
protected function createSettingsModel(): ?Model
{
return new Settings();
}
Expand All @@ -158,7 +157,7 @@ protected function createSettingsModel()
*
* @return string The rendered settings HTML
*/
public function getSettingsResponse()
public function getSettingsResponse(): string
{
$url = UrlHelper::cpUrl('twitter/settings');

Expand Down
18 changes: 12 additions & 6 deletions src/base/PluginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

use Craft;
use dukt\twitter\Plugin;
use \dukt\twitter\services\Twitter;
use \dukt\twitter\services\Accounts;
use \dukt\twitter\services\Api;
use \dukt\twitter\services\Cache;
use \dukt\twitter\services\Oauth;
use \dukt\twitter\services\Publish;

/**
* PluginTrait implements the common methods and properties for plugin classes.
Expand All @@ -26,7 +32,7 @@ trait PluginTrait
*
* @return \dukt\twitter\services\Twitter The twitter service
*/
public function getTwitter()
public function getTwitter() : Twitter
{
/** @var Twitter $this */
return $this->get('twitter');
Expand All @@ -37,7 +43,7 @@ public function getTwitter()
*
* @return \dukt\twitter\services\Accounts The accounts service
*/
public function getAccounts()
public function getAccounts() : Accounts
{
/** @var Twitter $this */
return $this->get('accounts');
Expand All @@ -48,7 +54,7 @@ public function getAccounts()
*
* @return \dukt\twitter\services\Api The api service
*/
public function getApi()
public function getApi() : Api
{
/** @var Twitter $this */
return $this->get('api');
Expand All @@ -59,7 +65,7 @@ public function getApi()
*
* @return \dukt\twitter\services\Cache The cache service
*/
public function getCache()
public function getCache() : Cache
{
/** @var Twitter $this */
return $this->get('cache');
Expand All @@ -70,7 +76,7 @@ public function getCache()
*
* @return \dukt\twitter\services\Oauth The oauth service
*/
public function getOauth()
public function getOauth() : Oauth
{
/** @var Twitter $this */
return $this->get('oauth');
Expand All @@ -81,7 +87,7 @@ public function getOauth()
*
* @return \dukt\twitter\services\Publish The publish service
*/
public function getPublish()
public function getPublish() : Publish
{
/** @var Twitter $this */
return $this->get('publish');
Expand Down
2 changes: 1 addition & 1 deletion src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Settings extends Model
/**
* @return array
*/
public function rules()
public function rules(): array
{
return [
[['token', 'tokenSecret'], 'string'],
Expand Down
3 changes: 2 additions & 1 deletion src/services/Oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use dukt\twitter\Plugin;
use yii\base\Component;
use League\OAuth1\Client\Credentials\TokenCredentials;
use craft\helpers\App;
use craft\helpers\UrlHelper;
use \League\OAuth1\Client\Server\Twitter as TwitterProvider;

Expand Down Expand Up @@ -94,7 +95,7 @@ public function getOauthProvider()
{
$options = [
'identifier' => Plugin::getInstance()->getConsumerKey(),
'secret' => Craft::parseEnv(Plugin::getInstance()->getConsumerSecret()),
'secret' => App::parseEnv(Plugin::getInstance()->getConsumerSecret()),
];

if (!isset($options['callback_uri'])) {
Expand Down
30 changes: 15 additions & 15 deletions src/web/twig/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
use craft\helpers\Template;
use dukt\twitter\helpers\TwitterHelper;
use dukt\twitter\Plugin;
use Twig_Extension;
use Twig_SimpleFunction;
use Twig_SimpleFilter;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
use GuzzleHttp\Exception\GuzzleException;

/**
* Twitter Twig Extension
*/
class Extension extends Twig_Extension
class Extension extends AbstractExtension
{
// Public Methods
// =========================================================================
Expand All @@ -41,8 +41,8 @@ public function getName()
public function getFilters()
{
return [
new Twig_SimpleFilter('autoLinkTweet', [$this, 'autoLinkTweet']),
new Twig_SimpleFilter('twitterTimeAgo', [$this, 'timeAgo'])
new TwigFilter('autoLinkTweet', [$this, 'autoLinkTweet']),
new TwigFilter('twitterTimeAgo', [$this, 'timeAgo'])
];
}

Expand All @@ -54,15 +54,15 @@ public function getFilters()
public function getFunctions()
{
return [
new Twig_SimpleFunction('twitterGrid', [$this, 'twitterGrid']),
new Twig_SimpleFunction('twitterTimeline', [$this, 'twitterTimeline']),
new Twig_SimpleFunction('twitterTweet', [$this, 'twitterTweet']),
new Twig_SimpleFunction('twitterVideo', [$this, 'twitterVideo']),
new Twig_SimpleFunction('twitterMoment', [$this, 'twitterMoment']),
new Twig_SimpleFunction('twitterFollowButton', [$this, 'twitterFollowButton']),
new Twig_SimpleFunction('twitterMessageButton', [$this, 'twitterMessageButton']),
new Twig_SimpleFunction('twitterTweetButton', [$this, 'twitterTweetButton']),
new Twig_SimpleFunction('embedTweet', [$this, 'embedTweet']),
new TwigFunction('twitterGrid', [$this, 'twitterGrid']),
new TwigFunction('twitterTimeline', [$this, 'twitterTimeline']),
new TwigFunction('twitterTweet', [$this, 'twitterTweet']),
new TwigFunction('twitterVideo', [$this, 'twitterVideo']),
new TwigFunction('twitterMoment', [$this, 'twitterMoment']),
new TwigFunction('twitterFollowButton', [$this, 'twitterFollowButton']),
new TwigFunction('twitterMessageButton', [$this, 'twitterMessageButton']),
new TwigFunction('twitterTweetButton', [$this, 'twitterTweetButton']),
new TwigFunction('embedTweet', [$this, 'embedTweet']),
];
}

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/SearchWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function displayName(): string
/**
* @inheritdoc
*/
public static function icon()
public static function icon(): string
{
return Craft::getAlias('@dukt/twitter/icons/twitter.svg');
}
Expand All @@ -61,7 +61,7 @@ public static function icon()
/**
* @inheritdoc
*/
public function rules()
public function rules() : array
{
$rules = parent::rules();
$rules[] = [['query', 'count'], 'required'];
Expand All @@ -88,7 +88,7 @@ public function getTitle(): string
/**
* @inheritdoc
*/
public function getBodyHtml()
public function getBodyHtml(): string
{
$variables = [];
$settings = $this->getSettings();
Expand Down Expand Up @@ -158,7 +158,7 @@ public function getBodyHtml()
/**
* @inheritdoc
*/
public function getSettingsHtml()
public function getSettingsHtml(): string
{
return Craft::$app->getView()->renderTemplate('twitter/_components/widgets/Search/settings', [
'settings' => $this->getSettings()
Expand Down