-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
177 lines (157 loc) · 6.41 KB
/
functions.php
File metadata and controls
177 lines (157 loc) · 6.41 KB
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
<?php
// Options Framework (https://github.com/devinsays/options-framework-plugin)
if ( !function_exists( 'optionsframework_init' ) ) {
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/_/inc/' );
require_once dirname( __FILE__ ) . '/_/inc/options-framework.php';
}
// Theme Setup (based on twentythirteen: http://make.wordpress.org/core/tag/twentythirteen/)
function themoment_setup() {
load_theme_textdomain( 'themoment', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'structured-post-formats', array( 'link', 'video' ) );
register_nav_menu( 'primary', __( 'Navigation Menu', 'themoment' ) );
add_theme_support( 'post-thumbnails' );
}
add_action( 'after_setup_theme', 'themoment_setup' );
// Scripts & Styles (based on twentythirteen: http://make.wordpress.org/core/tag/twentythirteen/)
function themoment_scripts_styles() {
global $wp_styles;
// Load Comments
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'themoment_scripts_styles' );
// WP Title (based on twentythirteen: http://make.wordpress.org/core/tag/twentythirteen/)
function themoment_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'themoment' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'themoment_wp_title', 10, 2 );
// Change the excerpt "read more" tags
function new_excerpt_more($more) {
global $post;
return ' <a class="read-more underline" href="'. get_permalink($post->ID) . '">Read more »</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
// Redirect after comment to main/referring page
function redirect_after_comment($location) {
return $_SERVER["HTTP_REFERER"] . '#success';
}
add_filter('comment_post_redirect', 'redirect_after_comment');
// Load/dequeue jQuery
if ( !function_exists( 'core_mods' ) ) {
function core_mods() {
if ( !is_admin() ) {
wp_deregister_script( 'jquery' );
//wp_register_script( 'jquery', ( "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ), false);
//wp_enqueue_script( 'jquery' );
}
}
add_action( 'wp_enqueue_scripts', 'core_mods' );
}
// Custom Menu
register_nav_menu( 'primary', __( 'Navigation Menu', 'themoment' ) );
// Navigation - update coming from twentythirteen
function post_navigation() {
echo '<div class="navigation">';
echo ' <div class="next-posts">'.get_next_posts_link('« Older Entries').'</div>';
echo ' <div class="prev-posts">'.get_previous_posts_link('Newer Entries »').'</div>';
echo '</div>';
}
// Posted On
function posted_on() {
printf( __( '<time class="entry-date" datetime="%1$s" pubdate>%2$s</time></a>', '' ),
esc_attr( get_the_time() ),
esc_attr( get_the_date() )
);
}
add_action( 'init', 'register_cpt_resource' );
function register_cpt_resource() {
$labels = array(
'name' => _x( 'Resources', 'resource' ),
'singular_name' => _x( 'Resource', 'resource' ),
'add_new' => _x( 'Add New', 'resource' ),
'add_new_item' => _x( 'Add New Resource', 'resource' ),
'edit_item' => _x( 'Edit Resource', 'resource' ),
'new_item' => _x( 'New Resource', 'resource' ),
'view_item' => _x( 'View Resource', 'resource' ),
'search_items' => _x( 'Search Resources', 'resource' ),
'not_found' => _x( 'No resources found', 'resource' ),
'not_found_in_trash' => _x( 'No resources found in Trash', 'resource' ),
'parent_item_colon' => _x( 'Parent Resource:', 'resource' ),
'menu_name' => _x( 'Resources', 'resource' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'All resources',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'taxonomies' => array( 'category' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'resource', $args );
}
add_action( 'init', 'register_cpt_event' );
function register_cpt_event() {
$labels = array(
'name' => _x( 'Events', 'event' ),
'singular_name' => _x( 'Event', 'event' ),
'add_new' => _x( 'Add New', 'event' ),
'add_new_item' => _x( 'Add New Event', 'event' ),
'edit_item' => _x( 'Edit Event', 'event' ),
'new_item' => _x( 'New Event', 'event' ),
'view_item' => _x( 'View Event', 'event' ),
'search_items' => _x( 'Search Events', 'event' ),
'not_found' => _x( 'No events found', 'event' ),
'not_found_in_trash' => _x( 'No events found in Trash', 'event' ),
'parent_item_colon' => _x( 'Parent Event:', 'event' ),
'menu_name' => _x( 'Events', 'event' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'All events',
'supports' => array( 'title', 'editor', 'thumbnail' ),
'taxonomies' => array( '' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 6,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'event', $args );
}
function remove_editor() {
remove_post_type_support('page', 'editor');
}
add_action('admin_init', 'remove_editor');
?>