Esempio n. 1
0
 /**
  * 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();
 }
 /**
  * Returns the composite of the button.
  * @param \SocialSharing_Projects_Builder_Network $network
  * @return \SocialSharing_HtmlBuilder_AbstractElement
  */
 public function getButton(SocialSharing_Projects_Builder_Network $network)
 {
     return $this->builder->getButton($network);
 }
 /**
  * Returns the unique builder name.
  *
  * @return string
  */
 public function getName()
 {
     return $this->builder->getName();
 }