-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·240 lines (206 loc) · 7.67 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
<?php
/*
* Loads the Options Panel
*
* If you're loading from a child theme use stylesheet_directory
* instead of template_directory
*/
if ( !function_exists( 'optionsframework_init' ) ) {
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
}
/*
* Turns off the default options panel from Twenty Eleven
*/
add_action('after_setup_theme','remove_twentyeleven_options', 100);
function remove_twentyeleven_options() {
remove_action( 'admin_menu', 'twentyeleven_theme_options_add_page' );
}
//Set language folder and load textdomain
if (file_exists(STYLESHEETPATH . '/languages'))
$language_folder = (STYLESHEETPATH . '/languages');
else
$language_folder = (TEMPLATEPATH . '/languages');
load_theme_textdomain( 'img', $language_folder);
//Add support for post thumbnails
if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'post-thumbnails' );
// add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
// Homepage widgets
if ( function_exists( 'register_sidebar_widget' ))
register_sidebar(array(
'name'=> __( 'Home Left', 'img'),
'id' => 'left-home-box',
'before_widget' => '<div id="left-home-box"><li id="%1$s" class="widget %2$s">',
'after_widget' => '</li></div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
if ( function_exists( 'register_sidebar_widget' ))
register_sidebar(array(
'name'=> __( 'Home Center', 'img'),
'id' => 'center-home-box',
'before_widget' => '<div id="center-home-box"><li id="%1$s" class="widget %2$s">',
'after_widget' => '</li></div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
if ( function_exists( 'register_sidebar_widget' ))
register_sidebar(array(
'name'=> __( 'Home Right', 'img'),
'id' => 'right-home-box',
'before_widget' => '<div id="right-home-box"><li id="%1$s" class="widget %2$s">',
'after_widget' => '</li></div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
// Dynamic Sidebars
if ( function_exists( 'register_sidebar_widget' ))
register_sidebar(array(
'name'=> __( 'Sidebar', 'img'),
'id' => 'normal_sidebar',
'before_widget' => '<div class="page-sidebar"><li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
// Footer Sidebars
if ( function_exists( 'register_sidebar_widget' ))
register_sidebar(array(
'name'=> __( 'Footer Left', 'img'),
'id' => 'footer_left',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
if ( function_exists( 'register_sidebar_widget' ))
register_sidebar(array(
'name'=> __( 'Footer Center', 'img'),
'id' => 'footer_center',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
if ( function_exists( 'register_sidebar_widget' ))
register_sidebar(array(
'name'=> __( 'Footer Right', 'img'),
'id' => 'footer_right',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>',
));
// custom post type + menu item for it
//add dynamic menus
//Code http://www.1stwebdesigner.com/wordpress/how-to-add-backwards-compatible-wordpress-3-0-features-to-your-theme/
if (function_exists('wp_nav_menu')) {
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __('Secondary Menu'),
)
);
}
}
/*----------------------------------------
Slider Custom Post Type
---------------------------------------------*/
add_action( 'init', 'create_slider' );
function create_slider() {
register_post_type( 'img_slideshow',
array(
'labels' => array(
'name' => __( 'Slides' ),
'singular_name' => __( 'Slide' )
),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
)
);
}
/************************************************
Custom Header Image Code
Source: http://clark-technet.com/2012/04/wordpress-custom-headers-update-for-3-4
*************************************************/
add_action( 'after_setup_theme', 'theme_setup' );
function theme_setup() {
global $wp_version;
//Compare wp_version to know which way to add custom header support
if (version_compare($wp_version, '3.4' , '>=')){
add_theme_support( 'custom-header', array(
// Header image default
'default-image' => get_template_directory_uri() . '/images/headers/header.jpg',
// Header text display default
'header-text' => false,
// Header text color default
'default-text-color' => '000',
// Header image width (in pixels)
'width' => '1000',
// Header flex width changes width into suggested width
'flex-width' => true,
// Header image height (in pixels)
'height' => '200',
// Header flex height changes height into suggested height
'flex-height' => true,
// Header image random rotation default
'random-default' => true,
// Template header style callback
'wp-head-callback' => 'theme_header_style',
// Admin header style callback
'admin-head-callback' => 'theme_admin_header_style',
// Admin preview style callback
'admin-preview-callback' => 'theme_admin_header_image'
) );
} else {
add_theme_support( 'custom-header', array( 'random-default' => true ) );
//WP Custom Header - random rotation by default
define( 'HEADER_TEXTCOLOR', '' );
define( 'HEADER_IMAGE', '' );
define( 'HEADER_IMAGE_HEIGHT', '200' );
define( 'HEADER_IMAGE_WIDTH', '1000' );
define('NO_HEADER_TEXT', true );
add_custom_image_header( 'theme_header_style', 'theme_admin_header_style', 'theme_admin_header_image' );
}
register_default_headers( array(
'header' => array(
'url' => '%s/images/headers/header.jpg',
'thumbnail_url' => '%s/images/headers/header-thumbnail.jpg',
'description' => 'Header Image 1'
)
) );
}
//http://codex.wordpress.org/Adding_Administration_Menus
//<?php add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
add_action( 'admin_menu' , 'my_plugin_menu' );
function my_plugin_menu() {
add_options_page( 'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' );
}
function my_plugin_options() {
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrap">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}
function wpbootstrap_scripts_with_jquery()
{
// Register the script like this for a theme:
wp_register_script( 'custom-script', get_template_directory_uri() . '/bootstrap/js/bootstrap.min.js', array( 'jquery' ) );
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );
// Register Custom Navigation Walker
//https://github.com/twittem/wp-bootstrap-navwalker
//require_once('inc/twitter_bootstrap_nav_walker.php');
?>