/** * Builds the composite and returns button markup. * @return string */ public function build() { $environment = $this->builder->getEnvironment(); $dispatcher = $environment->getDispatcher(); $this->project = $dispatcher->apply('before_build', array($this->project)); if ((!array_key_exists('action', $_GET) || $_GET['action'] !== 'getPreviewHtml') && $this->project->isShowOnPosts() && !$this->project->isShowAt('popup')) { $current = get_post(); if ($current === null) { return ''; } if (!$this->project->isShortCodeShow() && $current->post_type === 'post' && (!$this->project->isShowOnAllPosts() && !$this->project->isShowOnSpecificPost($current->ID)) && !$this->project->showOnSpecificPostType($current->post_type) && !$this->project->isShowOnAllPostTypes()) { return ''; } if ($current->post_type === 'page' && (!$this->project->isShowOnAllPages() && !$this->project->isShowOnSpecificPost($current->ID)) && !$this->project->showOnSpecificPostType($current->post_type) && !$this->project->isShowOnAllPostTypes()) { return ''; } if (!$this->project->isShowOnAllPosts() && !$this->project->isShowOnAllPages() && !in_array($current->post_type, array('post', 'page'), false) && !$this->project->showOnSpecificPostType($current->post_type) && !$this->project->isShowOnAllPostTypes()) { return ''; } } if (!$this->project->isShortCodeShow() && !$this->project->isPopupShow() && $this->project->isShowOnHomepage() && !$this->builder->isHomepage()) { return ''; } try { $composite = $this->builder->getComposite(); } catch (Exception $e) { if (defined('WP_DEBUG') && WP_DEBUG && (function_exists('is_super_admin') && is_super_admin())) { return sprintf($this->environment->translate('Failed to build the project: %s.'), $e->getMessage()); } return ''; } $this->project = $dispatcher->apply('after_build', array($this->project)); $dispatcher->dispatch('before_html_build'); return $composite->build(); }
/** * Constructs the builder decorator. * * @param \SocialSharing_Projects_Builder $builder * @param array $networks */ public function __construct(SocialSharing_Projects_Builder $builder, array $networks) { parent::__construct($builder->getProject(), $builder->getEnvironment()); $this->builder = $builder; $this->networks = $networks; }
/** * Constructs the navigation decorator. * @param \SocialSharing_Projects_Builder $builder */ public function __construct(SocialSharing_Projects_Builder $builder) { parent::__construct($builder->getProject(), $builder->getEnvironment()); $this->builder = $builder; }