/
functions.php
181 lines (140 loc) · 5.72 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
<?php
/**
* @package WordPress
* @subpackage AllTheTheme
* @since AllTheTheme 1.0
*/
// 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 allthetheme_setup() {
load_theme_textdomain( 'allthetheme', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'structured-post-formats', array( 'link', 'video' ) );
add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'quote', 'status' ) );
register_nav_menu( 'primary', __( 'Navigation Menu', 'allthetheme' ) );
add_theme_support( 'post-thumbnails' );
}
add_action( 'after_setup_theme', 'allthetheme_setup' );
// Scripts & Styles (based on twentythirteen: http://make.wordpress.org/core/tag/twentythirteen/)
/**
* Enqueue allthetheme scripts
* @return void
*/
// Load jQuery
if ( !is_admin() ) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"), false);
wp_enqueue_script('jquery');
}
function allthetheme_enqueue_scripts() {
wp_enqueue_style( 'allthetheme-styles', get_template_directory_uri() . '/static/css/style.css' ); //our stylesheet
wp_enqueue_script( 'jquery' );
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'allthetheme_enqueue_scripts' );
// WP Title (based on twentythirteen: http://make.wordpress.org/core/tag/twentythirteen/)
function allthetheme_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', 'allthetheme' ), max( $paged, $page ) );
//FIX
// if (function_exists('is_tag') && is_tag()) {
// single_tag_title("Tag Archive for ""); echo '" - '; }
// elseif (is_archive()) {
// wp_title(''); echo ' Archive - '; }
// elseif (is_search()) {
// echo 'Search for "'.wp_specialchars($s).'" - '; }
// elseif (!(is_404()) && (is_single()) || (is_page())) {
// wp_title(''); echo ' - '; }
// elseif (is_404()) {
// echo 'Not Found - '; }
// if (is_home()) {
// bloginfo('name'); echo ' - '; bloginfo('description'); }
// else {
// bloginfo('name'); }
// if ($paged>1) {
// echo ' - page '. $paged; }
return $title;
}
add_filter( 'wp_title', 'allthetheme_wp_title', 10, 2 );
// Custom Menu
register_nav_menu( 'primary', __( 'Navigation Menu', 'allthetheme' ) );
// Widgets
if ( function_exists('register_sidebar' )) {
function allthetheme_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar Widgets', 'allthetheme' ),
'id' => 'sidebar-primary',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'allthetheme_widgets_init' );
}
// 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( __( '<span class="sep">Posted </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a> by <span class="byline author vcard">%5$s</span>', '' ),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_author() )
);
}
//remove comments
add_filter('comments_open', '__return_false');
/* Uncomment to add custom image sizes
function allthetheme_add_image_sizes() {
add_image_size( 'allthetheme-thumb', 300, 100, true );
add_image_size( 'allthetheme-large', 600, 300, true );
}
add_action( 'init', 'allthetheme_add_image_sizes' );
function allthetheme_show_image_sizes($sizes) {
$sizes['allthetheme-thumb'] = __( 'AllTheTheme Thumb', 'allthetheme' );
$sizes['allthetheme-large'] = __( 'AllTheTheme Large', 'allthetheme' );
return $sizes;
}
add_filter('image_size_names_choose', 'allthetheme_show_image_sizes');
*/
/* Uncomment to add minimum image upload sizes
add_filter('wp_handle_upload_prefilter','allthetheme_handle_upload_prefilter');
//Set the minimum file sizes
$minimumWidth = '640';
$minimumHeight = '480';
function allthetheme_handle_upload_prefilter($file)
{
$img=getimagesize($file['tmp_name']);
$minimum = array('width' => $minimumWidth, 'height' => $minimumHeight);
$width= $img[0];
$height =$img[1];
if ($width < $minimum['width'] )
return array("error"=>"Image dimensions are too small. Minimum width is {$minimum['width']}px. Uploaded image width is $width px");
elseif ($height < $minimum['height'])
return array("error"=>"Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image height is $height px");
else
return $file;
}
*/
?>