Added publication-embed shortcode.
This commit is contained in:
44
includes/shortcodes/class-publication-embed.php
Normal file
44
includes/shortcodes/class-publication-embed.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package CleverOgre
|
||||
* @subpackage OgreIssuu
|
||||
* @version 0.1.0
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
||||
namespace OgreIssuu\Shortcodes;
|
||||
|
||||
use OgreIssuu\Api;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class PublicationEmbed extends Shortcode {
|
||||
|
||||
public function get_default_attributes():array {
|
||||
return [
|
||||
'slug' => '',
|
||||
'responsive' => true,
|
||||
'width' => '100%',
|
||||
'height' => '100%',
|
||||
'hideIssuuLogo' => false,
|
||||
'hideShareButton' => false,
|
||||
'showOtherPublications' => false,
|
||||
'bgColor' => '',
|
||||
'fullScreenShareBgColor' => '',
|
||||
];
|
||||
}
|
||||
|
||||
public function render(array $atts, string $content):void {
|
||||
$slug = $atts['slug'];
|
||||
unset($atts['slug']);
|
||||
if (empty($slug)) return;
|
||||
|
||||
$embed = Api::instance()->get_publication_embed($slug, $atts);
|
||||
if (is_null($embed) || !property_exists($embed, 'embed')) return;
|
||||
|
||||
echo $embed->embed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PublicationEmbed::instance();
|
||||
Reference in New Issue
Block a user