コード例 #1
0
ファイル: Extension.php プロジェクト: linhntaim/katniss
 public function register()
 {
     if (!$this->cacheEnable) {
         if ($this->gaEnable) {
             enqueue_theme_footer($this->gaAsync ? $this->gaScriptAsync() : $this->gaScript(), 'ga_script');
         }
         if ($this->mixPanelEnable) {
             enqueue_theme_footer($this->mixPanelScript(), 'mix_panel_script');
         }
     } else {
         enqueue_theme_footer(Html5::js(AssetHelper::jsUrl($this::EXTENSION_NAME)), $this::EXTENSION_NAME);
         if ($this->gaEnable && $this->gaAsync) {
             enqueue_theme_footer($this->gaJsAsync(), 'ga_js_async');
         }
     }
 }
コード例 #2
0
ファイル: Extension.php プロジェクト: linhntaim/katniss
 public function register()
 {
     $sharing_buttons = [];
     if ($this->facebookEnable) {
         enqueue_theme_footer($this->facebookJsSdk(), 'facebook_js_sdk');
         add_filter('open_graph_tags_before_render', new CallableObject(function ($data) {
             $data['fb:app_id'] = $this->facebookAppId;
             return $data;
         }));
         if ($this->facebookCommentEnable) {
             view()->share('facebook_comment', true);
             $color_scheme = $this->facebookCommentColorScheme;
             $num_posts = $this->facebookCommentNumPosts;
             $order_by = $this->facebookCommentOrderBy;
             $mobile = $this->facebookCommentMobile;
             $width = $this->facebookCommentWidth;
             $widthUnit = $this->facebookCommentWidthUnit;
             add_place('facebook_comment', new CallableObject(function ($url) use($color_scheme, $num_posts, $order_by, $mobile, $width, $widthUnit) {
                 $color_scheme = ' data-colorscheme="' . $color_scheme . '"';
                 $num_posts = ' data-numposts="' . $num_posts . '"';
                 $order_by = ' data-order-by="' . $order_by . '"';
                 if ($mobile != 'auto') {
                     $mobile = ' data-mobile="' . ($mobile == 'yes' ? 'true' : 'false') . '"';
                 }
                 $width = ' data-width="' . $width . $widthUnit . '"';
                 return '<div class="fb-comments" data-href="' . $url . '"' . $color_scheme . $num_posts . $order_by . $mobile . $width . '"></div>';
             }));
         }
         if ($this->facebookLikeEnable || $this->facebookShareEnable || $this->facebookRecommendEnable || $this->facebookSendEnable) {
             enqueue_theme_header('<style>.fb_iframe_widget > span{vertical-align: baseline!important;}</style>', 'facebook_css_fixed');
         }
         if ($this->facebookLikeEnable) {
             $sharing_buttons['facebook_like'] = '<div class="fb-like" data-href="{sharing_url}" data-layout="' . $this->facebookLikeLayout . '" data-action="like" data-show-faces="false" data-share="false"></div>';
         }
         if ($this->facebookShareEnable) {
             $sharing_buttons['facebook_share'] = '<div class="fb-share-button" data-href="{sharing_url}" data-layout="' . $this->facebookShareLayout . '"></div>';
         }
         if ($this->facebookRecommendEnable) {
             $sharing_buttons['facebook_recommend'] = '<div class="fb-like" data-href="{sharing_url}" data-layout="' . $this->facebookRecommendLayout . '" data-action="recommend" data-show-faces="false" data-share="false"></div>';
         }
         if ($this->facebookSendEnable) {
             $sharing_buttons['facebook_send'] = '<div class="fb-send" data-href="{sharing_url}"></div>';
         }
         if ($this->facebookSaveEnable) {
             $sharing_buttons['facebook_save'] = '<div class="fb-save" data-uri="{sharing_url}" data-size="small"></div>';
         }
     }
     if ($this->twitterEnable) {
         enqueue_theme_footer($this->twitterJsSdk(), 'twitter_js_sdk');
         if ($this->twitterShareEnable) {
             $sharing_buttons['twitter_tweet'] = '<a href="https://twitter.com/share" class="twitter-share-button" data-url="{sharing_url}" data-lang="' . currentLocaleCode() . '">Tweet</a>';
         }
     }
     if ($this->linkedInEnable) {
         enqueue_theme_footer($this->linkedInJsSdk(), 'linkedin_js_sdk');
         if ($this->linkedInShareEnable) {
             if ($this->linkedInShareCountMode != 'nocount') {
                 $sharing_buttons['linkedin_share'] = '<script type="IN/Share" data-url="{sharing_url}" data-counter="' . $this->linkedInShareCountMode . '"></script>';
             } else {
                 $sharing_buttons['linkedin_share'] = '<script type="IN/Share" data-url="{sharing_url}"></script>';
             }
         }
     }
     if ($this->googleEnable) {
         enqueue_theme_footer($this->googleJsSdk(), 'google_plus_js_sdk');
         if ($this->googleShareEnable) {
             if ($this->googleShareButtonAnnotation == 'inline') {
                 $sharing_buttons['google_share'] = '<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="300" data-href="{sharing_url}"></div>';
             } else {
                 $sharing_buttons['google_share'] = '<div class="g-plusone" data-size="' . $this->googleShareButtonSize . '" data-annotation="' . $this->googleShareButtonAnnotation . '" data-href="{sharing_url}"></div>';
             }
         }
     }
     add_place('sharing_buttons', new CallableObject(function ($sharing_url) use($sharing_buttons) {
         $buttons = content_filter('sharing_buttons', $sharing_buttons);
         if (count($buttons) > 0) {
             array_walk($buttons, function (&$button) use($sharing_url) {
                 $button = str_replace('{sharing_url}', $sharing_url, $button);
             });
             return '<ul class="list-inline"><li>' . implode('</li><li>', $buttons) . '</li></ul>';
         }
         return '';
     }));
 }