-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
109 lines (89 loc) · 3.95 KB
/
functions.php
File metadata and controls
109 lines (89 loc) · 3.95 KB
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
<?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="' . esc_url( admin_url( 'plugins.php#timber' ) ) . '">' . esc_url( admin_url( 'plugins.php') ) . '</a></p></div>';
});
add_filter('template_include', function($template) {
return get_stylesheet_directory() . '/static/no-timber.html';
});
return;
}
Timber::$dirname = array('templates', 'views');
class StarterSite extends TimberSite {
function __construct() {
add_theme_support( 'post-formats' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'menus' );
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
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, 'enqueue_styles_scripts'), 999 );
add_action( 'widgets_init', array($this, 'my_register_sidebars' ));
add_filter('timber/post/content/show_password_form_for_protected', function($maybe_show) { return true; });
parent::__construct();
}
function register_post_types() {
//this is where you can register custom post types
}
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['menu'] = new TimberMenu();
$context['primary_sidebar'] = Timber::get_widgets('Primary');
$context['site'] = $this;
return $context;
}
function myfoo( $text ) {
$text .= ' bar!';
return $text;
}
function add_to_twig( $twig ) {
/* this is where you can add your own functions to twig */
$twig->addExtension( new Twig_Extension_StringLoader() );
$twig->addFilter('myfoo', new Twig_SimpleFilter('myfoo', array($this, 'myfoo')));
return $twig;
}
function enqueue_styles_scripts() {
wp_enqueue_style( 'foundation-css', get_template_directory_uri() . '/inc/foundation/css/foundation.css', false);
wp_enqueue_style( 'main', get_template_directory_uri().'/inc/css/style.css' );
wp_enqueue_style( 'audiowide', 'https://fonts.googleapis.com/css?family=Audiowide&subset=latin-ext' );
wp_enqueue_script( 'What-Input-js', get_template_directory_uri() . '/inc/foundation/js/vendor/what-input.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'foundation-js', get_template_directory_uri() . '/inc/foundation/js/vendor/foundation.min.js', array( 'jquery' ),'', true );
wp_enqueue_script( 'site-js', get_template_directory_uri() . '/inc/js/site.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'parallax-js', get_template_directory_uri() . '/inc/js/parallax.min.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'fontawesome-js', 'https://use.fontawesome.com/4590fc1b46.js', array( 'jquery' ), '', true );
}
function my_register_sidebars() {
/* Register the 'primary' sidebar. */
register_sidebar(
array(
'id' => 'primary',
'name' => __( 'Primary' ),
'description' => __( 'A short description of the sidebar.' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
)
);
register_sidebar(
array(
'id' => 'aktualne',
'name' => __( 'Aktualne' ),
'description' => __( 'A short description of the sidebar.' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
)
);
/* Repeat register_sidebar() code for additional sidebars. */
}
}
new StarterSite();