Skip to content

Commit 822c0d0

Browse files
committed
Merge branch 'release/2.4.0'
2 parents 017fd83 + 47e49cf commit 822c0d0

23 files changed

+758
-75
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# v2.4.0
2+
## 02/11/2020
3+
4+
1. [](#new)
5+
* Pass phpstan level 1 tests
6+
* Requires shortcode-core plugin v4.2.0
7+
* Twig 2.0 compatibility
8+
1. [](#improved)
9+
* Code cleanup
10+
111
# v2.3.0
212
## 02/06/2019
313

blueprints.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Shortcode UI
2-
version: 2.3.0
2+
version: 2.4.0
33
description: "This plugin provides several UI shortcodes"
44
icon: code
55
author:
@@ -13,7 +13,8 @@ bugs: https://github.com/getgrav/grav-plugin-shortcode-ui/issues
1313
license: MIT
1414

1515
dependencies:
16-
- shortcode-core
16+
- { name: grav, version: '>=1.6.4' }
17+
- { name: shortcode-core, version: '>=4.2.0' }
1718

1819
form:
1920
validation: strict

twig/ShortcodeUITwigExtension.php renamed to classes/plugin/ShortcodeUiTwigExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Grav\Plugin;
2+
namespace Grav\Plugin\ShortcodeUi;
33

44
class ShortcodeUiTwigExtension extends \Twig_Extension
55
{
@@ -25,8 +25,8 @@ public function parsePositionFunc($position)
2525
preg_match('/(.+), *(.+), *(\w+)/', $position, $matches);
2626

2727
$position = [
28-
'location' => 'top:'.$matches[1].';left:'.$matches[2].';',
29-
'coords' => isset($matches[3]) ? $matches[3] : 'nw',
28+
'location' => 'top:' . $matches[1] . ';left:' . $matches[2] . ';',
29+
'coords' => $matches[3] ?? 'nw',
3030
];
3131

3232
return $position;

shortcodes/AccordionsShortcode.php renamed to classes/shortcodes/AccordionsShortcode.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@
22

33
namespace Grav\Plugin\Shortcodes;
44

5+
use Grav\Plugin\ShortcodeCore\Shortcode;
56
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
67

7-
88
class AccordionsShortcode extends Shortcode
99
{
1010
public function init()
1111
{
1212
$this->shortcode->getHandlers()->add('ui-accordion', function(ShortcodeInterface $sc) {
13-
1413
// Add assets
1514
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-accordion.css');
1615

1716
$hash = $this->shortcode->getId($sc);
1817

1918
$independent = filter_var($sc->getParameter('independent', false), FILTER_VALIDATE_BOOLEAN);
2019

21-
$output = $this->twig->processTemplate('partials/ui-accordion.html.twig', [
22-
'hash' => $hash,
23-
'open' => $sc->getParameter('open'),
24-
'type' => $independent ? 'checkbox' : 'radio',
25-
'accordion_items' => $this->shortcode->getStates($hash),
26-
]);
20+
$output = $this->twig->processTemplate(
21+
'partials/ui-accordion.html.twig',
22+
[
23+
'hash' => $hash,
24+
'open' => $sc->getParameter('open'),
25+
'type' => $independent ? 'checkbox' : 'radio',
26+
'accordion_items' => $this->shortcode->getStates($hash),
27+
]
28+
);
2729

2830
return $output;
2931
});
@@ -32,7 +34,8 @@ public function init()
3234
// Add accordion to accordion state using parent accordion id
3335
$hash = $this->shortcode->getId($sc->getParent());
3436
$this->shortcode->setStates($hash, $sc);
35-
return;
37+
38+
return '';
3639
});
3740
}
3841
}

shortcodes/AnimatedTextShortcode.php renamed to classes/shortcodes/AnimatedTextShortcode.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
namespace Grav\Plugin\Shortcodes;
44

55
use Grav\Common\Utils;
6+
use Grav\Plugin\ShortcodeCore\Shortcode;
67
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
78

8-
99
class AnimatedTextShortcode extends Shortcode
1010
{
1111
public function init()
1212
{
1313
$this->shortcode->getHandlers()->add('ui-animated-text', function(ShortcodeInterface $sc) {
14-
1514
// Add assets
1615
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-atext.css');
1716
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-atext.js');
@@ -30,20 +29,21 @@ public function init()
3029
$content = (array) $content;
3130
}
3231

33-
if (intval($visible) > count($words)) {
32+
if ((int)$visible > count($words)) {
3433
$visible = 1;
3534
}
3635

37-
$output = $this->twig->processTemplate('partials/ui-atext.html.twig', [
38-
'content' => $content,
39-
'words' => $words,
40-
'animation' => $animation,
41-
'element' => $sc->getParameter('element', 'h1'),
42-
'wrapper_extra' => Utils::contains($animation, 'type') ? ' waiting' : '',
43-
'visible' => $visible,
44-
]);
45-
46-
return $output;
36+
return $this->twig->processTemplate(
37+
'partials/ui-atext.html.twig',
38+
[
39+
'content' => $content,
40+
'words' => $words,
41+
'animation' => $animation,
42+
'element' => $sc->getParameter('element', 'h1'),
43+
'wrapper_extra' => Utils::contains($animation, 'type') ? ' waiting' : '',
44+
'visible' => $visible,
45+
]
46+
);
4747
});
4848
}
4949
}

shortcodes/BrowserShortcode.php renamed to classes/shortcodes/BrowserShortcode.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
namespace Grav\Plugin\Shortcodes;
44

5+
use Grav\Plugin\ShortcodeCore\Shortcode;
56
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
67

7-
88
class BrowserShortcode extends Shortcode
99
{
1010
public function init()
1111
{
1212
$this->shortcode->getHandlers()->add('ui-browser', function(ShortcodeInterface $sc) {
13-
1413
// Add assets
1514
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-browser.css');
1615

17-
$output = $this->twig->processTemplate('partials/ui-browser.html.twig', [
18-
'address' => $sc->getParameter('address', 'http://localhost'),
19-
'shortcode' => $sc,
20-
]);
21-
22-
return $output;
16+
return $this->twig->processTemplate(
17+
'partials/ui-browser.html.twig',
18+
[
19+
'address' => $sc->getParameter('address', 'http://localhost'),
20+
'shortcode' => $sc,
21+
]
22+
);
2323
});
2424
}
2525
}

shortcodes/CalloutShortcode.php renamed to classes/shortcodes/CalloutShortcode.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
namespace Grav\Plugin\Shortcodes;
44

5+
use Grav\Plugin\ShortcodeCore\Shortcode;
56
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
67

7-
88
class CalloutShortcode extends Shortcode
99
{
1010
public function init()
1111
{
1212
$this->shortcode->getHandlers()->add('ui-callout', function(ShortcodeInterface $sc) {
13-
1413
// Add assets
1514
$this->shortcode->addAssets('js', ['jquery', 101]);
1615
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-tooltips.js');
@@ -19,12 +18,15 @@ public function init()
1918

2019
$hash = $this->shortcode->getId($sc);
2120

22-
$output = $this->twig->processTemplate('partials/ui-callouts.html.twig', [
23-
'hash' => $hash,
24-
'shortcode' => $sc,
25-
'classes' => $sc->getParameter('class'),
26-
'callouts' => $this->shortcode->getStates($hash),
27-
]);
21+
$output = $this->twig->processTemplate(
22+
'partials/ui-callouts.html.twig',
23+
[
24+
'hash' => $hash,
25+
'shortcode' => $sc,
26+
'classes' => $sc->getParameter('class'),
27+
'callouts' => $this->shortcode->getStates($hash),
28+
]
29+
);
2830

2931
return $output;
3032
});
@@ -33,7 +35,8 @@ public function init()
3335
// Add tab to tab state using parent tabs id
3436
$hash = $this->shortcode->getId($sc->getParent());
3537
$this->shortcode->setStates($hash, $sc);
36-
return;
38+
39+
return '';
3740
});
3841
}
3942
}

shortcodes/ImageCompareShortcode.php renamed to classes/shortcodes/ImageCompareShortcode.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
namespace Grav\Plugin\Shortcodes;
44

5+
use Grav\Plugin\ShortcodeCore\Shortcode;
56
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
67

7-
88
class ImageCompareShortcode extends Shortcode
99
{
1010
public function init()
1111
{
1212
$this->shortcode->getHandlers()->add('ui-image-compare', function(ShortcodeInterface $sc) {
13-
1413
// Add assets
1514
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-cslider.css');
1615
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-cslider.js');
@@ -19,13 +18,16 @@ public function init()
1918

2019
preg_match_all('/<img.*(?:alt="(.*?)").*\/>/', $content, $matches);
2120

22-
if (sizeof($matches) == 2 && sizeof($matches[0]) == 2) {
23-
$output = $this->twig->processTemplate('partials/ui-cslider.html.twig', [
24-
'matches' => $matches,
25-
]);
26-
27-
return $output;
21+
if (count($matches) === 2 && count($matches[0]) === 2) {
22+
return $this->twig->processTemplate(
23+
'partials/ui-cslider.html.twig',
24+
[
25+
'matches' => $matches,
26+
]
27+
);
2828
}
29+
30+
return '';
2931
});
3032
}
3133
}

shortcodes/PolaroidShortcode.php renamed to classes/shortcodes/PolaroidShortcode.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
namespace Grav\Plugin\Shortcodes;
44

5+
use Grav\Plugin\ShortcodeCore\Shortcode;
56
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
67

7-
88
class PolaroidShortcode extends Shortcode
99
{
1010
public function init()
1111
{
1212
$this->shortcode->getHandlers()->add('ui-polaroid', function(ShortcodeInterface $sc) {
13-
1413
// Add assets
1514
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-polaroid.css');
1615

17-
$output = $this->twig->processTemplate('partials/ui-polaroid.html.twig', [
18-
'shortcode' => $sc,
19-
]);
20-
21-
return $output;
16+
return $this->twig->processTemplate(
17+
'partials/ui-polaroid.html.twig',
18+
[
19+
'shortcode' => $sc,
20+
]
21+
);
2222
});
2323
}
2424
}

shortcodes/TabsShortcode.php renamed to classes/shortcodes/TabsShortcode.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,39 @@
22

33
namespace Grav\Plugin\Shortcodes;
44

5+
use Grav\Plugin\ShortcodeCore\Shortcode;
56
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
67

7-
88
class TabsShortcode extends Shortcode
99
{
1010
public function init()
1111
{
1212
$this->shortcode->getHandlers()->add('ui-tabs', function(ShortcodeInterface $sc) {
13-
1413
// Add assets
1514
$this->shortcode->addAssets('js', ['jquery', 101]);
1615
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-tabs.js');
1716
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-tabs.css');
1817

1918
$hash = $this->shortcode->getId($sc);
2019

21-
$output = $this->twig->processTemplate('partials/ui-tabs.html.twig', [
22-
'hash' => $hash,
23-
'active' => $sc->getParameter('active', 0),
24-
'position' => $sc->getParameter('position', 'top-left'),
25-
'theme' => $sc->getParameter('theme', $this->config->get('plugins.shortcode-ui.theme.tabs', 'default')),
26-
'child_tabs' => $this->shortcode->getStates($hash),
27-
]);
28-
29-
return $output;
20+
return $this->twig->processTemplate(
21+
'partials/ui-tabs.html.twig',
22+
[
23+
'hash' => $hash,
24+
'active' => $sc->getParameter('active', 0),
25+
'position' => $sc->getParameter('position', 'top-left'),
26+
'theme' => $sc->getParameter('theme', $this->config->get('plugins.shortcode-ui.theme.tabs', 'default')),
27+
'child_tabs' => $this->shortcode->getStates($hash),
28+
]
29+
);
3030
});
3131

3232
$this->shortcode->getHandlers()->add('ui-tab', function(ShortcodeInterface $sc) {
3333
// Add tab to tab state using parent tabs id
3434
$hash = $this->shortcode->getId($sc->getParent());
3535
$this->shortcode->setStates($hash, $sc);
36-
return;
36+
37+
return '';
3738
});
3839
}
3940
}

0 commit comments

Comments
 (0)