View difference between Paste ID: cTpJ2zFD and 8vSyZHkG
SHOW: | | - or go back to the newest paste.
1
<?php
2
/**
3
 * Roots functions
4
 */
5
6
if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); }
7
8
require_once locate_template('/inc/includes.php');   
9
10
function roots_setup() {
11
12
  // Make theme available for translation
13
  load_theme_textdomain('roots', get_template_directory() . '/lang');
14
15
  // Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
16
  register_nav_menus(array(
17
    'primary_navigation' => __('Primary Navigation', 'roots'),
18
  ));
19
20
  // Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
21
  add_theme_support('post-thumbnails');
22
23
24
  // Add post formats (http://codex.wordpress.org/Post_Formats)
25
  add_theme_support('post-formats', array('gallery', 'link', 'image', 'quote', 'video', 'audio'));
26
27
  // Tell the TinyMCE editor to use a custom stylesheet
28
  add_editor_style('assets/css/editor-style.css');
29
30
}
31
32
add_action('after_setup_theme', 'roots_setup');
33
34
35
add_action( 'admin_notices', 'is_options_css_writable' );
36
function is_options_css_writable(){
37
    if( !is_writable( locate_template('/css/options.css') ) )
38
        echo '<div class="updated"><p>css/options.css rights is not enough</p></div>';
39
}
40
41
42
add_filter( 'the_category', 'add_nofollow_cat' );
43
function add_nofollow_cat( $text ) {
44
    $text = str_replace('rel="category tag"', "", $text); return $text;
45
}
46
47
add_filter('widget_text', 'do_shortcode');
48
49
function limit_words($string, $word_limit) {
50
51
    // creates an array of words from $string (this will be our excerpt)
52
    // explode divides the excerpt up by using a space character
53
54
    $words = explode(' ', $string);
55
56
    // this next bit chops the $words array and sticks it back together
57
    // starting at the first word '0' and ending at the $word_limit
58
    // the $word_limit which is passed in the function will be the number
59
    // of words we want to use
60
    // implode glues the chopped up array back together using a space character
61
62
    return implode(' ', array_slice($words, 0, $word_limit));
63
64
}
65
66
67
add_filter( 'wp_get_attachment_image', 'remove_thumbnail_dimensions', 10 );
68
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
69
70
function remove_thumbnail_dimensions( $html ) {
71
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
72
    return $html;
73
}
74
75
// show admin bar only for admins
76
if (!current_user_can('manage_options')) {
77
    add_filter('show_admin_bar', '__return_false');
78
}
79
// show admin bar only for admins and editors
80
if (!current_user_can('edit_posts')) {
81
    add_filter('show_admin_bar', '__return_false');
82
}
83
84
function template_admin_head(){
85
    echo '<script>template_uri = "'.get_template_directory_uri().'";</script>';
86
    echo '<script>base_url = "'.home_url().'";</script>';
87
}
88-
add_action('admin_head', 'template_admin_head');
88+
add_action('admin_head', 'template_admin_head');
89
90
function dfi_per_catgory($dfi) {
91
	if ( has_category('10-things') ) {
92
	 return 17158; /*media id*/
93
	} else if( has_category('culinary') ) {
94
	 return 17155; /*media id*/
95
	} else if( has_category('foh') ) {
96
	 return 17149; /*media id*/
97
	} else if( has_category('holiday-posts') ) {
98
	 return 17159; /*media id*/
99
	} else if( has_category('hotel-notes') ) {
100
	 return 17157; /*media id*/
101
	} else if( has_category('travel-tuesday') ) {
102
	 return 17147; /*media id*/
103
	} else if( has_category('how-we-see-it') ) {
104
	 return 17107; /*media id*/
105
	} else if( has_category('coach') ) {
106
	 return 16137; /*media id*/
107
	} else if( has_category('consult') ) {
108
	 return 17160; /*media id*/
109
	} else if( has_category('podcasts') ) {
110
	 return 17148; /*media id*/
111
	} else if( has_category('pub-speak-facilitate') ) {
112
	 return 16785; /*media id*/
113
	} else if( has_category('qfo') ) {
114
	 return 16789; /*media id*/
115
	} else if( has_category('they-just-dont-get-it') ) {
116
	 return 17153; /*media id*/
117
	} else if( has_category('marketing-branding') ) {
118
	 return 17151; /*media id*/
119
	} else if( has_category('groupon') ) {
120
	 return 17146; /*media id*/
121
	} else if( has_category('guest-experience') ) {
122
	 return 17143; /*media id*/
123
	} else if( has_category('social-business') ) {
124
	 return 17142; /*media id*/
125
	} else if( has_category('surveys-research') ) {
126
	 return 17145; /*media id*/
127
	} else if( has_category('yelp') ) {
128
	 return 17144; /*media id*/
129
	} else if( has_category('people-culture-hwsi') ) {
130
	 return 16759; /*media id*/
131
	} else if( has_category('tlntmgmt') ) {
132
	 return 17150; /*media id*/
133
	} else if( has_category('train') ) {
134
	 return 16742; /*media id*/
135
	} else if( has_category('restaurant-notes') ) {
136
	 return 17161; /*media id*/
137
	} else if( has_category('business-2') ) {
138
	 return 16782; /*media id*/
139
	} else if( has_category('nso') ) {
140
	 return 17064; /*media id*/
141
	} else if( has_category('the-law') ) {
142
	 return 17156; /*media id*/
143
	} else if( has_category('govt-regs') ) {
144
	 return 17156; /*media id*/
145
	} else if( has_category('leadership-theory') ) {
146
	 return 17154; /*media id*/
147
	} else if( has_category('cost-controls-hwsi') ) {
148
	 return 16476; /*media id*/
149
	} else if( has_category('technology-2') ) {
150
	 return 17162; /*media id*/
151
	}
152
	return $dfi; // return the default $dfi
153
}
154
add_filter( 'dfi_thumbnail_id', 'dfi_per_catgory');