Advertisement
Guest User

monstermod

a guest
Jun 1st, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.61 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Social Gallery Image Template
  4.  *
  5.  * This template is used to display Social Gallery images singularly.
  6.  * Depending on your theme it may be required that you edit this file
  7.  * You may want to seek assistance for this on the Forums @ http://forum.socialgalleryplugin.com
  8.  *
  9.  * Note on Customisation:
  10.  *     
  11.  *      If you want to edit this file please make a copy named "custom-single-social-gallery-image.php" and save it within this directory
  12.  *
  13.  * Copyright StormGate Ltd. 2012-2013
  14.  */
  15.  
  16.     global $thisSocialGalleryImage,$wpdb,$socialGallery_t,$socialGallery_Settings;
  17.    
  18.     if (count($thisSocialGalleryImage) == 1){
  19.    
  20.         #} Retrieve Image
  21.         global $socialGalleryImage,$sgtitleOverride; $socialGalleryImage = $thisSocialGalleryImage[0];
  22.        
  23.         #} Retrieve Options
  24.         $sgPageSidebar = $socialGallery_Settings->get('sgPageSidebar');
  25.         $sgPageWidth = $socialGallery_Settings->get('sgPageWidth');
  26.        
  27.         #} Build Title
  28.         $imageTitle = trim($socialGalleryImage->sg_ititle); if (empty($imageTitle) && !empty($socialGalleryImage->sg_idesc)) $imageTitle = $socialGalleryImage->sg_idesc;
  29.         $blogName = get_bloginfo('name'); $sgtitleOverride = $imageTitle; # .' | '. $blogName;
  30.        
  31.         #} Discern URL
  32.         $pageURL = sgpaba_71($socialGalleryImage->sg_iperma);
  33.        
  34.         #} Headers
  35.         add_action('wp_head', 'sgp38a_33');
  36.  
  37.         #} Set Title
  38.         add_filter( 'wp_title', 'sgpc8803_34', 10, 3 );
  39.    
  40.         #} Calculate Appropriate Sizes
  41.         if (isset($sgPageWidth)) $likeWidth = $sgPageWidth; else $likeWidth = 600;
  42.         if (isset($sgPageWidth)) $imgMaxWidth = $sgPageWidth; else $imgMaxWidth = 600;
  43.         if ($imgMaxWidth == 0) $imgMaxWidth = 600; if ($likeWidth == 0) $likeWidth = 600; $captionWidth = $imgMaxWidth; #defaults
  44.            
  45.         #} Image shortcode (for caption use) - only use if description and sizes present.
  46.         $imageStr = '<a href="'.$socialGalleryImage->sg_iurl.'" title="'.$socialGalleryImage->sg_idesc.'"><img src="'.$socialGalleryImage->sg_iurl.'" alt="" title="'.$socialGalleryImage->sg_idesc.'" style="max-width:'.$imgMaxWidth.'px" /></a>';
  47.         #} Discern proper description
  48.         if (isset($socialGalleryImage->sg_idesc))
  49.             if ($socialGalleryImage->sg_idesc != $sgtitleOverride){ # Don't repeat the caption otherwise.
  50.                 if (!empty($socialGalleryImage->sg_idesc) && $socialGalleryImage->sg_idim != 'NULL')
  51.                 if (isset($sgPageWidth)) $captionWidth = $sgPageWidth-20;
  52.                     $imageStr = do_shortcode('[caption width="'.$captionWidth.'" caption="'.$socialGalleryImage->sg_idesc.'"]'.$imageStr.'[/caption]');
  53.             }
  54.    
  55.         #} Discern Appears in
  56.         $appearsIn = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts where post_type = 'post' AND post_status = 'publish' AND ID IN (SELECT wp_postid FROM " . $socialGallery_t['imagelinks'] . " where sg_iid = %d)",$socialGalleryImage->sg_iid));
  57.    
  58.  
  59.    
  60.         # Required for any social gallery image page!
  61.         global $socialGalleryCurrentPerma;  $socialGalleryCurrentPerma = $socialGalleryImage->sg_iperma;
  62.         function socialGallery_define_currentPerm($socperma) {
  63.             global $socialGalleryCurrentPerma;
  64.             ?><script type="text/javascript">var sgpcurrperm = '<?php echo $socialGalleryCurrentPerma; ?>';</script><?php
  65.         }
  66.         add_action('wp_head', 'socialGallery_define_currentPerm');
  67.    
  68.    
  69.    
  70.         #} Continue with page load.
  71.         get_header(); ?>
  72.                        
  73.        
  74.             <div id="container">
  75.            
  76.             <div id="primary" class="site-content">
  77.            
  78.                 <div id="content" role="main">
  79.                
  80.                     <div class="socialGalleryItem"<?php if (isset($sgPageWidth)) if (!empty($sgPageWidth)) echo ' style="width:'.$sgPageWidth.'px"'; ?>>
  81.                        
  82.                         <!-- Social Gallery Page Header -->
  83.                         <header class="socialGallery-header">
  84.                             <h1 class="socialGallery-title"><?php echo $sgtitleOverride; ?></h1>
  85.                         </header>
  86.                    
  87.                         <!-- Social Gallery Page Image -->
  88.                         <div id="socialGalleryItemImage">
  89.                             <?php echo $imageStr; ?>
  90.                         </div>
  91.                    
  92.                         <!-- Social Gallery Page "Appears In" -->
  93.                         <?php if (count($appearsIn) > 0){ ?>
  94.                         <div id="socialGalleryItemAppearsIn">Appears in the post<?php if (count($appearsIn) > 1) echo 's'; ?>: <?php
  95.                        
  96.                                 $i = 0;                    
  97.                                 foreach ($appearsIn as $post){
  98.                                    
  99.                                     if ($i > 0) echo ', ';                 
  100.                                     echo '<a href="'.get_permalink($post->ID).'" title="'.$post->post_title.'">'.$post->post_title.'</a>'; 
  101.                                    
  102.                                     $i++;
  103.                                    
  104.                                 }
  105.    
  106.                          ?></div>
  107.                          <?php } ?>
  108.                        
  109.                         <!-- Social Gallery Page Share Options -->
  110.                         <?php if ($socialGallery_Settings->get('sgPageShareDeck') == 1){ ?>
  111.                         <div id="socialGalleryItemShareDeck">
  112.                        
  113.                             <div id="socialGalleryItemShareRows">
  114.                                 <p><strong>Share This</strong></p>
  115.                                 <div id="stTopRow">
  116.                                     <div id="sgTum"><a href="http://www.tumblr.com/share/photo?source=<?php echo urlencode(get_bloginfo('wpurl')) ?>&caption=<?php echo urlencode($sgtitleOverride) ?>&clickthru=<?php echo urlencode($pageURL) ?>" title="Share on Tumblr" target="_blank" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;">Share on Tumblr</a></div>
  117.                                     <div id="sgIN"><script type="IN/Share" data-url="<?php echo urlencode($pageURL) ?>" data-counter="right"></script></div>
  118.                                     <div id="sgGoog"><div class="g-plusone" data-size="medium" data-annotation="bubble" href="<?php echo urlencode($pageURL) ?>"></div></div>
  119.                                 </div>
  120.                                 <div id="stBottomRow">
  121.                                     <div id="sgTwi"><a href="https://twitter.com/share" class="twitter-share-button" data-via="SocialGalleryWP">Tweet</a></div>
  122.                                     <div id="sgPin"><a href="http://pinterest.com/pin/create/button/?url=<?php echo $pageURL; ?>&media<?php echo $socialGalleryImage->sg_iurl; ?>=&description=<?php echo $sgtitleOverride; ?>" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a></div>
  123.                                     <div id="sgSU"><div class="sbutton"><su:badge layout="1" location="<?php echo $pageURL; ?>"></su:badge></div></div>
  124.                                 </div>
  125.                                
  126.                                 <div class="fb-like" data-send="true" data-width="<?php echo $likeWidth; ?>" href="<?php echo $pageURL; ?>" data-show-faces="true" notify="true"></div>
  127.                                
  128.                             </div>
  129.                            
  130.                         </div>
  131.                         <script type="text/javascript">if (typeof socialGallery_LoadSocial != "undefined") jQuery(document).ready(function(e) {socialGallery_LoadSocial()})</script>
  132.                         <?php } ?>
  133.                          
  134.                         <!-- Social Gallery Page Comments -->
  135.                         <?php if ($socialGallery_Settings->get('sgPageComments') == 1){ ?>
  136.                          <div id="socialGalleryItemComments">
  137.                              <div class="fb-comments fb_iframe_widget" data-num-posts="10" href="<?php echo $pageURL; ?>" data-width="<?php echo $likeWidth; ?>" fb-xfbml-state="rendered" notify="true"></div>
  138.                          </div>
  139.                         <script type="text/javascript">if (typeof socialGallery_LoadComments != "undefined") jQuery(document).ready(function(e) {socialGallery_LoadComments('<?php echo $pageURL; ?>')})</script>
  140.                         <?php } ?>
  141.                         <?php if ($socialGallery_Settings->get('sgPageComments') == 2){ ?>
  142.                          <div id="socialGalleryItemComments">
  143.                              <div id="disqus_thread"></div>
  144.                          </div>
  145.                         <script type="text/javascript">if (typeof socialGallery_LoadComments != "undefined") jQuery(document).ready(function(e) {socialGallery_LoadComments('<?php echo $pageURL; ?>','<?php echo $sgtitleOverride; ?>',1)})</script>
  146.                         <?php } ?>
  147.                          
  148.                   </div><!-- #socialGalleryItem -->
  149.             </div><!-- #content -->
  150.         </div><!-- #container -->
  151. <?php   #} Close out the page
  152.         if ($sgPageSidebar) get_sidebar();
  153.         get_footer();
  154. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement