-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
174 lines (143 loc) · 7 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
<?php
/**
*
*Sets 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 (see http://codex.wordpress.org/Theme_Development
* and http://codex.wordpress.org/Child_Themes), 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.
*
* 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 WpStrap
* @since wpstrap 1.0
*
* @return void
*/
//Enqueues scripts and styles for front end.
function cwd_wp_bootstrap_scripts_styles() {
//Calls Other Scripts
wp_enqueue_script( 'comment-reply' );
wp_enqueue_script('jquery');
// Loads Bootstrap minified JavaScript file.
wp_enqueue_script('bootstrapjs', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array('jquery'),'3.0.0', true );
// Loads Isotope minified JavaScript file.
wp_enqueue_script('isotopejs', get_template_directory_uri() . '/assets/js/jquery.isotope.min.js', array('jquery'),'1.5.25', true );
// Loads Backtop JavaScript file.
wp_enqueue_script( 'back-to-top', get_template_directory_uri() . '/assets/js/back-to-top.js', array( 'jquery' ), '6.2.1', true );
// Loads Bootstrap minified CSS file.
wp_enqueue_style('bootstrapwp', get_template_directory_uri() . '/assets/css/bootstrap.min.css', false ,'3.0.0');
// Loads Font Awesome minified CSS file.
wp_enqueue_style('Font_Awesome_wp', get_template_directory_uri() . '/assets/font-awesome/css/font-awesome.min.css', false ,'4.0.3');
// Loads our main stylesheet.
wp_enqueue_style('style', get_stylesheet_directory_uri() . '/style.css', array('bootstrapwp') ,'1.0');
}
add_action('wp_enqueue_scripts', 'cwd_wp_bootstrap_scripts_styles');
/**
* WordPress Widgets start right here.
*/
function wedesign_widgets_init() {
register_sidebar( array(
'name' => __( 'Primary Sidebar', 'wedesign' ),
'description' => __( 'Area 1 - sidebar.php - Displays on Default, Blog, Blog Excerpt page templates', 'wedesign' ),
'id' => 'primary-widget-area',
'before_widget' => '<div class="panel panel-default">',
'after_widget' => "</div></div>",
'before_title' => '<div class="panel-heading"><h3 class="panel-title">',
'after_title' => '</h3></div><div class="panel-body">',
) );
register_sidebar( array(
'name' => __( 'Home Widget 1', 'wedesign' ),
'description' => __( 'Area 6 - sidebar-home.php - Displays on the Home Page', 'wedesign' ),
'id' => 'home-widget-1',
'before_title' => '<div id="widget-title-one" class="widget-title-home"><h3>',
'after_title' => '</h3></div>',
'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
'after_widget' => '</div>'
) );
register_sidebar( array(
'name' => __( 'Home Widget 2', 'wedesign' ),
'description' => __( 'Area 7 - sidebar-home.php - Displays on the Home Page', 'wedesign' ),
'id' => 'home-widget-2',
'before_title' => '<div id="widget-title-two" class="widget-title-home"><h3>',
'after_title' => '</h3></div>',
'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
'after_widget' => '</div>'
) );
register_sidebar( array(
'name' => __( 'Home Widget 3', 'wedesign' ),
'description' => __( 'Area 8 - sidebar-home.php - Displays on the Home Page', 'wedesign' ),
'id' => 'home-widget-3',
'before_title' => '<div id="widget-title-three" class="widget-title-home"><h3>',
'after_title' => '</h3></div>',
'before_widget' => '<div id="%1$s" class="widget-wrapper %2$s">',
'after_widget' => '</div>'
) );
register_sidebar( array(
'name' => __( 'Footer Widget', 'wedesign' ),
'description' => __( 'Area 12 - sidebar-footer.php - Maximum of 3 widgets per row', 'wedesign' ),
'id' => 'footer-widget',
'before_title' => '<div class="headline"><h3>',
'after_title' => '</h3></div>',
'before_widget' => '<div class="col-md-4">',
'after_widget' => '</div>'
) );
}
add_action( 'widgets_init', 'wedesign_widgets_init' );
// Replaces the excerpt "more" text by a link
function new_excerpt_more($more) {
global $post;
return '<br><a class="btn btn-primary pull-right" href="'. get_permalink($post->ID) . '">Read More <span class="glyphicon glyphicon-chevron-right"></span></a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
//Calls nav menu
if ( ! function_exists( 'cwd_wp_bootstrapwp_theme_setup' ) ):
function cwd_wp_bootstrapwp_theme_setup() {
// Adds the main menu
register_nav_menus( array(
'main-menu' => __( 'Main Menu', 'cwd_wp_bootstrapwp' ),
) );
}
endif;
add_action( 'after_setup_theme', 'cwd_wp_bootstrapwp_theme_setup' );
//Require includes files
require_once 'inc/nav.php';
require_once 'inc/pagination.php';
require_once 'inc/comment_format.php';
require_once 'inc/breadcrumbs.php';
require_once 'inc/post-type.php';
require_once 'inc/Recent_Posts-widget.php';
//require( get_template_directory() . '/inc/slider/slider_post_type.php' ); // Create Front Page Slider Post Type
require( get_template_directory() . '/inc/slider/slider.php' ); // Create Front Page Slider
//Add support for thumbnails
if (function_exists('add_theme_support')) {
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 750, 250, true);
add_image_size('archives', 64, 64, true);
add_image_size('categories', 100, 100, true);
add_image_size('portifolio', 545, 335, true);
add_image_size('portifolios', 710, 440, true);
add_image_size( 'homepage-slide', 480, 260, true ); // Front page slide image
}
//Add Register Custom Widgets
add_action( 'widgets_init', 'olaw2jr_load_widgets' );
function olaw2jr_load_widgets() {
register_widget( 'Olaw2jr_Latest_Posts' );
}
//Rwrites rules
add_action('init', 'wpstrap_rewrite');
function wpstrap_rewrite() {
global $wp_rewrite;
$wp_rewrite->add_permastruct('typename', 'typename/%year%/%postname%/', true, 1);
add_rewrite_rule('typename/([0-9]{4})/(.+)/?$', 'index.php?typename=$matches[2]', 'top');
$wp_rewrite->flush_rules(); // !!!
}