-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfunctions.php
218 lines (184 loc) · 6.05 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
<?php
/**
* Vendd functions and definitions
*
* @package Vendd
*/
/**
* Constants and important files
*/
define( 'VENDD_NAME', 'Vendd' );
define( 'VENDD_AUTHOR', 'Easy Digital Downloads' );
define( 'VENDD_VERSION', '1.2.7' );
define( 'VENDD_HOME', 'https://easydigitaldownloads.com/downloads/vendd' );
if ( ! function_exists( 'vendd_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features
*/
function vendd_setup() {
global $content_width;
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 722; /* pixels */
}
/**
* Make theme available for translation
*/
load_theme_textdomain( 'vendd', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head.
*/
add_theme_support( 'automatic-feed-links' );
/**
* Enable support for Post Thumbnails on posts and pages.
*/
add_theme_support( 'post-thumbnails' );
// add a hard cropped (for uniformity) image size for posts & some pages
add_image_size( 'vendd_featured_image', 722, 361, true );
// add a hard cropped (for uniformity) image size for full width pages
add_image_size( 'vendd_featured_image_full_width', 1120, 361, true );
// add a hard cropped (for uniformity) image size for content lists
add_image_size( 'vendd_featured_image_thumb', 200, 200, true );
// add a hard cropped (for uniformity) image size for the single downloads
add_image_size( 'vendd_product_image', 722, 361, true );
// add a hard cropped (for uniformity) image size for the product grid
add_image_size( 'vendd_downloads_shortcode_grid_image', 520, 260, true );
/**
* Theme nav menus
*/
register_nav_menus( array(
'info_bar' => __( 'Information Bar Menu', 'vendd' ),
'main_menu' => __( 'Main Menu', 'vendd' ),
) );
/**
* Switch default core markup to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
/**
* Setup the WordPress core custom background feature.
*/
add_theme_support( 'custom-background', apply_filters( 'vendd_custom_background_args', array(
'default-color' => 'f1f1f1',
'default-image' => /* get_template_directory_uri() . '/inc/images/your_image.png' */ '',
) ) );
/**
* Add theme support for title tag
*/
add_theme_support( 'title-tag' );
/**
* Split [downloads] taxonomy display into separate settings
*/
if ( get_theme_mod( 'vendd_downloads_taxonomies' ) ) {
set_theme_mod( 'vendd_downloads_cats', 1 );
set_theme_mod( 'vendd_downloads_tags', 1 );
remove_theme_mod( 'vendd_downloads_taxonomies' );
}
}
endif; // vendd_setup
add_action( 'after_setup_theme', 'vendd_setup' );
/**
* Add search to main menu
*/
function vendd_main_menu_search_form( $items, $location ) {
if ( 'main_menu' == $location->theme_location && 1 == get_theme_mod( 'vendd_menu_search' ) ) {
$items .= '<li class="nav-search-form-list-item"><span class="nav-search-form"><a class="nav-search-anchor" href="#"><i class="fa fa-search" aria-hidden="true"></i></a>' . get_search_form( false ) . '</span></li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'vendd_main_menu_search_form', 10, 2 );
/**
* Register widget area
*/
function vendd_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'vendd' ),
'id' => 'sidebar-main',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<span class="widget-title">',
'after_title' => '</span>',
) );
// only register download sidebar if EDD is activated
if ( class_exists( 'Easy_Digital_Downloads' ) ) {
register_sidebar( array(
'name' => __( 'Download Sidebar', 'vendd' ),
'id' => 'sidebar-download',
'description' => '',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<span class="widget-title">',
'after_title' => '</span>',
) );
}
}
add_action( 'widgets_init', 'vendd_widgets_init' );
/**
* Enqueue scripts and styles
*/
function vendd_scripts() {
// Theme stylesheet
wp_enqueue_style( 'vendd-style', get_stylesheet_uri() );
// Font Awesome
wp_enqueue_style( 'vendd-fontawesome', get_template_directory_uri() . '/inc/fonts/font-awesome/css/font-awesome.min.css', array(), VENDD_VERSION, 'all' );
// Vendd scripts
wp_enqueue_script( 'vendd-scripts', get_template_directory_uri() . '/inc/js/vendd-scripts.js', array( 'jquery' ), VENDD_VERSION, true );
// parallax background
if ( 1 == get_theme_mod( 'vendd_parallax_bg' ) ) :
wp_enqueue_script( 'vendd-parallax', get_template_directory_uri() . '/inc/js/parallax.js', array( 'jquery' ), VENDD_VERSION, true );
endif;
// Comment reply behavior
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'vendd_scripts' );
/**
* Admin page
*/
function vendd_updater() {
require( get_template_directory() . '/inc/admin/updater/theme-updater.php' );
}
add_action( 'after_setup_theme', 'vendd_updater' );
/**
* Custom conditional tags
*/
require get_template_directory() . '/inc/conditional-tags.php';
/**
* Custom EDD functions
*
* Only require if Easy Digital Downloads is activated
*/
if ( vendd_edd_is_activated() ) {
require get_template_directory() . '/inc/edd-functions.php';
}
/**
* Custom FES for EDD functions
*
* Only require if Frontend Submissions for Easy Digital Downloads is activated
*/
if ( vendd_fes_is_activated() ) {
require get_template_directory() . '/inc/fes-functions.php';
}
/**
* Vendd's widgets
*/
if ( vendd_edd_is_activated() ) {
require get_template_directory() . '/inc/admin/widgets.php';
}
/**
* Custom template tags
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates
*/
require get_template_directory() . '/inc/extras.php';
/**
* Customizer additions
*/
require get_template_directory() . '/inc/customizer.php';