Esempio n. 1
0
 function display_topbar($is_shortcode = false, $shortcode_options = array(), $share_options = array())
 {
     $post_types = $this->general_options['display_in_types'];
     $is_valid = false;
     if ($is_shortcode == true) {
         $is_valid = true;
     } else {
         $is_valid = $this->check_applicability($post_types, 'topbar');
     }
     $output = "";
     if ($is_valid) {
         $topbar_content_area = ESSBOptionValuesHelper::options_bool_value($this->options, 'topbar_contentarea');
         $topbar_content_area_pos = ESSBOptionValuesHelper::options_value($this->options, 'topbar_contentarea_pos');
         $topbar_buttons_align = ESSBOptionValuesHelper::options_value($this->options, 'topbar_buttons_align', 'left');
         $topbar_usercontent = ESSBOptionValuesHelper::options_value($this->options, 'topbar_usercontent');
         if ($is_shortcode) {
             if (!empty($shortcode_options['topbar_contentarea'])) {
                 $topbar_content_area = ESSBOptionValuesHelper::unified_true($shortcode_options['topbar_contentarea']);
             }
             if (!empty($shortcode_options['topbar_contentarea_pos'])) {
                 $topbar_contentarea_pos = $shortcode_options['topbar_contentarea_pos'];
             }
             if (!empty($shortcode_options['topbar_buttons_align'])) {
                 $topbar_buttons_align = $shortcode_options['topbar_buttons_align'];
             }
             if (!empty($shortcode_options['topbar_usercontent'])) {
                 $topbar_usercontent = $shortcode_options['topbar_usercontent'];
             }
         }
         $topbar_usercontent = stripslashes($topbar_usercontent);
         $topbar_usercontent = do_shortcode($topbar_usercontent);
         if ($topbar_usercontent != '') {
             $topbar_usercontent = preg_replace(array('#%%title%%#', '#%%siteurl%%#', '#%%permalink%%#'), array(get_the_title(), get_site_url(), get_permalink()), $topbar_usercontent);
             $topbar_usercontent = ESSBCoreHelper::post_details_to_content($topbar_usercontent);
         }
         if (!$is_shortcode) {
             $ssbuttons = $this->generate_share_buttons('topbar');
         } else {
             $ssbuttons = $this->generate_share_buttons('topbar', 'share', $share_options, true, $shortcode_options);
         }
         $output = '';
         $output .= '<div class="essb_topbar">';
         $output .= '<div class="essb_topbar_inner">';
         if (!$topbar_content_area) {
             $output .= sprintf('<div class="essb_topbar_inner_buttons essb_bar_withoutcontent essb_topbar_align_%1$s">', $topbar_buttons_align);
             $output .= $ssbuttons;
             $output .= '</div>';
         } else {
             if ($topbar_content_area_pos == "left") {
                 $output .= '<div class="essb_topbar_inner_content">';
                 $output .= stripslashes($topbar_usercontent);
                 $output .= '</div>';
                 $output .= sprintf('<div class="essb_topbar_inner_buttons essb_topbar_align_%1$s">', $topbar_buttons_align);
                 $output .= $ssbuttons;
                 $output .= '</div>';
             } else {
                 $output .= sprintf('<div class="essb_topbar_inner_buttons essb_topbar_align_%1$s">', $topbar_buttons_align);
                 $output .= $ssbuttons;
                 $output .= '</div>';
                 $output .= '<div class="essb_topbar_inner_content">';
                 $output .= stripslashes($topbar_usercontent);
                 $output .= '</div>';
             }
         }
         $output .= '</div>';
         $output .= '</div>';
         if (!$is_shortcode) {
             echo $output;
         }
         essb_resource_builder()->add_js(ESSBResourceBuilderSnippets::js_build_generate_topbar_reveal_code(), true, 'essb-topbar-code');
     }
     if ($is_shortcode) {
         return $output;
     }
 }