-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.php
257 lines (224 loc) · 10.4 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
/** This entire theme is based on TwentyTen from WordPress 3.1. Edited as I saw fit ****/
add_action('after_setup_theme', 'wpst_setup');
function wpst_setup() {
// Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories. More info at http://codex.wordpress.org/Post_Formats
add_theme_support( 'post-formats', array( 'aside', 'audio', 'gallery', 'quote', 'link', 'image', 'status', 'chat', 'video' ) );
add_theme_support( 'post-thumbnails' ); // This theme uses Featured Images
add_theme_support( 'automatic-feed-links' ); // Add default posts and comments RSS feed links to <head>
// This theme uses wp_nav_menu() in one location. Add more as needed
register_nav_menus( array( 'primary' => 'Primary Navigation' ) );
}
add_action('comment_form_before', 'wpst_comment_enqueue');
function wpst_comment_enqueue() {
if(get_option( 'thread_comments' )) {
wp_enqueue_script( 'comment-reply' );
}
}
/*Register and enqueue javascript/styles*/
add_action('wp_enqueue_scripts', 'wpst_load_scripts');
function wpst_load_scripts() {
if(is_admin()) return;
wp_enqueue_script('jquery'); //can remove once you have another script that depends on jquery. Dependency auto-loads jquery in that case.
//wp_enqueue_script('cycle', get_stylesheet_directory_uri().'/js/jquery.cycle.all.min.js', array('jquery'));
//wp_enqueue_script('mailcheck', get_stylesheet_directory_uri().'/js/jquery.mailcheck.min.js', array('jquery'));
//Enqueue styles
wp_enqueue_style('normalize', get_stylesheet_directory_uri().'/css/normalize.css', null, 'all');
wp_enqueue_style('style', get_bloginfo('stylesheet_url'), 'normalize', null, 'all');
//wp_enqueue_style('sass', get_stylesheet_directory_uri().'/stylesheets/style.css', 'normalize', null, 'all');
}
/** Template for comments and pingbacks. */
function wpst_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' : ?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'twentyeleven' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyeleven' ), ' ' ); ?></p>
<?php
break;
default : ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<footer class="comment-meta">
<div class="comment-author vcard">
<?php
$avatar_size = 68;
if ( '0' != $comment->comment_parent )
$avatar_size = 39;
echo get_avatar( $comment, $avatar_size );
/* translators: 1: comment author, 2: date and time */
printf( __( '%1$s on %2$s <span class="says">said:</span>', 'twentyeleven' ),
sprintf( '<span class="fn">%s</span>', get_comment_author_link() ),
sprintf( '<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>',
esc_url( get_comment_link( $comment->comment_ID ) ),
get_comment_time( 'c' ),
/* translators: 1: date, 2: time */
sprintf( __( '%1$s at %2$s', 'twentyeleven' ), get_comment_date(), get_comment_time() )
)
);
?>
<?php edit_comment_link( __( '[Edit]', 'twentyeleven' ), ' ' ); ?>
</div><!-- .comment-author .vcard -->
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyeleven' ); ?></em>
<br />
<?php endif; ?>
</footer>
<div class="comment-content"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply ↓', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</article><!-- #comment-## -->
<?php
break;
endswitch;
}
/* Get wp_nav_menu() fallback, wp_page_menu(), to show home link. */
function wpst_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'wpst_page_menu_args' );
/** Prints HTML with meta information for the current post—date/time and author. */
function wpst_posted_on() {
printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
sprintf( esc_attr__( 'View all posts by %s', 'twentyeleven' ), get_the_author() ),
esc_html( get_the_author() )
);
}
/** Prints HTML with meta information for the current post (category, tags and permalink). */
function wpst_posted_in() {
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.';
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.';
} else {
$posted_in = 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.';
}
// Prints the string, replacing the placeholders.
printf(
$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
// browser detection via body_class
function wpst_browser_body_class($classes) {
//WordPress global vars available.
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if($is_lynx) $classes[] = 'lynx';
elseif($is_gecko) $classes[] = 'firefox';
elseif($is_opera) $classes[] = 'opera';
elseif($is_NS4) $classes[] = 'ns4';
elseif($is_safari) $classes[] = 'safari';
elseif($is_chrome) $classes[] = 'chrome';
elseif($is_IE) $classes[] = 'ie';
else $classes[] = 'unknown';
if($is_iphone) $classes[] = 'iphone';
//Adds a class of singular too when appropriate
if ( is_singular() && ! is_home() ) $classes[] = 'singular';
return $classes;
}
add_filter('body_class','wpst_browser_body_class');
// Post numbering via post_class
function wpst_add_post_classes( $classes ) {
global $wp_query;
if( $wp_query->found_posts < 1 ) return $classes;
if( $wp_query->current_post == 0 ) $classes[] = 'post-first';
if( $wp_query->current_post % 2 ) {
$classes[] = 'post-even';
} else {
$classes[] = 'post-odd';
}
if( $wp_query->current_post == ( $wp_query->post_count - 1 ) ) $classes[] = 'post-last';
return $classes;
}
add_filter( 'post_class', 'wpst_add_post_classes' );
/* Checks to see if we should blame nacin
@return bool true if we should blame nacin, false if we shouldn't */
function maybe_blame_nacin(){
return true;
}
//Apply do_shortcode() to widgets so that shortcodes will be executed in widgets
add_filter('widget_text', 'do_shortcode');
// REMOVE THE WORDPRESS UPDATE NOTIFICATION FOR ALL USERS EXCEPT SYSADMIN
global $user_login;
get_currentuserinfo();
if (!current_user_can('update_plugins')) { // checks to see if current user can update plugins
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
//Adds Attachment ID to Media Library admin columns
add_filter('manage_media_columns', 'posts_columns_attachment_id', 1);
add_action('manage_media_custom_column', 'posts_custom_columns_attachment_id', 1, 2);
function posts_columns_attachment_id($defaults){
$defaults['wps_post_attachments_id'] = __('ID');
return $defaults;
}
function posts_custom_columns_attachment_id($column_name, $id){
if($column_name === 'wps_post_attachments_id'){
echo $id;
}
}
//Add Plugins link to Admin Bar
function add_wpst_admin_bar_link($wp_admin_bar) {
if ( !is_super_admin() || !is_admin_bar_showing() )
return;
$wp_admin_bar->add_node( array(
'parent' => 'site-name',
'id' => 'ab-plugins',
'title' => 'Plugins',
'href' => admin_url('plugins.php')
) );
}
add_action('admin_bar_menu', 'add_wpst_admin_bar_link', 35);
// Admin Notice on Posts Page
//add_action('admin_head-post.php', 'wpst_postspage_error_notice');
function wpst_postspage_error_notice() {
$postspage = get_option('page_for_posts');
if (!empty($postspage))
add_action('admin_notices', 'wpst_postspage_print_notices');
}
function wpst_postspage_print_notices() {
$postspage = get_option('page_for_posts');
// show this only if we're editing the posts page
if (!empty($postspage) && isset($_GET['action']) && $_GET['action'] == 'edit' && $_GET['post'] == $postspage)
echo '<div class="error"><p>This page is a container for the most recent posts. It should always be empty, and you should never edit this page. To add a news item, go to <a href="post-new.php">Posts -- Add New</a>.<p></div>';
}
// function for inserting Google Analytics into the wp_footer
add_action('wp_footer', 'ga');
function ga() {
if ( !is_user_logged_in() ) { // not for logged in users ?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX']); // insert your Google Analytics id here
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php
}
}
// Includes the widgets.php file that defines all widget based functions.
require_once( get_template_directory() . '/widgets.php' );
require_once( get_template_directory() . '/inc/theme-options.php' );
require_once( get_template_directory() . '/inc/admin_appearance_mods.php' );
require_once( get_template_directory() . '/inc/meta.php' );
//Adding mail class files
require_once( get_template_directory() . '/inc/mail/func/functions.func.php');
require_once( get_template_directory() . '/inc/mail/class/notices.class.php');
require_once( get_template_directory() . '/inc/mail/class/form.class.php');