/
functions.php
194 lines (175 loc) · 6.97 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
<?php
/**
* Skillcrush Starter functions and definitions
*
* Set up the theme and provides some helper functions, which are used in the
* theme as custom template tags. Others are attached to action and filter
* hooks in WordPress to change core functionality.
*
* When using a child theme you can override certain functions (those wrapped
* in a function_exists() call) by defining them first in your child theme's
* functions.php file. The child theme's functions.php file is included before
* the parent theme's file, so the child theme functions would be used.
*
* @link http://codex.wordpress.org/Theme_Development
* @link http://codex.wordpress.org/Child_Themes
*
* Functions that are not pluggable (not wrapped in function_exists()) are
* instead attached to a filter or action hook.
*
* For more information on hooks, actions, and filters,
* @link http://codex.wordpress.org/Plugin_API
*
* @package WordPress
* @subpackage Skillcrush_Starter
* since Skillcrush Starter 1.0
*/
// Theme support for post-thumbnails and menus
function beccamakesatheme_setup() {
// Post thumbnails support
add_theme_support('post-thumbnails');
// Register Menus
register_nav_menus ( array (
'primary-menu' => __( 'Primary Menu', 'beccamakesatheme' ),
'secondary' => __( 'Secondary Menu', 'beccamakesatheme' ),
) );
}
add_action( 'after_setup_theme', 'beccamakesatheme_setup' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
/* Custom Header */
$defaults = array(
'default-image' => '',
'width' => 200,
'height' => 138,
'flex-height' => false,
'flex-width' => true,
'uploads' => true,
'random-default' => false,
'header-text' => true,
'default-text-color' => '',
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
add_theme_support( 'custom-header', $defaults );
add_theme_support( 'custom-background' );
// Register widget area
function beccamakesatheme_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar 1', 'beccamakesatheme' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar.', 'beccamakesatheme' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Footer 1', 'beccamakesatheme' ),
'id' => 'footer-1',
'description' => __( 'Add widgets here to appear in your footer.', 'beccamakesatheme' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Home Top', 'beccamakesatheme' ),
'id' => 'home-top',
'description' => __( 'Add widgets here to appear at the top of your homepage', 'beccamakesatheme' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Front Page', 'beccamakesatheme' ),
'id' => 'front-page',
'description' => __( 'Add widgets here to appear at the top of your homepage', 'beccamakesatheme' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'beccamakesatheme_widgets_init' );
// Comments
function skillcrush_comments($comment, $args, $depth) {
$comment = '<li class="comment">';
$comment .= '<header class="comment-head">';
$comment .= '<span class="comment-author">' . get_comment_author() . '</span>';
$comment .= '<span class="comment-meta">' . get_comment_date('m/d/Y') . ' | ' . get_comment_reply_link(array('depth' => $depth, 'max_depth' => 5)) . '</span>';
$comment .= '</header>';
$comment .= '<div class="comment-body">';
$comment .= '<p>' . get_comment_text() . '</p>';
$comment .= '</div>';
$comment .= '</li>';
echo $comment;
}
function custom_excerpt_more($more) {
return '...';
}
add_filter('excerpt_more', 'custom_excerpt_more');
function create_custom_post_types() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio' ),
'singular_name' => __( 'Portfolio' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
)
);
}
add_action( 'init', 'create_custom_post_types' );
// Register Custom Post Type
function custom_post_type() {
$labels = array(
'name' => _x( 'Services', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Service', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Services', 'text_domain' ),
'name_admin_bar' => __( 'Services', 'text_domain' ),
'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
'all_items' => __( 'All Items', 'text_domain' ),
'add_new_item' => __( 'Add New Item', 'text_domain' ),
'add_new' => __( 'Add New', 'text_domain' ),
'new_item' => __( 'New Item', 'text_domain' ),
'edit_item' => __( 'Edit Item', 'text_domain' ),
'update_item' => __( 'Update Item', 'text_domain' ),
'view_item' => __( 'View Item', 'text_domain' ),
'search_items' => __( 'Search Item', 'text_domain' ),
'not_found' => __( 'Not found', 'text_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'Service', 'text_domain' ),
'description' => __( 'List of services offered', 'text_domain' ),
'labels' => $labels,
'supports' => array( ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'services', $args );
}
add_action( 'init', 'custom_post_type', 0 );
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'post-feature-img', 770, 120, true ); //(cropped)
add_image_size( 'home-portfolio', 460, 400, false );
add_image_size( 'home-blog', 460, 240, true );
}
if ( ! isset( $content_width ) ) {
$content_width = 800;
}