-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·121 lines (100 loc) · 3.63 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
<?php
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'html5reset', TEMPLATEPATH . '/languages' );
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable($locale_file) )
require_once($locale_file);
// Add RSS links to <head> section
automatic_feed_links();
// Load jQuery
if ( !function_exists(core_mods) ) {
function core_mods() {
if ( !is_admin() ) {
wp_deregister_script('jquery');
wp_register_script('jquery', get_template_directory_uri() . "/_/js/jquery-1.7.2.min.js", false);
wp_enqueue_script('jquery');
}
}
core_mods();
}
// Clean up the <head>
function removeHeadLinks() {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
}
add_action('init', 'removeHeadLinks');
remove_action('wp_head', 'wp_generator');
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => __('Sidebar Widgets','html5reset' ),
'id' => 'sidebar-widgets',
'description' => __( 'These are widgets for the sidebar.','html5reset' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
}
add_theme_support( 'post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'audio', 'chat', 'video')); // Add 3.1 post format theme support.
register_nav_menu('main_menu', 'The Alpaka main menu');
register_nav_menu('footer_menu', 'The Alpaka footer menu');
function getImageForThumb($num) {
global $more;
$more = 1;
$content = get_the_content();
$count = substr_count($content, '<img');
$start = 0;
if ($count > 0) {
for($i=1;$i<=$count;$i++) {
$imgBeg = strpos($content, '<img', $start);
$post = substr($content, $imgBeg);
$imgEnd = strpos($post, '>');
$postOutput = substr($post, 0, $imgEnd+1);
$image[$i] = $postOutput;
$start=$imgEnd+1;
$cleanF = strpos($image[$num],'src="')+5;
$cleanB = strpos($image[$num],'"',$cleanF)-$cleanF;
$imgThumb = urlencode(substr($image[$num],$cleanF,$cleanB));
}
} else {
$image[1] = '<img';
$imgThumb = get_bloginfo('template_url') . '/images/default_thumb.jpg';
}
if(stristr($image[$num],'<img')) { return $imgThumb; }
$more = 0;
}
function custom_excerpt_length( $length ) {
return 45;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 240, 240 );
function new_excerpt_more($more) {
global $post;
return ' <a href="'. get_permalink($post->ID) . '">…</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
add_action('after_setup_theme', 'my_theme_setup');
function my_theme_setup(){
load_theme_textdomain('alpaka', get_template_directory() . '/languages');
}
// THIS INCLUDES THE THUMBNAIL IN OUR RSS FEED
add_filter( 'the_excerpt_rss', 'alpaka_insertThumbnailRSS' );
add_filter( 'the_content_feed', 'alpaka_insertThumbnailRSS' );
function alpaka_insertThumbnailRSS( $content ) {
global $post; $posts;
if ( has_post_thumbnail( $post->ID ) )
$content = '' . get_the_post_thumbnail( $post->ID ) . '' . $content;
else
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches[1][0];
if(!empty($first_img)){
$content = '<div>' . $first_img . '</div>' . $content;
}
return $content;
}
?>