View difference between Paste ID: PTdkT2Fn and C7udYcHm
SHOW: | | - or go back to the newest paste.
1
<?php
2
3
define( 'SITEORIGIN_THEME_VERSION' , '2.2.2' );
4
define( 'SITEORIGIN_THEME_ENDPOINT' , 'http://siteorigin.com' );
5
6
include get_template_directory().'/functions/settings.php';
7
include get_template_directory().'/functions/admin.php';
8
include get_template_directory().'/functions/gallery.php';
9
include get_template_directory().'/functions/panels.php';
10
11
if(file_exists(get_template_directory().'/premium/functions.php')){
12
	include get_template_directory().'/premium/functions.php';
13
}
14
15
if(!defined('SITEORIGIN_IS_PREMIUM')) {
16
	include get_template_directory().'/upgrade/upgrade.php';
17
}
18
19
include get_template_directory().'/extras/settings/settings.php';
20
include get_template_directory().'/extras/premium/premium.php';
21
include get_template_directory().'/extras/update/update.php';
22
include get_template_directory().'/extras/adminbar/adminbar.php';
23
include get_template_directory().'/extras/widgets/widgets.php';
24
25
if(!function_exists('snapshot_setup_theme')) :
26
/**
27
 * General theme setup
28
 * 
29
 * @action after_setup_theme
30
 */
31
function snapshot_setup_theme(){
32
	// Enable translation
33
	load_theme_textdomain( 'snapshot', get_template_directory() . '/languages' );
34
	
35
	// We're using SiteOrigin theme settings
36
	siteorigin_settings_init();
37
38
	global $content_width;
39
	if ( ! isset( $content_width ) ) $content_width = siteorigin_setting('posts_sidebar_images') ? 440 : 775;
40
	
41
	// The custom header is used for the logo
42
	add_theme_support('custom-header', array(	
43
		'flex-width' => true,
44
		'flex-height' => true,
45
		'header-text' => false,
46
	));
47
	
48
	// Custom background images are nice
49
	$background = array();
50
	switch(siteorigin_setting('appearance_style')){
51
		case 'light' :
52
			$background['default-color'] = 'FEFEFE';
53
			break;
54
		case 'dark' :
55
			$background['default-color'] = '333';
56
			$background['default-image'] = get_template_directory_uri().'/images/dark/bg.png';
57
			break;
58
	}
59
	add_theme_support('custom-background', $background);
60
	
61
	add_theme_support('post-thumbnails');
62
	
63
	add_theme_support( 'automatic-feed-links' );
64
65
	/**
66
	 * Support panels
67
	 */
68
	add_theme_support( 'siteorigin-panels', array(
69
		'margin-bottom' => 30,
70
		'responsive' => false,
71
		'home-page' => true,
72
		'home-page-default' => false,
73
	) );
74
	
75
	set_post_thumbnail_size(310, 420, true);
76
	add_image_size('single-large', 960, 960, false);
77
	add_image_size('single-large-landscape', 960, 540, true);
78
	
79
	add_image_size('slider-large', 1600, 1600, false);
80
	
81
	// The navigation menus
82
	register_nav_menu('main-menu', __('Main Menu', 'snapshot'));
83
84
	add_editor_style();
85
86
	// Only include the bundled version of panels if the plugin does not exist
87
	if(!defined('SITEORIGIN_PANELS_VERSION')) include get_template_directory().'/extras/panels/panels.php';
88
}
89
endif;
90
add_action('after_setup_theme', 'snapshot_setup_theme');
91
92
93
if(!function_exists('snapshot_print_scripts')) :
94
/**
95
 * Add the custom style CSS
96
 * @return mixed
97
 * 
98
 * @action wp_print_styles
99
 */
100
function snapshot_print_scripts(){
101
	if(is_admin()) return;
102
103
	$header = get_custom_header()
104
	?>
105
	<style type="text/css" media="all">
106
		a{ color: <?php echo esc_attr(siteorigin_setting('appearance_link')) ?>; }
107
		<?php if($header->url) : ?>
108
			#menu-main-menu,
109
			#top-area .menu > ul{
110
				width: <?php echo max(200, 960-$header->width - 20) ?>px;
111
			}
112
		<?php endif; ?>
113
	</style>
114
	<?php
115
}
116
endif;
117
add_action('wp_print_styles', 'snapshot_print_scripts');
118
119
120
if(!function_exists('snapshot_print_html_shiv')) :
121
/**
122
 * Display the HTML 5 shiv conditional
123
 */
124
function snapshot_print_html_shiv(){
125
	?>
126
	<!--[if lt IE 9]>
127
	<script src="<?php echo get_template_directory_uri(); ?>/js/html5shiv.js" type="text/javascript"></script>
128
	<![endif]-->
129
	<!--[if (gte IE 6)&(lte IE 8)]>
130
	<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/selectivizr.js"></script>
131
	<![endif]-->
132
	<?php
133
}
134
endif;
135
add_action('wp_print_scripts', 'snapshot_print_html_shiv');
136
137
138
if(!function_exists('snapshot_setup_widgets')) :
139
/**
140
 * Setup the widgets
141
 * 
142
 * @action widgets_init
143
 */
144
function snapshot_setup_widgets(){
145
	register_sidebar(array(
146
		'name' => __('Site Footer', 'snapshot'),
147
		'id' => 'site-footer',
148
	));
149
	
150
	// Register all the SiteOrigin widgets we'll be using.
151
	register_widget( 'SiteOrigin_Widgets_CTA' );
152
	register_widget( 'SiteOrigin_Widgets_Button' );
153
	register_widget( 'SiteOrigin_Widgets_IconText' );
154
	register_widget( 'SiteOrigin_Widgets_Headline' );
155
	register_widget( 'SiteOrigin_Widgets_Gallery' );
156
	register_widget( 'SiteOrigin_Widgets_PostContent' );
157
	register_widget( 'SiteOrigin_Widgets_Image' );
158
	register_widget( 'SiteOrigin_Widgets_PostLoop' );
159
}
160
endif;
161
add_action('widgets_init', 'snapshot_setup_widgets');
162
163
164
if(!function_exists('snapshot_enqueue_scripts')) :
165
/**
166
 * Enqueue Snapshot's Scripts.
167
 * 
168
 * @action wp_enqueue_scripts
169
 */
170
function snapshot_enqueue_scripts(){
171
	wp_enqueue_style('snapshot', get_stylesheet_uri(), array(), SITEORIGIN_THEME_VERSION);
172
	
173
	if(siteorigin_setting('appearance_style') != 'light'){
174
		wp_enqueue_style('snapshot-style', get_template_directory_uri().'/premium/style-'.siteorigin_setting('appearance_style').'.css', array(), SITEORIGIN_THEME_VERSION);
175
	}
176
177
	wp_enqueue_script('imgpreload', get_template_directory_uri() . '/js/jquery.imgpreload.min.js', array('jquery'), '1.4');
178
	wp_enqueue_script('fitvids', get_template_directory_uri() . '/js/jquery.fitvids.min.js', array('jquery'), '1.0');
179
	
180
	wp_enqueue_script('snapshot', get_template_directory_uri() . '/js/snapshot.min.js', array('jquery', 'imgpreload'), SITEORIGIN_THEME_VERSION);
181
182
	wp_localize_script('snapshot', 'snapshot', array(
183
		'sliderLoaderUrl' => get_template_directory_uri().'/images/slider-loader.gif',
184
		'imageLoaderUrl' => get_template_directory_uri().'/images/photo-loader.gif',
185
	));
186
	
187
	// Enqueue all the slider stuff
188
	wp_enqueue_script('imgpreload', get_template_directory_uri() . '/js/jquery.imgpreload.min.js', array('jquery'));
189
	wp_enqueue_script('snapshot-home', get_template_directory_uri() . '/js/snapshot-home.min.js', array('jquery'), SITEORIGIN_THEME_VERSION);
190
	wp_localize_script('snapshot-home', 'snapshotHome', array(
191
		'sliderSpeed' => siteorigin_setting('slider_speed'),
192
		'transitionSpeed' => siteorigin_setting('slider_transition'),
193
		'loaderUrl' => get_template_directory_uri().'/images/slider-loader.gif'
194
	));
195
	
196
	if ( is_singular() && get_option( 'thread_comments' ) )
197
		wp_enqueue_script( 'comment-reply' );
198
	
199
	if(is_singular() && siteorigin_setting('social_display_share'))
200
		wp_enqueue_script('snapshot-google-plusone', get_template_directory_uri() . '/js/plusone.min.js', array(), SITEORIGIN_THEME_VERSION);
201
		
202
}
203
endif;
204
add_action('wp_enqueue_scripts', 'snapshot_enqueue_scripts');
205
206
if(!function_exists('snapshot_wp_title')) :
207
/**
208
 * Filter the title
209
 * @param $title
210
 * @param $sep
211
 * @param $seplocation
212
 * @return string
213
 * 
214
 * @filter wp_title
215
 */
216
function snapshot_wp_title($title, $sep, $seplocation){
217
	if(trim($sep) != ''){
218
		if(!empty($title)) {
219
			$title_array = explode($sep, $title);
220
		}
221
		else $title_array = array();
222
		
223
		$title_array[] = get_bloginfo('title');
224
		if(is_home()) $title_array[] = get_bloginfo('description');
225
226
		$title_array = array_map('trim', $title_array);
227
		$title_array = array_filter($title_array);
228
		
229
		if($seplocation == 'left') $title_array = array_reverse($title_array);
230
		
231
		$title = implode( " $sep ", $title_array );
232
	}
233
	
234
	return $title;
235
}
236
endif;
237
add_filter('wp_title', 'snapshot_wp_title', 10, 3);
238
239
240
if(!function_exists('snapshot_single_comment')) :
241
/**
242
 * Display a single comment.
243
 * 
244
 * @param $comment
245
 * @param $depth
246
 * @param $args
247
 */
248
function snapshot_single_comment($comment, $args, $depth){
249
	$GLOBALS['comment'] = $comment;
250
	?>
251
	<li id="comment-<?php echo get_comment_ID() ?>" <?php comment_class() ?>>
252
		<?php if(empty($comment->comment_type) || $comment->comment_type == 'comment') : ?>
253
			<div class="comment-avatar">
254
				<?php echo get_avatar(get_comment_author_email(), 60) ?>
255
			</div>
256
		<?php elseif($comment->comment_type == 'trackback' || $comment->comment_type == 'pingback') : ?>
257
			<div class="pingback-icon"></div>
258
		<?php endif; ?>
259
		
260
		<div class="comment-main">
261
			<div class="comment-info">
262
				<span class="author"><?php echo get_comment_author_link() ?></span>
263
				<span class="date"><?php comment_date() ?></span>
264
		
265
				<?php comment_reply_link(array('depth' => $depth, 'max_depth' => $args['max_depth'])) ?>
266
			</div>
267
			<div class="comment-content entry-content">
268
				<?php comment_text() ?>
269
			</div>
270
		</div>
271
	<?php
272
}
273
endif;
274
275
276
if(!function_exists('snapshot_previous_posts_link_attributes')):
277
/**
278
 * Add the proper class to the posts nav link
279
 * @param $attr
280
 * @return string
281
 * 
282
 * @filter previous_posts_link_attributes
283
 */
284
function snapshot_previous_posts_link_attributes($attr){
285
	$attr = 'class="next"';
286
	return $attr;
287
}
288
endif;
289
add_filter('previous_posts_link_attributes', 'snapshot_previous_posts_link_attributes');
290
291
292
if(!function_exists('snapshot_next_posts_link_attributes')):
293
/**
294
 * Add the proper class to the posts nav link
295
 * @param $attr
296
 * @return string
297
 * 
298
 * @filter next_posts_link_attributes
299
 */
300
function snapshot_next_posts_link_attributes($attr){
301
	$attr = 'class="prev"';
302
	return $attr;
303
}
304
endif;
305
add_filter('next_posts_link_attributes', 'snapshot_next_posts_link_attributes');
306
307
308
if(!function_exists('snapshot_footer_widget_params')):
309
/**
310
 * Set the widths of the footer widgets
311
 *
312
 * @param $params
313
 * @return mixed
314
 * 
315
 * @filter dynamic_sidebar_params
316
 */
317
function snapshot_footer_widget_params($params){
318
	// Check that this is the footer
319
	if($params[0]['id'] != 'site-footer') return $params;
320
321
	$sidebars_widgets = wp_get_sidebars_widgets();
322
	$count = count($sidebars_widgets[$params[0]['id']]);
323
	$params[0]['before_widget'] = preg_replace('/\>$/', ' style="width:'.round(100/$count,4).'%" >', $params[0]['before_widget']);
324
325
	return $params;
326
}
327
endif;
328
add_filter('dynamic_sidebar_params', 'snapshot_footer_widget_params');
329
330
function snapshot_wp_page_menu($args){
331
	?><div id="menu-main-menu-container"><?php
332
	$args['walker'] = new Snapshot_Walker_Page; 
333
	wp_page_menu($args);
334
	?></div><?php
335
}
336
337
if(!class_exists('Snapshot_Walker_Page')) :
338
class Snapshot_Walker_Page extends Walker_Page{
339
	function start_lvl( &$output, $depth = 0, $args = array() ) {
340
		$indent = str_repeat("\t", $depth);
341
		$output .= "\n$indent<ul class='sub-menu'><div class='sub-wrapper'><div class='pointer'></div>\n";
342
	}
343
344
	function end_lvl( &$output, $depth = 0, $args = array() ) {
345
		$indent = str_repeat("\t", $depth);
346
		$output .= "$indent</div></ul>\n";
347
	}
348
349
	function start_el( &$output, $page, $depth, $args, $current_page = 0 ) {
350
		if ( $depth ) $indent = str_repeat("\t", $depth);
351
		else $indent = '';
352
353
		$output .= $indent . '<li class="menu-item"><a href="' . get_permalink($page->ID) . '">' . apply_filters( 'the_title', $page->post_title, $page->ID ) . '</a>';
354
	}
355
}
356
endif;
357
358
if(!class_exists('Snapshot_Walker_Nav_Menu')) :
359
class Snapshot_Walker_Nav_Menu extends Walker_Nav_Menu {
360
	function start_lvl( &$output, $depth = 0, $args = array() ) {
361
		$indent = str_repeat("\t", $depth);
362
		$output .= "\n$indent<ul class='sub-menu'><div class='sub-wrapper'><div class='pointer'></div>\n";
363
	}
364
365
	function end_lvl( &$output, $depth = 0, $args = array() ) {
366
		$indent = str_repeat("\t", $depth);
367
		$output .= "$indent</div></ul>\n";
368
	}
369
}
370
endif;
371
372
373
if(!function_exists('snapshot_get_slider_query')) :
374
/**
375
 * Get the method for the slider query
376
 */
377
function snapshot_get_slider_query(){
378
	$query_args = apply_filters('snapshot_slider_query_args', array(
379
		'post_type' => 'post',
380
		'posts_per_page' => siteorigin_setting('slider_post_count'),
381
	));
382
	return new WP_Query($query_args);
383
}
384
endif;
385
386
function snapshot_premium_before_post_summary(){
387
	if(! siteorigin_setting('posts_clickable_thumbnails')) return;
388
	?><a href="<?php the_permalink() ?>" class="post-content-link"><?php
389
}
390
add_action('before_post_summary', 'snapshot_premium_before_post_summary');
391
392
function snapshot_premium_after_post_summary(){
393
	if(! siteorigin_setting('posts_clickable_thumbnails')) return;
394
	?></a><?php
395
}
396
add_action('after_post_summary', 'snapshot_premium_after_post_summary');
397
398
399
if(!function_exists('so_setting')) :
400
/**
401
 * This is a wrapper for siteorigin_setting to support legacy child themes.
402
 *
403
 * @param $name
404
 * @param null $default
405
 * @return mixed
406
 */
407
function so_setting($name, $default = null){
408
	return siteorigin_setting($name, $default);
409
}
410-
endif;
410+
411
412
function wpufe_check_multisite_user( $permission ) {
413
 
414
    // if its multisite and the user belongs to this blog
415
    if ( is_multisite() ) {
416
        global $blog_id;
417
 
418
        if ( is_blog_user( $blog_id ) ) {
419
            return 'yes';
420
        } else {
421
            return 'no';
422
        }
423
    }
424
     
425
    return $permission;
426
}
427
 
428
add_filter( 'wpuf_can_post', 'wpufe_check_multisite_user' );