forked from sdsweb/Simple-Shop-Theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
275 lines (241 loc) · 10 KB
/
functions.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
<?php
/**
*
* WARNING: Please do not edit this file.
* @see http://codex.wordpress.org/Child_Themes
*
* Load the theme function files (options panel, theme functions, widgets, etc...).
*/
include_once get_template_directory() . '/theme/class-simple-shop.php'; // Simple Shop Class (main functionality, actions/filters)
include_once get_template_directory() . '/theme/class-simple-shop-customizer.php'; // Simple Shop Customizer Class (specific to the customizer)
include_once get_template_directory() . '/includes/class-tgm-plugin-activation.php'; // TGM Activation
include_once get_template_directory() . '/includes/theme-options.php'; // SDS Theme Options
include_once get_template_directory() . '/includes/theme-functions.php'; // SDS Theme Options Functions
include_once get_template_directory() . '/includes/class-customize-us-control.php'; // Customize Controller
include_once get_template_directory() . '/includes/widget-social-media.php'; // SDS Social Media Widget
include_once get_template_directory() . '/theme/class-simple-shop-recent-posts.php'; // Simple Shop Recent Posts Widget
/**
* This function registers all content layouts available in this theme.
*/
if ( ! function_exists( 'sds_content_layouts' ) ) {
function sds_content_layouts() {
$content_layouts = array(
'default' => array( // Name used in saved option
'label' => __( 'Default', 'simple-shop' ), // Label on options panel (required)
'preview' => '<div class="cols cols-1 cols-default"><div class="col col-content" title="%1$s"><span class="label">%1$s</span></div></div>', // Preview on options panel (required; %1$s is replaced with values below on options panel if specified)
'preview_values' => array( __( 'Default', 'simple-shop' ) ),
'default' => true
),
'cols-2' => array( // Content Left, Primary Sidebar Right
'label' => __( 'Content Left', 'simple-shop' ),
'preview' => '<div class="cols cols-2"><div class="col col-content"></div><div class="col col-sidebar"></div></div>'
)
);
return apply_filters( 'sds_theme_options_content_layouts', $content_layouts );
}
}
/**
* This function modifies the global $content_width value based on content layout or page template settings.
*/
if ( ! function_exists( 'simple_shop_body_class' ) ) {
add_filter( 'body_class', 'simple_shop_body_class', 20 );
function simple_shop_body_class( $classes ) {
global $sds_theme_options, $content_width;
// Simple Shop Customizer
$simple_shop_customizer = Simple_Shop_Customizer_Instance();
// Content layout was specified by user in Theme Options
if ( isset( $sds_theme_options['body_class'] ) && ! empty( $sds_theme_options['body_class'] ) )
// 1 Column
if ( $sds_theme_options['body_class'] !== 'cols-1' )
$content_width = 950;
// Page Template was specified by the user for this page
if ( ! empty( $sds_theme_options['page_template'] ) && $sds_theme_options['page_template'] !== 'default' )
// Full Width or Landing Page
if ( in_array( $sds_theme_options['page_template'], array( 'page-full-width.php', 'page-landing-page.php' ) ) )
$content_width = 950;
// Customizer
if ( $simple_shop_customizer->is_customize_preview() )
$classes['simple-shop-customizer'] = 'customizer';
return $classes;
}
}
/**
* This function sets a default featured image size for use in this theme.
*/
if ( ! function_exists( 'sds_theme_options_default_featured_image_size' ) ) {
add_filter( 'sds_theme_options_default_featured_image_size', 'sds_theme_options_default_featured_image_size' );
function sds_theme_options_default_featured_image_size( $default ) {
return 'simple-shop-425x280';
}
}
/**
* Filters the blog title tag
*
* @param $tag
*
* @return string
*/
function sds_logo_filter( $tag ) {
return 'h1';
}
add_action( 'sds_logo_wrapper_element', 'sds_logo_filter', 1, 10 );
/**
* Filters the blog tagline tag
*
* @param $tag
*
* @return string
*/
function sds_tagline_filter( $tag ) {
return 'h2';
}
add_action( 'sds_tagline_wrapper_element', 'sds_tagline_filter', 1, 10 );
/**
* This function outputs a title for Archive page templates.
*
* Overwrites sds_archive_title in theme-functions.php line 219
*/
function sds_archive_title() {
global $sds_theme_options;
// Author
if ( is_author() ) :
$author = get_user_by( 'slug', get_query_var( 'author_name' ) ); // Get user data by slug with value of author_name in query
?>
<h1 title="<?php esc_attr_e( 'Author Archive:', 'simple-shop' ); ?> <?php echo ( $author instanceof WP_User ) ? $author->display_name : false; ?>" class="page-title author-archive-title block-title">
<?php _e( 'Author Archive:', 'simple-shop' ); ?> <?php echo ( $author instanceof WP_User ) ? $author->display_name : false; ?>
</h1>
<?php
// Categories
elseif ( is_category() ) :
?>
<h1 title="<?php single_cat_title( __( 'Category Archive: ', 'simple-shop' ) ); ?>" class="page-title category-archive-title block-title">
<?php single_cat_title( __( 'Category Archive: ', 'simple-shop' ) ); ?>
</h1>
<?php
// Tags
elseif ( is_tag() ) :
?>
<h1 title="<?php single_tag_title( __( 'Tag Archive: ', 'simple-shop' ) ); ?>" class="page-title tag-archive-title block-title">
<?php single_tag_title( __( 'Tag Archive: ', 'simple-shop' ) ); ?>
</h1>
<?php
// Daily Archives
elseif ( is_day() ) :
$the_date = get_the_date();
?>
<h1 title="<?php esc_attr_e( 'Daily Archives:', 'simple-shop' ); ?> <?php echo $the_date; ?>" class="page-title day-archive-title daily-archive-title block-title">
<?php _e( 'Daily Archives:', 'simple-shop' ); ?> <?php echo $the_date; ?>
</h1>
<?php
// Monthly Archives
elseif ( is_month() ) :
$the_date = get_the_date( 'F Y' );
?>
<h1 title="<?php esc_attr_e( 'Monthly Archives:', 'simple-shop' ); ?> <?php echo $the_date; ?>" class="page-title month-archive-title monthly-archive-title block-title">
<?php _e( 'Monthly Archives:', 'simple-shop' ); ?> <?php echo $the_date; ?>
</h1>
<?php
// Yearly Archives
elseif ( is_year() ) :
$the_date = get_the_date( 'Y' );
?>
<h1 title="<?php esc_attr_e( 'Yearly Archives:', 'simple-shop' ); ?> <?php echo $the_date; ?>" class="page-title year-archive-title yearly-archive-title block-title">
<?php _e( 'Yearly Archives:', 'simple-shop' ); ?> <?php echo $the_date; ?>
</h1>
<?php
endif;
}
if ( ! function_exists( 'sds_theme_options_ads' ) ) {
add_action( 'sds_theme_options_ads', 'sds_theme_options_ads' );
function sds_theme_options_ads() {
?>
<div class="sds-theme-options-ad">
<a href="<?php echo esc_url( sds_get_pro_link( 'theme-options-ad' ) ); ?>" target="_blank" class="sds-theme-options-upgrade-ad">
<h3><?php _e( 'Upgrade to Simple Shop Pro!', 'simple-shop' ); ?></h3>
<ul>
<li><?php _e( 'Priority Ticketing Support', 'simple-shop' ); ?></li>
<li><?php _e( 'More Customizer Settings - Colors & Typography', 'simple-shop' ); ?></li>
<li><?php _e( 'Conductor Support', 'simple-shop' ); ?></li>
<li><?php _e( 'Easily Add Custom Scripts/Styles', 'simple-shop' ); ?></li>
<li><?php _e( 'and More!', 'simple-shop' ); ?></li>
</ul>
<span class="sds-theme-options-btn-green"><?php _e( 'Upgrade Now!', 'simple-shop' ); ?></span>
</a>
</div>
<div class="sds-theme-options-ad">
<a href="<?php echo esc_url( 'http://conductorplugin.com/slocum-themes/' ); ?>" target="_blank" class="sds-theme-options-upgrade-ad sds-theme-options-upgrade-ad-dark-gray">
<h3><?php _e( 'Introducing Conductor Plugin', 'simple-shop' ); ?></h3>
<ul>
<li><?php _e( 'Custom Layouts', 'simple-shop' ); ?></li>
<li><?php _e( 'Custom Content Displays', 'simple-shop' ); ?></li>
<li><?php _e( 'No Code Required!', 'simple-shop' ); ?></li>
</ul>
<span class="sds-theme-options-btn-yellow"><?php _e( 'Get Conductor!', 'simple-shop' ); ?></span>
</a>
</div>
<?php
}
}
if ( ! function_exists( 'sds_theme_options_upgrade_cta' ) ) {
add_action( 'sds_theme_options_upgrade_cta', 'sds_theme_options_upgrade_cta' );
function sds_theme_options_upgrade_cta( $type ) {
switch( $type ) :
case 'color-schemes':
?>
<p>
<?php
printf( '<a href="%1$s" target="_blank">%2$s</a> %3$s',
esc_url( sds_get_pro_link( 'theme-options-colors' ) ),
__( 'Upgrade to Simple Shop Pro', 'simple-shop' ),
__( 'and receive more color schemes!', 'simple-shop' )
);
?>
</p>
<?php
break;
case 'web-fonts':
?>
<p>
<?php
printf( '<a href="%1$s" target="_blank">%2$s</a> %3$s',
esc_url( sds_get_pro_link( 'theme-options-fonts' ) ),
__( 'Upgrade to Simple Shop Pro', 'simple-shop' ),
__( 'to use more web fonts!', 'simple-shop' )
);
?>
</p>
<?php
break;
case 'help-support':
?>
<p>
<?php
printf( '<a href="%1$s" target="_blank">%2$s</a> %3$s',
esc_url( sds_get_pro_link( 'theme-options-help' ) ),
__( 'Upgrade to Simple Shop Pro', 'simple-shop' ),
__( 'to receive priority ticketing support!', 'simple-shop' )
);
?>
</p>
<?php
break;
endswitch;
}
}
function sds_get_pro_link( $content ) {
return esc_url( 'https://slocumthemes.com/wordpress-themes/simple-shop-pro/?utm_source=simple-shop&utm_medium=link&utm_content=' . urlencode( sanitize_title_with_dashes( $content ) ) . '&utm_campaign=pro#purchase-theme' );
}
if ( ! function_exists( 'sds_theme_options_help_support_tab_content' ) ) {
add_action( 'sds_theme_options_help_support_tab_content', 'sds_theme_options_help_support_tab_content' );
function sds_theme_options_help_support_tab_content( ) {
?>
<p><?php printf( __( 'If you\'d like to create a support request, please visit the <a href="%1$s">Simple Shop Forums on WordPress.org</a>.', 'simple-shop' ), esc_url( 'http://wordpress.org/support/theme/simple-shop/' ) ); ?></p>
<?php
}
}
if ( ! function_exists( 'sds_copyright_branding' ) ) {
add_filter( 'sds_copyright_branding', 'sds_copyright_branding', 10, 2 );
function sds_copyright_branding( $text, $theme_name ) {
return sprintf( __( '<a href="%1$s">%2$s by Slocum Studio</a>', 'simple-shop' ), esc_url( 'https://slocumthemes.com/wordpress-themes/simple-shop-free/' ), $theme_name );
}
}