forked from baze/wp-starter-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
112 lines (99 loc) · 4.21 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
<?php
if ( ! class_exists('Timber')) {
add_action('admin_notices', function () {
echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . admin_url('plugins.php#timber') . '">' . admin_url('plugins.php') . '</a></p></div>';
});
return;
}
define('THEME_URL', get_template_directory_uri());
class StarterSite extends TimberSite
{
function __construct()
{
add_theme_support('post-formats');
add_theme_support('post-thumbnails');
add_theme_support('menus');
add_filter('timber_context', array($this, 'add_to_context'));
add_filter('get_twig', array($this, 'add_to_twig'));
add_action('init', array($this, 'register_post_types'));
add_action('init', array($this, 'register_taxonomies'));
add_action('wp_enqueue_scripts', array($this, 'load_styles'));
add_action('wp_footer', array($this, 'load_scripts'));
parent::__construct();
}
function register_post_types()
{
//this is where you can register custom post types
register_post_type('mitarbeiter', array(
'label' => 'Mitarbeiter',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'mitarbeiter', 'with_front' => true),
'query_var' => true,
'exclude_from_search' => true,
'supports' => array('title', 'editor', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'thumbnail', 'author', 'page-attributes', 'post-formats'),
'labels' => array(
'name' => 'Mitarbeiter',
'singular_name' => 'Mitarbeiter',
'menu_name' => 'Mitarbeiter',
'add_new' => 'Neuer Mitarbeiter',
'add_new_item' => 'Mitarbeiter hinzufügen',
'edit' => 'Bearbeiten',
'edit_item' => 'Mitarbeiter bearbeiten',
'new_item' => 'Neuer Mitarbeiter',
'view' => 'Ansehen',
'view_item' => 'Mitarbeiter ansehen',
'search_items' => 'Mitarbeiter durchsuchen',
'not_found' => 'Keine Mitarbeiter gefunden',
'not_found_in_trash' => 'Keine Mitarbeiter im Papierkorb gefunden',
'parent' => 'Übergeordneter Mitarbeiter',
)
));
}
function register_taxonomies()
{
//this is where you can register custom taxonomies
}
function add_to_context($context)
{
$context['foo'] = 'bar';
$context['stuff'] = 'I am a value set in your functions.php file';
$context['notes'] = 'These values are available everytime you call Timber::get_context();';
$context['primary_menu'] = new TimberMenu("Primary Navigation");
$context['secondary_menu'] = new TimberMenu("Secondary Navigation");
$context['user_menu'] = new TimberMenu("User Navigation");
$context['site'] = $this;
$context['penis'] = get_field('penis', 'option');
return $context;
}
function add_to_twig($twig)
{
/* this is where you can add your own fuctions to twig */
$twig->addExtension(new Twig_Extension_StringLoader());
$twig->addFilter('myfoo', new Twig_Filter_Function('myfoo'));
return $twig;
}
function load_styles()
{
wp_register_style('screen', THEME_URL . '/dest/css/screen.css', '', '', 'screen');
wp_enqueue_style('screen');
}
function load_scripts()
{
wp_enqueue_script('main', THEME_URL . '/dest/js/bundle.js', array(), '20140916', true);
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
}
}
new StarterSite();
function myfoo($text)
{
$text .= ' bar!';
return $text;
}