summaryrefslogtreecommitdiff
path: root/wordpress/functions.php
blob: ff849a237e62e7173dcc1cf38ff062d5556569c9 (plain)
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
<?php

// Replace jquery through the CDN version and move it to the footer
function movejquerytofooter(){
	if(!is_admin()){
		wp_deregister_script('jquery');
		wp_register_script('jquery', '//code.jquery.com/jquery-2.1.1.min.js', false, '1.3.2', true);

		wp_enqueue_script('jquery');
	}
}
add_action( 'init', 'movejquerytofooter');

// Disable W3TC footer comment for everyone but Admins (single site & network mode)
if ( !current_user_can( 'activate_plugins' ) ) {
	add_filter( 'w3tc_can_print_comment', function( $w3tc_setting ) { return false; }, 10, 1 );
}

// Add piwik tracking script without the plugin
function var_piwik() {
	if (!is_admin()) {
		wp_register_script( 'piwik', get_template_directory_uri() . '/js/piwik.js','',null,true);
		wp_enqueue_script('piwik');
	}
}
add_action( 'init', 'var_piwik');

// Add "Read more" button to custom excerpts
function custom_excerpt($text) {
	$text = preg_replace('/<\/p>$/', '', $text );
	$excerpt =  $text . '<br><a class="read-more-button" href="'. esc_url( get_permalink() ).'">' . __( 'Read more', 'papercuts' ) . '</a></p>';
	return $excerpt;
}
add_filter('the_excerpt', 'custom_excerpt');