AddThis.php 1.11 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<?php

namespace Magefan\Blog\Block\Social;

use Magento\Store\Model\ScopeInterface;

class AddThis extends \Magento\Framework\View\Element\Template
{
    /**
     * Retrieve AddThis status
     *
     * @return boolean
     */
    public function getAddThisEnabled()
    {
        return (bool)$this->_scopeConfig->getValue(
            'mfblog/social/add_this_enabled', ScopeInterface::SCOPE_STORE
        );
    }

    /**
     * Retrieve AddThis publisher id
     *
     * @return boolean
     */
    public function getAddThisPubId()
    {
        return $this->_scopeConfig->getValue(
            'mfblog/social/add_this_pubid', ScopeInterface::SCOPE_STORE
        );
    }

    /**
     * Retrieve AddThis language code
     *
     * @return boolean
     */
    public function getAddThisLanguage()
    {
        return $this->_scopeConfig->getValue(
            'mfblog/social/add_this_language', ScopeInterface::SCOPE_STORE
        );
    }

    public function toHtml()
    {
        if (!$this->getAddThisEnabled() || !$this->getAddThisPubId()) {
            return '';
        }

        return parent::toHtml();
    }
}