From 4a019decec4f1994592e95c6c6d31ffc0a0d56db Mon Sep 17 00:00:00 2001
From: Kurt Zenisek <KZeni1@gmail.com>
Date: Tue, 24 Nov 2020 18:57:14 -0600
Subject: [PATCH] Confirmed Matomo 4 compliance.

---
 CHANGELOG.md               |   6 +-
 Widgets/GetTwitterFeed.php | 167 ++++++++++++++++++-------------------
 plugin.json                |  63 +++++++-------
 3 files changed, 114 insertions(+), 122 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7fa5fa8..0db3430 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## 1.0.4
+
+- Confirmed Matomo 4 compliance.
+
 ## 1.0.3
 
 - Better scoped the widget styles.
@@ -14,4 +18,4 @@
 
 ## 1.0
 
-- Initial Release.
\ No newline at end of file
+- Initial Release.
diff --git a/Widgets/GetTwitterFeed.php b/Widgets/GetTwitterFeed.php
index 2fdd841..895714a 100644
--- a/Widgets/GetTwitterFeed.php
+++ b/Widgets/GetTwitterFeed.php
@@ -28,69 +28,68 @@
  */
 class getTwitterFeed extends Widget
 {
-
-    /**
-     * @var SettingsProvider
-     */
+	/**
+	 * @var SettingsProvider
+	 */
 	private $settingsProvider;
 
-    public function __construct(SettingsProvider $settingsProvider)
-    {
-        $this->settingsProvider = $settingsProvider;
-    }
-
-    public static function configure(WidgetConfig $config)
-    {
-        /**
-         * Set the category the widget belongs to. You can reuse any existing widget category or define
-         * your own category.
-         */
-        $config->setCategoryId('TwitterFeedWidgetByAmperage_Social');
-
-        /**
-         * Set the subcategory the widget belongs to. If a subcategory is set, the widget will be shown in the UI.
-         */
-        // $config->setSubcategoryId('General_Overview');
-
-        /**
-         * Set the name of the widget belongs to.
-         */
-        $config->setName('TwitterFeedWidgetByAmperage_TwitterFeed');
-
-        /**
-         * Set the order of the widget. The lower the number, the earlier the widget will be listed within a category.
-         */
-        $config->setOrder(50);
-
-        /**
-         * Optionally set URL parameters that will be used when this widget is requested.
-         * $config->setParameters(array('myparam' => 'myvalue'));
-         */
-
-        /**
-         * Define whether a widget is enabled or not. For instance some widgets might not be available to every user or
-         * might depend on a setting (such as Ecommerce) of a site. In such a case you can perform any checks and then
-         * set `true` or `false`. If your widget is only available to users having super user access you can do the
-         * following:
-         *
-         * $config->setIsEnabled(\Piwik\Piwik::hasUserSuperUserAccess());
-         * or
-         * if (!\Piwik\Piwik::hasUserSuperUserAccess())
-         *     $config->disable();
-         */
-    }
-
-    /**
-     * This method renders the widget. It's on you how to generate the content of the widget.
-     * As long as you return a string everything is fine. You can use for instance a "Piwik\View" to render a
-     * twig template. In such a case don't forget to create a twig template (eg. myViewTemplate.twig) in the
-     * "templates" directory of your plugin.
-     *
-     * @return string
-     */
-    public function render(){
-        try {
-
+	public function __construct(SettingsProvider $settingsProvider)
+	{
+		$this->settingsProvider = $settingsProvider;
+	}
+
+	public static function configure(WidgetConfig $config)
+	{
+		/**
+		 * Set the category the widget belongs to. You can reuse any existing widget category or define
+		 * your own category.
+		 */
+		$config->setCategoryId('TwitterFeedWidgetByAmperage_Social');
+
+		/**
+		 * Set the subcategory the widget belongs to. If a subcategory is set, the widget will be shown in the UI.
+		 */
+		// $config->setSubcategoryId('General_Overview');
+
+		/**
+		 * Set the name of the widget belongs to.
+		 */
+		$config->setName('TwitterFeedWidgetByAmperage_TwitterFeed');
+
+		/**
+		 * Set the order of the widget. The lower the number, the earlier the widget will be listed within a category.
+		 */
+		$config->setOrder(50);
+
+		/**
+		 * Optionally set URL parameters that will be used when this widget is requested.
+		 * $config->setParameters(array('myparam' => 'myvalue'));
+		 */
+
+		/**
+		 * Define whether a widget is enabled or not. For instance some widgets might not be available to every user or
+		 * might depend on a setting (such as Ecommerce) of a site. In such a case you can perform any checks and then
+		 * set `true` or `false`. If your widget is only available to users having super user access you can do the
+		 * following:
+		 *
+		 * $config->setIsEnabled(\Piwik\Piwik::hasUserSuperUserAccess());
+		 * or
+		 * if (!\Piwik\Piwik::hasUserSuperUserAccess())
+		 *     $config->disable();
+		 */
+	}
+
+	/**
+	 * This method renders the widget. It's on you how to generate the content of the widget.
+	 * As long as you return a string everything is fine. You can use for instance a "Piwik\View" to render a
+	 * twig template. In such a case don't forget to create a twig template (eg. myViewTemplate.twig) in the
+	 * "templates" directory of your plugin.
+	 *
+	 * @return string
+	 */
+	public function render()
+	{
+		try {
 			$output = '<div class="widget-body">';
 
 			$twitter_username = '';
@@ -100,35 +99,31 @@ public function render(){
 			$settings = $this->settingsProvider->getMeasurableSettings('TwitterFeedWidgetByAmperage', $idSite);
 			$twitter_username = $settings->twitterFeedUsernameSetting->getValue();
 
-			if($twitter_username == ''){
-				$output.= '<p>You first need to configure the Twitter Feed Username in your <a href="index.php?module=SitesManager&action=index#TwitterFeedWidgetByAmperage">measurable (website/app) settings</a>.</p>';
-			}else{ // Twitter Feed Username has been provided
-
-				$output.= '<a class="twitter-timeline" data-height="400" data-theme="light" href="https://twitter.com/'.$twitter_username.'?ref_src=twsrc%5Etfw">Tweets by '.$twitter_username.'</a>';
+			if ($twitter_username == '') {
+				$output .= '<p>You first need to configure the Twitter Feed Username in your <a href="index.php?module=SitesManager&action=index#TwitterFeedWidgetByAmperage">measurable (website/app) settings</a>.</p>';
+			} else {
+				// Twitter Feed Username has been provided
 
-				$output.= '<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>';
+				$output .= '<a class="twitter-timeline" data-height="400" data-theme="light" href="https://twitter.com/' . $twitter_username . '?ref_src=twsrc%5Etfw">Tweets by ' . $twitter_username . '</a>';
 
-				$output.= '<p><a href="https://analytics.twitter.com/user/'.$twitter_username.'/home" target="_blank" class="more">View More Twitter Insights &amp; Stats</a></p>';
+				$output .= '<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>';
 
+				$output .= '<p><a href="https://analytics.twitter.com/user/' . $twitter_username . '/home" target="_blank" class="more">View More Twitter Insights &amp; Stats</a></p>';
 			}
 
-			$output.= '</div>';
+			$output .= '</div>';
 			return $output;
-
-        } catch (\Exception $e) {
-            return $this->error($e);
-        }
-    }
-
-    /**
-     * @param \Exception $e
-     * @return string
-     */
-    private function error($e)
-    {
-        return '<div class="pk-emptyDataTable">'
-             . Piwik::translate('General_ErrorRequest', array('', ''))
-             . ' - ' . $e->getMessage() . '</div>';
-    }
-
+		} catch (\Exception $e) {
+			return $this->error($e);
+		}
+	}
+
+	/**
+	 * @param \Exception $e
+	 * @return string
+	 */
+	private function error($e)
+	{
+		return '<div class="pk-emptyDataTable">' . Piwik::translate('General_ErrorRequest', ['', '']) . ' - ' . $e->getMessage() . '</div>';
+	}
 }
diff --git a/plugin.json b/plugin.json
index 00ac389..c4afe2a 100644
--- a/plugin.json
+++ b/plugin.json
@@ -1,37 +1,30 @@
 {
-    "name": "TwitterFeedWidgetByAmperage",
-    "description": "Show Twitter Feed as a configurable widget.",
-    "version": "1.0.3",
-    "theme": false,
-    "keywords": [
-        "amperage",
-        "twitter",
-        "social",
-        "widget",
-        "twitter feed",
-        "dashboard"
-    ],
-    "license": "GPL v3+",
-    "homepage": "https://www.amperagemarketing.com",
-    "require": {
-        "piwik": ">=3.3.0-stable,<4.0.0-b1"
-    },
-    "support": {
-        "email": "kzeni1@gmail.com",
-        "issues": "https://github.com/AMPERAGE-Marketing/Matomo-Twitter-Feed-Widget/issues",
-        "wiki": "https://github.com/AMPERAGE-Marketing/Matomo-Twitter-Feed-Widget/wiki",
-        "source": "https://github.com/AMPERAGE-Marketing/Matomo-Twitter-Feed-Widget"
-    },
-    "authors": [
-        {
-            "name": "Amperage Marketing & Fundraising",
-            "email": "digital@amperagemarketing.com",
-            "homepage": "http://www.amperagemarketing.com"
-        },
-        {
-            "name": "Kurt Zenisek",
-            "email": "kzeni1@gmail.com",
-            "homepage": "http://kzeni.com"
-        }
-    ]
+	"name": "TwitterFeedWidgetByAmperage",
+	"description": "Show Twitter Feed as a configurable widget.",
+	"version": "1.0.4",
+	"theme": false,
+	"keywords": ["amperage", "twitter", "social", "widget", "twitter feed", "dashboard"],
+	"license": "GPL v3+",
+	"homepage": "https://www.amperagemarketing.com",
+	"require": {
+		"piwik": ">=3.3.0-stable,<5.0.0-b1"
+	},
+	"support": {
+		"email": "kzeni1@gmail.com",
+		"issues": "https://github.com/AMPERAGE-Marketing/Matomo-Twitter-Feed-Widget/issues",
+		"wiki": "https://github.com/AMPERAGE-Marketing/Matomo-Twitter-Feed-Widget/wiki",
+		"source": "https://github.com/AMPERAGE-Marketing/Matomo-Twitter-Feed-Widget"
+	},
+	"authors": [
+		{
+			"name": "Amperage Marketing & Fundraising",
+			"email": "digital@amperagemarketing.com",
+			"homepage": "http://www.amperagemarketing.com"
+		},
+		{
+			"name": "Kurt Zenisek",
+			"email": "kzeni1@gmail.com",
+			"homepage": "http://kzeni.com"
+		}
+	]
 }