Skip to content

Commit

Permalink
Merge pull request #5 from funilrys/shortcode-not-found
Browse files Browse the repository at this point in the history
Fix issue around "Class 'Grav\Plugin\Shortcodes\Shortcode' not found".
  • Loading branch information
AmauryCarrade committed Jul 26, 2020
2 parents b84a0cb + 59f41db commit f89959d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 31 deletions.
37 changes: 23 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
{
"name": "amaurycarrade/grav-plugin-static-social-embeds",
"description": "Embeds social status (like tweets, instagram posts, toots, etc.) in articles without using their embed iframe, but rather statically without any dependency to the service.",
"type": "project",
"require": {
"jedkirby/tweet-entity-linker": "^1.2"
"name": "amaurycarrade/grav-plugin-static-social-embeds",
"description": "Embeds social status (like tweets, instagram posts, toots, etc.) in articles without using their embed iframe, but rather statically without any dependency to the service.",
"type": "project",
"require": {
"jedkirby/tweet-entity-linker": "^1.2"
},
"license": "MIT",
"authors": [
{
"name": "Amaury Carrade",
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Grav\\Plugin\\Shortcodes\\": "shortcodes"
},
"license": "MIT",
"authors": [
{
"name": "Amaury Carrade",
"email": "[email protected]"
}
],
"minimum-stability": "stable"
}
"classmap": [
"static-social-embeds.php",
"classes/SSEShortcode.php"
]
}
}
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 20 additions & 12 deletions static-social-embeds.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Grav\Plugin;

use Grav\Common\Assets;
Expand All @@ -23,21 +24,31 @@ class StaticSocialEmbedsPlugin extends Plugin
*/
public static function getSubscribedEvents()
{
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/classes/SSEShortcode.php';

return [
'onPluginsInitialized' => ['onPluginsInitialized', 0]
'onPluginsInitialized' => [
['autoload', 100001],
['onPluginsInitialized', 0]
],
];
}

/**
* [onPluginsInitialized:100000] Composer autoload.
*
* @return ClassLoader
*/
public function autoload()
{
return require __DIR__ . '/vendor/autoload.php';
}

/**
* Initialize the plugin
*/
public function onPluginsInitialized()
{
// Don't proceed if we are in the admin plugin
if ($this->isAdmin()) {
// Don't proceed if we are in the admin plugin
return;
}

Expand Down Expand Up @@ -65,18 +76,15 @@ public function onAssetsInitialized()
/** @var $assets Assets */
$assets = $this->grav['assets'];

if ($this->config->get('plugins.static-social-embeds.include_font_awesome_5', true))
{
if ($this->config->get('plugins.static-social-embeds.include_font_awesome_5', true)) {
$assets->add('https://use.fontawesome.com/releases/v5.1.0/css/all.css');
}

if ($this->config->get('plugins.static-social-embeds.built_in_css', true))
{
if ($this->config->get('plugins.static-social-embeds.built_in_css', true)) {
$assets->add('plugin://static-social-embeds/assets/css-compiled/sse.min.css', 4);
}

if ($this->config->get('plugins.static-social-embeds.built_in_js', true))
{
if ($this->config->get('plugins.static-social-embeds.built_in_js', true)) {
$assets->addJs('plugin://static-social-embeds/assets/js/sse.js', 4, true, 'defer');
}
}
Expand All @@ -86,6 +94,6 @@ public function onAssetsInitialized()
*/
public function onShortcodeHandlers()
{
$this->grav['shortcode']->registerAllShortcodes(__DIR__.'/shortcodes');
$this->grav['shortcode']->registerAllShortcodes(__DIR__ . '/shortcodes');
}
}
8 changes: 4 additions & 4 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function isClassMapAuthoritative()
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}

/**
Expand Down Expand Up @@ -377,11 +377,11 @@ private function findFileWithExtension($class, $ext)
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
$length = $this->prefixLengthsPsr4[$first][$search];
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
Expand Down
2 changes: 2 additions & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
$baseDir = dirname($vendorDir);

return array(
'Grav\\Plugin\\Shortcodes\\SSEShortcode' => $baseDir . '/classes/SSEShortcode.php',
'Grav\\Plugin\\StaticSocialEmbedsPlugin' => $baseDir . '/static-social-embeds.php',
);
1 change: 1 addition & 0 deletions vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

return array(
'Jedkirby\\TweetEntityLinker\\' => array($vendorDir . '/jedkirby/tweet-entity-linker/src'),
'Grav\\Plugin\\Shortcodes\\' => array($baseDir . '/shortcodes'),
);
14 changes: 14 additions & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,34 @@ class ComposerStaticInit1c781dd30cc1c5fc04980a1fc07fda14
array (
'Jedkirby\\TweetEntityLinker\\' => 27,
),
'G' =>
array (
'Grav\\Plugin\\Shortcodes\\' => 23,
),
);

public static $prefixDirsPsr4 = array (
'Jedkirby\\TweetEntityLinker\\' =>
array (
0 => __DIR__ . '/..' . '/jedkirby/tweet-entity-linker/src',
),
'Grav\\Plugin\\Shortcodes\\' =>
array (
0 => __DIR__ . '/../..' . '/shortcodes',
),
);

public static $classMap = array (
'Grav\\Plugin\\Shortcodes\\SSEShortcode' => __DIR__ . '/../..' . '/classes/SSEShortcode.php',
'Grav\\Plugin\\StaticSocialEmbedsPlugin' => __DIR__ . '/../..' . '/static-social-embeds.php',
);

public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit1c781dd30cc1c5fc04980a1fc07fda14::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1c781dd30cc1c5fc04980a1fc07fda14::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1c781dd30cc1c5fc04980a1fc07fda14::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit f89959d

Please sign in to comment.