-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtemplate-gallery-3.php
executable file
·334 lines (278 loc) · 10.2 KB
/
template-gallery-3.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?php
/**
* The main template file for display portfolio page.
*
* Template Name: Gallery 3 Columns
* @package WordPress
*/
/**
* Get all photos
**/
$menu_sets_query = '';
$portfolio_items = -1;
/**
* Get Current page object
**/
$page = get_page($post->ID);
$current_page_id = '';
if(isset($page->ID))
{
$current_page_id = $page->ID;
}
//Check if password protected
$portfolio_password = get_post_meta($current_page_id, 'portfolio_password', true);
if(!empty($portfolio_password))
{
session_start();
if(!isset($_SESSION['gallery_page_'.$current_page_id]) OR empty($_SESSION['gallery_page_'.$current_page_id]))
{
include (get_template_directory() . "/templates/template-password.php");
exit;
}
}
//Get content gallery
$gallery_id = get_post_meta($current_page_id, 'page_gallery_id', true);
$args = array(
'post_type' => 'attachment',
'numberposts' => $portfolio_items,
'post_status' => null,
'post_parent' => $gallery_id,
'order' => 'ASC',
'orderby' => 'menu_order',
);
//Get gallery images
$all_photo_arr = get_posts( $args );
get_header();
//Get Page background style
$bg_style = get_post_meta($current_page_id, 'page_bg_style', true);
//Check browser and version for performance tuning
$isIE8 = ereg('MSIE 8',$_SERVER['HTTP_USER_AGENT']);
if($isIE8)
{
$bg_style = 'Static Image';
}
if($bg_style == 'Static Image')
{
if(has_post_thumbnail($current_page_id, 'full'))
{
$image_id = get_post_thumbnail_id($current_page_id);
$image_thumb = wp_get_attachment_image_src($image_id, 'full', true);
$pp_page_bg = $image_thumb[0];
}
else
{
$pp_page_bg = get_stylesheet_directory_uri().'/example/bg.jpg';
}
?>
<script type="text/javascript">
jQuery.backstretch( "<?php echo $pp_page_bg; ?>", {speed: 'slow'} );
</script>
<?php
} // end if static image
else
{
$page_bg_gallery_id = get_post_meta($current_page_id, 'page_bg_gallery_id', true);
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $page_bg_gallery_id,
'order' => 'ASC',
'orderby' => 'menu_order',
);
$bg_photo_arr = get_posts( $args );
?>
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/supersized.css" type="text/css" media="screen" />
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/supersized.3.1.3.js"></script>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/supersized.shutter.js"></script>
<script type="text/javascript">
jQuery(function($){
$.supersized({
//Functionality
slideshow : 1, //Slideshow on/off
autoplay : 1, //Slideshow starts playing automatically
start_slide : 1, //Start slide (0 is random)
random : 0, //Randomize slide order (Ignores start slide)
<?php
$pp_portfolio_slideshow_timer = get_option('pp_portfolio_slideshow_timer');
if(empty($pp_portfolio_slideshow_timer))
{
$pp_portfolio_slideshow_timer = 5000;
}
else
{
$pp_portfolio_slideshow_timer = $pp_portfolio_slideshow_timer*1000;
}
?>
slide_interval : <?php echo $pp_portfolio_slideshow_timer; ?>, //Length between transitions
<?php
$pp_portfolio_slideshow_trans = get_option('pp_portfolio_slideshow_trans');
if(empty($pp_portfolio_slideshow_trans))
{
$pp_portfolio_slideshow_trans = 1;
}
?>
transition : <?php echo $pp_portfolio_slideshow_trans; ?>, //0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
transition_speed : 500, //Speed of transition
new_window : 1, //Image links open in new window/tab
pause_hover : 0, //Pause slideshow on hover
keyboard_nav : 1, //Keyboard navigation on/off
performance : 1, //0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
image_protect : 0, //Disables image dragging and right click with Javascript
//Size & Position
min_width : 0, //Min width allowed (in pixels)
min_height : 0, //Min height allowed (in pixels)
vertical_center : 1, //Vertically center background
horizontal_center : 1, //Horizontally center background
<?php
$pp_portfolio_enable_fit_image = get_option('pp_portfolio_enable_fit_image');
if(empty($pp_portfolio_enable_fit_image))
{
$pp_portfolio_enable_fit_image = 1;
}
else
{
$pp_portfolio_enable_fit_image = 0;
}
?>
fit_portrait : <?php echo $pp_portfolio_enable_fit_image; ?>, //Portrait images will not exceed browser height
fit_landscape : <?php echo $pp_portfolio_enable_fit_image; ?>, //Landscape images will not exceed browser width
//Components
navigation : 1, //Slideshow controls on/off
thumbnail_navigation : 0, //Thumbnail navigation
slide_counter : 0, //Display slide numbers
slide_captions : 0, //Slide caption (Pull from "title" in slides array)
progress_bar : 1,
slides : [ //Slideshow Images
<?php
foreach($bg_photo_arr as $key => $photo)
{
$small_image_url = get_stylesheet_directory_uri().'/images/000_70.png';
$hyperlink_url = get_permalink($photo->ID);
if(!empty($photo->guid))
{
$image_url[0] = $photo->guid;
}
?>
<?php $homeslides .= '{image : \''.$image_url[0].'\', thumb: \''.$small_image_url.'\', title: "<div id=\"gallery_title\">'.htmlentities($photo->post_title).'</div><div id=\"gallery_desc\">'.htmlentities($photo->post_content).'</div>"},'; ?>
<?php
}
?>
<?php $homeslides = substr($homeslides,0,-1);
echo $homeslides; ?> ]
});
});
</script>
<div id="thumb-tray" class="load-item">
<div id="thumb-back"></div>
<div id="thumb-forward"></div>
<a id="prevslide" class="load-item"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/arrow_back.png" alt=""/></a>
<a id="nextslide" class="load-item"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/arrow_forward.png" alt=""/></a>
</div>
<div id="progress-back" class="load-item">
<div id="progress-bar"></div>
</div>
<input type="hidden" id="pp_image_path" name="pp_image_path" value="<?php echo get_stylesheet_directory_uri(); ?>/images/"/>
<?php
}
?>
<?php
//Display main gallery contents
if(!empty($all_photo_arr))
{
?>
<?php
//Get social media sharing option
$pp_social_sharing = get_option('pp_social_sharing');
if(!empty($pp_social_sharing))
{
?>
<div class="gallery_social">
<div class="each">
<iframe class="facebook_button" src="//www.facebook.com/plugins/like.php?app_id=262802827073639&href=<?php echo urlencode($page->guid); ?>&send=false&layout=box_count&width=200&show_faces=true&action=like&colorscheme=light&font&height=70" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:70px;" allowTransparency="true"></iframe>
</div>
<div class="each">
<a href="https://twitter.com/share" data-text="<?php echo $page->post_title; ?>" data-url="<?php echo $page->guid; ?>" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<div class="each">
<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="tall" href="<?php echo $page->guid; ?>"></g:plusone>
<!-- Place this render call where appropriate -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
</div>
<?php
}
?>
<div class="page_control">
<a id="page_minimize" href="#">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_minus.png" alt=""/>
</a>
<a id="page_maximize" href="#">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_plus.png" alt=""/>
</a>
</div>
<!-- Begin content -->
<div id="page_content_wrapper">
<div class="inner">
<div class="inner_wrapper">
<div id="page_caption" class="sidebar_content full_width" style="padding-bottom:0">
<h1 class="cufon"><?php echo $post->post_title; ?></h1>
</div>
<div class="sidebar_content full_width">
<?php
//Get page description
if(!empty($post->post_content))
{
?>
<?php echo pp_apply_content($post->post_content); ?><br/>
<?php
}
?>
<?php
foreach($all_photo_arr as $key => $photo)
{
$small_image_url = get_stylesheet_directory_uri().'/images/000_70.png';
$hyperlink_url = get_permalink($photo->ID);
if(!empty($photo->guid))
{
$image_url[0] = $photo->guid;
$small_image_url = wp_get_attachment_image_src($photo->ID, 'gallery_3', true);
}
$last_class = '';
if(($key+1)%3==0)
{
$last_class = 'last';
}
?>
<div class="one_third <?php echo $last_class; ?> gallery3">
<?php
if(!empty($small_image_url))
{
$pp_portfolio_enable_slideshow_title = get_option('pp_portfolio_enable_slideshow_title');
?>
<a class="fancy-gallery" rel="fancybox-thumb" href="<?php echo $image_url[0]; ?>" <?php if(!empty($pp_portfolio_enable_slideshow_title)) { ?>title="<?php echo $photo->post_title; ?>"<?php } ?>>
<img src="<?php echo $small_image_url[0]; ?>" alt="" class="one_third_img"/>
</a>
<?php
}
?>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
<br class="clear"/>
<?php get_footer(); ?>
<?php
}
?>