-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
216 lines (190 loc) · 5.84 KB
/
Copy pathfunctions.php
File metadata and controls
216 lines (190 loc) · 5.84 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
//functions.php v.3.1
function creaWidget(){
//Widget Area
register_sidebar(array(
"name" => __( 'Barra Laterale', 'ffalpha' ),
"id" => "sidebar-1",
"description" => "I widget sidebar dx",
"before_widget" => '<div class="widget">',
"after_widget" => '</div>',
"before_title" => '<h4>',
"after_title" => '</h4>'
));
register_sidebar(array(
"name" => "Footer-sx",
"id" => "sidebar-2",
"description" => "Footer a sinistra",
"before_widget" => '<div class="widget">',
"after_widget" => '</div>',
"before_title" => '<h4>',
"after_title" => '</h4>'
));
register_sidebar(array(
"name" => "Footer-cx",
"id" => "sidebar-3",
"description" => "Footer al centro",
"before_widget" => '<div class="widget">',
"after_widget" => '</div>',
"before_title" => '<h4>',
"after_title" => '</h4>'
));
register_sidebar(array(
"name" => "Footer-dx",
"id" => "sidebar-4",
"description" => "Footer a destra",
"before_widget" => '<div class="widget">',
"after_widget" => '</div>',
"before_title" => '<h4>',
"after_title" => '</h4>'
));
register_sidebar(array(
"name" => "Footer-last",
"id" => "sidebar-5",
"description" => "Footer in fondo",
"before_widget" => '<div class="widget">',
"after_widget" => '</div>',
"before_title" => '<h4>',
"after_title" => '</h4>'
));
register_sidebar(array(
"name" => "Header-right",
"id" => "sidebar-6",
"description" => "Header a destra",
"before_widget" => '<div class="widget">',
"after_widget" => '</div>',
"before_title" => '<h4>',
"after_title" => '</h4>'
));
}
add_action("widgets_init","creaWidget");
function creaMenu(){
//Registro una nuova navigazione
register_nav_menu("principale","Mia Navigazione Principale");
}
add_action("init","creaMenu");
function immagineEvidenza(){
//Attivo le immagini in evidenza degli articoli
add_theme_support('post-thumbnails');
}
add_action("init","immagineEvidenza");
//Paginazione
function pagination_nav() {
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) { ?>
<nav class="pagination" role="navigation">
<div class="nav-previous"><?php next_posts_link( '← Articoli meno recenti ' ); ?></div>
<div class="nav-next"><?php previous_posts_link( ' - Articoli piu recenti → ' ); ?></div>
</nav>
<?php }
}
//Carico Styles
function load_styles() {
//Carico CSS di Bootstrap
wp_register_style(
'bootstrapCSS',
get_template_directory_uri() . '/css/bootstrap.min.css',
//"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css",
array(),
null,
'all'
);
wp_register_style(
"fancyCSS",
get_bloginfo("template_url") . "/css/jquery.fancybox.min.css",
false,
"3.2.0",
"all"
);
wp_register_style(
'fawesomeCSS',
'https://use.fontawesome.com/releases/v5.0.6/css/all.css',
array(),
null,
'all'
);
// register style.css
wp_register_style('main_css', get_stylesheet_uri(), array("bootstrapCSS"), null, 'all');
//wp_register_style('theme-style', get_stylesheet_uri(), array(), null, 'all');
//enqueue styles
wp_enqueue_style("fancyCSS");
wp_enqueue_style("fawesomeCSS");
wp_enqueue_style("bootstrapCSS");
wp_enqueue_style('main_css');
}
add_action( 'wp_enqueue_scripts', 'load_styles', 11);
// Only on front-end pages, NOT in admin area
if (!is_admin()) {
function caricaScripts(){
//new
global $wp_scripts;
// Definisco il mio script
wp_register_script(
"myjs",
// get_bloginfo("template_url") . "/js/my.js",
get_bloginfo("template_url") . "/js/myscript.js",
array("jquery","popperJS","bootstrapJS"),
"1.0.0",
true
);
//Bootstrap Popper.js
wp_register_script(
"popperJS",
get_bloginfo("template_url") . "/js/popper.min.js",
array("jquery"),
"1.0",
true
);
//Bootstrap JS Plugins
wp_register_script(
"bootstrapJS",
get_bloginfo("template_url") . "/js/bootstrap.min.js",
//"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js",
array("jquery"),
"4.0.0",
true
);
// Caricamenti scripts (attenzione qui non importa l'ordine, le dipendenze sono indicate negli array() precedenti
wp_enqueue_script("myjs");
wp_enqueue_script("popperJS");
wp_enqueue_script("bootstrapJS");
}
add_action("wp_enqueue_scripts","caricaScripts");
} // end if !is_admin
//Dynamic caption text in fancybox
function add_title_attachment_link($link, $id = null) {
$id = intval( $id );
$_post = get_post( $id );
$post_title = esc_attr( $_post->post_excerpt );
return str_replace('<a href', '<a title="'. $post_title .'" href', $link);
}
add_filter('wp_get_attachment_link', 'add_title_attachment_link', 10, 2);
// Register Custom Navigation Walker
require_once('wp_bootstrap_navwalker.php');
//Gutenberg support
/**
* Add support for Gutenberg.
*
* @link https://wordpress.org/gutenberg/handbook/reference/theme-support/
*/
function mytheme_setup_theme_supported_features() {
// Theme supports wide images, galleries and videos.
add_theme_support( 'align-wide' );
// Make specific theme colors available in the editor.
add_theme_support( 'editor-color-palette',
array(
'name' => 'dark blue',
'color' => '#1767ef',
),
array(
'name' => 'light gray',
'color' => '#eee',
),
array(
'name' => 'dark gray',
'color' => '#444',
)
);
}
add_action( 'after_setup_theme', 'mytheme_setup_theme_supported_features' );
?>