-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
226 lines (186 loc) · 8.79 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
<?php
require_once('inc/pagination.inc.php');
require_once('inc/template-tags.inc.php');
/**
* Include CSS files
*/
function theme_enqueue_scripts() {
wp_enqueue_style( 'Font_Awesome', 'https://use.fontawesome.com/releases/v5.6.1/css/all.css' );
wp_enqueue_style( 'Bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'MDB', get_template_directory_uri() . '/css/mdb.min.css' );
wp_enqueue_style( 'Style', get_template_directory_uri() . '/style.css' );
wp_enqueue_script( 'jQuery', get_template_directory_uri() . '/js/jquery-3.4.1.min.js', array(), '3.4.1', true );
wp_enqueue_script( 'Tether', get_template_directory_uri() . '/js/popper.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'Bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'MDB', get_template_directory_uri() . '/js/mdb.min.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );
/**
* Setup Theme
*/
function mdbtheme_setup() {
// Add featured image support
add_theme_support('post-thumbnails');
add_theme_support('title-tag');
add_theme_support('html5',
array('comment-list', 'comment-form', 'search-form')
);
add_theme_support('menus');
register_nav_menu('primary', 'Primary Menu');
register_nav_menu('footer', 'Footer Menu');
register_nav_menu('category', 'Product Category Menu');
}
add_action('after_setup_theme', 'mdbtheme_setup');
add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );
//Portfolio Post Type
function mdb_projects(){
register_post_type('projects',
array(
'rewrite' => array('slug' => 'projects'),
'labels' => array(
'name' => 'Projects',
'singular_name' => 'Project',
'menu_name' => 'Projects',
'all_items' => 'All Projects',
'add_new_item' => 'Add New Project',
'view_item' => 'View Project',
'edit_item' => 'Edit Project',
'search_item' => 'Search Project',
'not_found' => 'Not Found',
'not_found_in_trash' => 'Not found in trash'
),
'description' => 'Add portfolio/projects you have worked on!',
'menu-icon' => 'dashicons-portfolio',
'show_ui' => true,
'sjow_in_menu' => true,
'can_export' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'exclude_from_search' => false,
'public' => true,
'has-archive' => true,
'supports' => array(
'title','editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields'
),
'taxonomies' => array('category','tag')
)
);
}
add_action('init', 'mdb_projects', 0);
// Widgets
function mdb_widgets_init() {
register_sidebar( array(
'name' => 'Sidebar',
'id' => 'sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
}
add_action( 'widgets_init', 'mdb_widgets_init' );
// Filters
function search_filter($query){
if($query -> is_search()){
$query->set('post-type', array('post', 'projects'));
}
}
add_filter('pre_get_posts', 'search_filter');
// Footer widgets
function footer_widgets_init() {
// First footer widget area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'First Footer Widget Area', 'customfooter' ),
'id' => 'first-footer-widget-area',
'description' => __( 'The first footer widget area', 'customfooter' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Second Footer Widget Area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Second Footer Widget Area', 'customfooter' ),
'id' => 'second-footer-widget-area',
'description' => __( 'The second footer widget area', 'customfooter' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Third Footer Widget Area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Third Footer Widget Area', 'customfooter' ),
'id' => 'third-footer-widget-area',
'description' => __( 'The third footer widget area', 'customfooter' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Fourth Footer Widget Area, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Fourth Footer Widget Area', 'customfooter' ),
'id' => 'fourth-footer-widget-area',
'description' => __( 'The fourth footer widget area', 'customfooter' ),
'before_widget' => '<div id="%1$s" class="widget-container %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
// Register sidebars by running tutsplus_widgets_init() on the widgets_init hook.
add_action( 'widgets_init', 'footer_widgets_init' );
// Custom Background
$defaults = array(
'default-image' => '',
'default-preset' => 'fit', // 'default', 'fill', 'fit', 'repeat', 'custom'
'default-position-x' => 'center', // 'left', 'center', 'right'
'default-position-y' => 'center', // 'top', 'center', 'bottom'
'default-size' => 'cover', // 'auto', 'contain', 'cover'
'default-repeat' => 'no-repeat', // 'repeat-x', 'repeat-y', 'repeat', 'no-repeat'
'default-attachment' => 'scroll', // 'scroll', 'fixed'
'default-color' => '',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
add_theme_support( 'custom-background', $defaults );
// Custom Headers
$args = array(
'flex-width' => true,
'width' => 960,
'flex-height' => true,
'height' => 360,
'default-image' => get_template_directory_uri() . '/img/header.png',
'uploads' => true,
);
add_theme_support( 'custom-header', $args );
//Custom Logo
add_theme_support( 'custom-logo', array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
'uploads' => true
) );
function customtheme_add_woocommerce_support()
{
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'customtheme_add_woocommerce_support' );
remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40);
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta', 5);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
function woocommerce_template_product_short_description() {
woocommerce_get_template( 'single-product/short-description.php' );
}
add_action('woocommerce_single_product_summary', 'woocommerce_template_product_short_description', 10);
?>