/** * If post view, setup the post with child blocks * * @return $this */ protected function _beforeToHtml() { if ($this->getPost() && $this->_getBlockForPostPrepare() !== false) { $this->preparePost($this->getPost()); } return parent::_beforeToHtml(); }
/** * Generate and return the ShareThis markup * * @return string */ protected function _toHtml() { if (Mage::helper('wp_addon_addthis')->isActiveOnPage()) { return $this->getHtml($this->getPost()); } return parent::_toHtml(); }
/** * Setup the comments block * */ protected function _beforeToHtml() { if (($commentsBlock = $this->getChild('comments')) !== false) { $commentsBlock->setPost($this->getPage()); } return parent::_beforeToHtml(); }
/** * Generate and return the ShareThis JS * * @return string */ protected function _toHtml() { $helper = Mage::helper('wp_addon_addthis'); if ($helper->isActiveOnPage()) { $config = array('data_track_clickback' => (bool) $helper->getOption('addthis_append_data'), 'data_track_addressbar' => (bool) $helper->getOption('data_track_addressbar'), 'data_track_textcopy' => (bool) $helper->getOption('addthis_copytracking2'), 'ui_atversion' => $helper->getVersion(), 'ui_header_background' => $helper->getOption('addthis_header_background'), 'ui_header_color' => $helper->getOption('addthis_header_color'), 'ui_cobrand' => $helper->getOption('addthis_brand'), 'ui_508_compliant' => (bool) $helper->getOption('addthis_508')); if ($helper->getOption('data_ga_property')) { $config['data_ga_property'] = $helper->getOption('data_ga_property'); $config['data_ga_social'] = true; } if ($helper->getOption('addthis_language') == '2') { $config['ui_language'] = $helper->getOption('addthis_language'); } $share = array(); if ($helper->getOption('addthis_twitter_template')) { $share['passthrough']['twitter']['via'] = $this->_getFirstTwitterUsername($helper->getOption('addthis_twitter_template')); } if ($helper->getOption('addthis_bitly_login') && $helper->getOption('addthis_bitly_key')) { $share['url_transforms']['shorten']['twitter'] = 'bitly'; $share['shorteners']['bitly']['login'] = $helper->getOption('addthis_bitly_login'); $share['shorteners']['bitly']['apiKey'] = $helper->getOption('addthis_bitly_key'); } return implode('', array(sprintf('<link rel="stylesheet" href="%s" media="all" />', Mage::helper('wordpress')->getBaseUrl('wp-content/plugins/addthis/css/output.css?ver=3.9')), '<script type="text/javascript">var addthis_product = \'wpp-3.5.1\';', $this->_mergeArrayJson($config, $helper->getOption('addthis_config_json'), "var addthis_config = '%s';"), sprintf("var addthis_options = {%s};", trim($helper->getOption('addthis_options'), '{}')), $this->_mergeArrayJson($share, $helper->getOption('addthis_share_json'), "if (typeof(addthis_share) == \"undefined\"){ addthis_share = %s;}"), '</script>', sprintf('<script type="text/javascript" src="//s7.addthis.com/js/%s/addthis_widget.js#pubid=%s"></script>', $helper->getVersion(), $helper->getPublisherId()))); } return parent::_toHtml(); }
/** * Load all enabled widgets * * @return Fishpig_Wordpress_Block_Sidebar */ protected function _beforeToHtml() { if (isset(self::$_lockedWidgetAreas[$this->getWidgetArea()])) { return $this; } self::$_lockedWidgetAreas[$this->getWidgetArea()] = true; if ($widgets = $this->getWidgetsArray()) { $this->_initAvailableWidgets(); foreach ($widgets as $widgetType) { $name = $this->_getWidgetName($widgetType); $widgetIndex = $this->_getWidgetIndex($widgetType); if ($widget = $this->getWidgetType($name)) { if ($block = $this->getLayout()->createBlock($widget['block'])) { if (isset($widget['template']) && !empty($widget['template'])) { $block->setTemplate($widget['template']); } $block->setWidgetType($name); $block->setWidgetIndex($widgetIndex); $this->setChild('wordpress_widget_' . $widgetType, $block); } } } } if (!$this->getTemplate()) { $this->setTemplate('wordpress/sidebar.phtml'); } return parent::_beforeToHtml(); }
/** * Attempt to load the widget information from the WordPress options table * * @return Fishpig_Wordpress_Block_Sidebar_Widget_Abstract */ protected function _beforeToHtml() { if ($this->getWidgetType()) { $data = $this->helper('wordpress')->getWpOption('widget_' . $this->getWidgetType()); if ($data) { $data = unserialize($data); if (isset($data[$this->getWidgetIndex()])) { foreach ($data[$this->getWidgetIndex()] as $field => $value) { if ($this->_fixOptionKeys) { $field = preg_replace('/([A-Z]{1})([A-Z]{1,})/e', "'\$1' . strtolower('\$2');", $field); $field = preg_replace('/([A-Z]{1})/e', "'_' . strtolower('\$1');", $field); } $this->setData($field, $value); } } } } return parent::_beforeToHtml(); }
/** * This block is deprecated and will no longer work * * @return $this */ protected function _beforeToHtml() { $this->setTemplate(null); return parent::_beforeToHtml(); }
/** * Ensure the DB details are set * * @return $this */ protected function _prepareLayout() { $this->helper('wordpress/database')->connect(); return parent::_prepareLayout(); }