示例#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();
 }
示例#2
0
 /**
  * Returns an array of the container classes.
  * @return array
  */
 protected function getContainerClasses()
 {
     $classes = array('supsystic-social-sharing', 'supsystic-social-sharing-package-' . strtolower($this->getName()));
     if ($this->project->isHiddenOnHomePage()) {
         $classes[] = 'supsystic-social-sharing-hide-on-homepage';
     }
     if ($this->isHomepage()) {
         $classes[] = 'supsystic-social-homepage';
     }
     if ($this->project->isHiddenOnMobile()) {
         $classes[] = 'supsystic-social-sharing-hide-on-mobile';
     }
     if ($this->project->isShowOnlyOnMobile()) {
         $classes[] = 'supsystic-social-sharing-show-only-on-mobile';
     }
     if (!$this->project->isPopupShow() && $this->project->isShowOnClick()) {
         $classes[] = 'supsystic-social-sharing-click';
     }
     if ($this->project->has('spacing')) {
         $classes[] = 'supsystic-social-sharing-spacing';
     }
     if ($this->project->isShowAtSidebar()) {
         $classes[] = 'supsystic-social-sharing-fixed';
         $classes[] = 'supsystic-social-sharing-' . $this->project->getExtra('left');
         if (function_exists('is_admin_bar_showing') && is_admin_bar_showing()) {
             $classes[] = 'supsystic-social-sharing-adminbar';
         }
     } else {
         $classes[] = 'supsystic-social-sharing-content';
         $alignInContent = $this->project->getAlignTypeInContent();
         switch ($alignInContent) {
             case 'left':
                 $classes[] = 'supsystic-social-sharing-content-align-left';
                 break;
             case 'right':
                 $classes[] = 'supsystic-social-sharing-content-align-right';
                 break;
             default:
                 $classes[] = 'supsystic-social-sharing-content-align-center';
         }
     }
     return $classes;
 }