diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17d4561..2746d3d 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Simple Sharing Changelog
+## 2.0.0 - 2022-11-17
+### Updated
+- Craft4.x Support Added (^2.0.0 is not backward compatible with Craft3.x, use 1.x branch).
+
## 1.0.8 - 2020-11-08
### Updated
diff --git a/README.md b/README.md
index 02377b8..163cdda 100755
--- a/README.md
+++ b/README.md
@@ -6,11 +6,12 @@ Simple Sharing is a CraftCMS plugin that generates social media share links with
the Craft CP page, allowing you to quickly and easily share entries.
## Requirements
+Current Version: 2.0.0\
+This plugin requires Craft CMS ^4.0.0.
-This plugin requires Craft CMS 3.0.0-beta.23 or later.
+If you are looking for CraftCMS 3.x support, use current project [Version 1.0.8](https://github.com/wrav/SimpleSharing/tree/1.0.8)
-If use are looking for CraftCMS 2.5 support use previous project [version 1.1.5](https://github.com/hut6/SimpleSharing/tree/1.1.5)
-which is the latest release for CraftCMS 2.5.
+If you are looking for CraftCMS 2.5 support, use previous project [version 1.1.5](https://github.com/hut6/SimpleSharing/tree/1.1.5)
## Installing
diff --git a/composer.json b/composer.json
index 53337e8..8afd465 100755
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "wrav/simplesharing",
"description": "Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.",
"type": "craft-plugin",
- "version": "1.0.8",
+ "version": "2.0.0",
"keywords": [
"craft",
"cms",
@@ -31,7 +31,8 @@
}
],
"require": {
- "craftcms/cms": "^3.0.0-beta.23"
+ "php": ">=8.0.0",
+ "craftcms/cms": "^4.0.0"
},
"repositories": [
{
@@ -53,5 +54,11 @@
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/wrav/SimpleSharing/master/CHANGELOG.md",
"class": "wrav\\simplesharing\\SimpleSharing"
+ },
+ "config": {
+ "allow-plugins": {
+ "yiisoft/yii2-composer": true,
+ "craftcms/plugin-installer": true
+ }
}
}
diff --git a/src/SimpleSharing.php b/src/SimpleSharing.php
index cba862c..f25a92d 100755
--- a/src/SimpleSharing.php
+++ b/src/SimpleSharing.php
@@ -1,6 +1,6 @@
plugin === $this) {
- }
- }
- );
-
Event::on(
View::class,
- View::EVENT_END_PAGE,
- function(Event $event) {
+ ViewAlias::EVENT_END_PAGE,
+ function() {
if (Craft::$app->getRequest()->getIsCpRequest()) {
$url = Craft::$app->assetManager->getPublishedUrl('@wrav/simplesharing/assetbundles/simplesharing/dist/js/SimpleSharing.js', true);
-
echo "";
}
}
@@ -100,7 +86,7 @@ function(Event $event) {
/**
* @inheritdoc
*/
- protected function createSettingsModel()
+ protected function createSettingsModel(): ?Model
{
return new Settings();
}
@@ -110,10 +96,10 @@ protected function createSettingsModel()
*/
protected function settingsHtml(): string
{
- $sections = Craft::$app->sections->getAllSections('id');
+ $sections = Craft::$app->sections->getAllSections();
$optionsSections = [];
- foreach ($sections as $id => $section) {
+ foreach ($sections as $section) {
$optionsSections[$section->id] = $section->name;
}
@@ -121,7 +107,7 @@ protected function settingsHtml(): string
'facebook' => 'Facebook',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn',
-// 'pinterest' => 'Pinterest',
+ //'pinterest' => 'Pinterest',
'mix' => 'Mix',
'tumblr' => 'Tumblr',
'reddit' => 'Reddit',
diff --git a/src/assetbundles/simplesharing/dist/img/SimpleSharing-icon.svg b/src/assetbundles/simplesharing/dist/img/SimpleSharing-icon.svg
index 3a5a37f..11d66f7 100755
--- a/src/assetbundles/simplesharing/dist/img/SimpleSharing-icon.svg
+++ b/src/assetbundles/simplesharing/dist/img/SimpleSharing-icon.svg
@@ -1,52 +1 @@
-
-
-
-
+
diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php
index 816050a..e812206 100755
--- a/src/controllers/DefaultController.php
+++ b/src/controllers/DefaultController.php
@@ -1,6 +1,6 @@
request->getQueryParams();
$allowedSections = SimpleSharing::getInstance()->getSettings()->allowedSections;
$allowedPlatforms = SimpleSharing::getInstance()->getSettings()->allowedPlatforms;
if (!$allowedSections || (is_array($allowedSections) && in_array($data['sectionId'], $allowedSections))) {
- /** @var Entry|null $entry */
- $entry = Craft::$app->getEntries()->getEntryById($data['id']);
- if (null !== $entry && trim((string)$entry->url)) {
+ $entry = Craft::$app->getEntries()->getEntryById($data['id']);
+ if (null !== $entry && trim((string) $entry->url)) {
$btns = [];
- $encodedUrl = urlencode(trim($entry->url));
+ $encodedUrl = urlencode(trim((string) $entry->url));
$links = [
'facebook' => 'Facebook',
'twitter' => 'Twitter',
- 'linkedin' => 'LinkedIn',
-// 'pinterest' => 'Pinterest',
+ 'linkedin' => 'LinkedIn',
+ //'pinterest' => 'Pinterest',
'mix' => 'Mix',
'tumblr' => 'Tumblr',
'reddit' => 'Reddit',
@@ -72,6 +77,6 @@ public function actionUrl()
}
}
- Craft::$app->end();
+ throw new NotFoundHttpException();
}
}
diff --git a/src/models/Settings.php b/src/models/Settings.php
index c4537f4..24feec8 100755
--- a/src/models/Settings.php
+++ b/src/models/Settings.php
@@ -1,6 +1,6 @@
'https://www.facebook.com/sharer/sharer.php?u=' . $encodedUrl,
+ 'twitter' => 'https://twitter.com/intent/tweet?text=' . $encodedUrl,
+ 'linkedin' => 'https://www.linkedin.com/shareArticle?mini=true&title=&summary=&source=&url=' . $encodedUrl,
+ 'mix' => 'https://mix.com/add?url=' . $encodedUrl,
+ 'tumblr' => 'https://www.tumblr.com/share/link?url=' . $encodedUrl,
+ 'reddit' => 'http://www.reddit.com/submit?url=' . $encodedUrl,
+ default => null,
+ };
}
}