-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
313 lines (266 loc) · 8.93 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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
/*
Theme Name: Brasa 2018
Theme URI: http://brasa.art.br
Description: Brasa 2018 - Tema filho do Tema Coletivo
Author: Matheus Gimenez
Author URI: http://brasa.art.br
Template: tema-coletivo
Version: 0.1alpha
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: brasa2018
*/
/**
* Set coletivo_load_default_fonts filter to false to avoid load default fonts
* @param boolean $value
* @return boolean
*/
function brasa2018_coletivo_load_default_fonts( $value ) {
return false;
}
add_filter( 'coletivo_load_default_fonts', 'brasa2018_coletivo_load_default_fonts', 10, 1 );
/**
* Load site scripts.
*
* @since 2.2.0
*/
function brasa2018_enqueue_scripts() {
$template_url = get_stylesheet_directory_uri();
// Loads Brasa2018 CSS file
wp_enqueue_style( 'brasa2018-sourcesans', 'https://fonts.googleapis.com/css?family=Source+Sans+Pro', array(), null, 'all', true );
wp_enqueue_style( 'brasa2018-css', $template_url . '/brasa2018.css', array(), null, 'all' );
// Loads Brasa2018 JS file
wp_enqueue_script( 'brasa2018-js', $template_url . '/brasa2018.js', array(), null, true );
}
add_action( 'wp_footer', 'brasa2018_enqueue_scripts', 1 );
// Register Custom Post Type
function custom_post_type_depoimentos() {
$labels = array(
'name' => _x( 'Depoimentos', 'Post Type General Name', 'tema-brasa' ),
'singular_name' => _x( 'Depoimento', 'Post Type Singular Name', 'tema-brasa' ),
'menu_name' => __( 'Depoimentos', 'tema-brasa' ),
'parent_item_colon' => __( 'Item parente', 'tema-brasa' ),
'all_items' => __( 'Todos depoimentos', 'tema-brasa' ),
'view_item' => __( 'Ver depoimento', 'tema-brasa' ),
'add_new_item' => __( 'Adicionar novo depoimento', 'tema-brasa' ),
'add_new' => __( 'Adicionar novo', 'tema-brasa' ),
'edit_item' => __( 'Editar item', 'tema-brasa' ),
'update_item' => __( 'Atualizar item', 'tema-brasa' ),
'search_items' => __( 'Buscar depoimentos', 'tema-brasa' ),
'not_found' => __( 'Não en
contrado', 'tema-brasa' ),
'not_found_in_trash' => __( 'Não encontrado na lixeira', 'tema-brasa' ),
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-aside',
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'depoimentos', $args );
}
// Hook into the 'init' action
add_action( 'init', 'custom_post_type_depoimentos', 0 );
/**
* Página de equipe
*/
// Register Custom Post Type
function custom_post_type_equipe() {
$labels = array(
'name' => _x( 'Equipe', 'Post Type General Name', 'tema-brasa' ),
'singular_name' => _x( 'Equipe', 'Post Type Singular Name', 'tema-brasa' ),
'menu_name' => __( 'Equipe', 'tema-brasa' ),
'parent_item_colon' => __( 'Item parente', 'tema-brasa' ),
'all_items' => __( 'Todos membros', 'tema-brasa' ),
'view_item' => __( 'Ver membro', 'tema-brasa' ),
'add_new_item' => __( 'Adicionar novo membro', 'tema-brasa' ),
'add_new' => __( 'Adicionar novo', 'tema-brasa' ),
'edit_item' => __( 'Editar item', 'tema-brasa' ),
'update_item' => __( 'Atualizar item', 'tema-brasa' ),
'search_items' => __( 'Buscar membro', 'tema-brasa' ),
'not_found' => __( 'Não en
contrado', 'tema-brasa' ),
'not_found_in_trash' => __( 'Não encontrado na lixeira', 'tema-brasa' ),
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-groups',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'equipe', $args );
}
// Hook into the 'init' action
add_action( 'init', 'custom_post_type_equipe', 0 );
// if (!function_exists('get_field')) {
// function get_field($field) {
// global $post;
// return get_post_meta($post->ID, $field, true);
// }
// }
// if (!function_exists('the_field')) {
// function the_field($field) {
// global $post;
// echo get_field($field);
// }
// }
// function team_query( $query ) {
// if ( is_post_type_archive('equipe') ) {
// $query->set( 'orderby', 'rand' );
// return;
// }
// }
//add_action( 'pre_get_posts', 'team_query' );
require get_template_directory() . '/inc/class-metabox.php';
$team_metabox = new Odin_Metabox(
'team_metabox', // Slug/ID do Metabox (obrigatório)
'Team', // Nome do Metabox (obrigatório)
'equipe', // Slug do Post Type, sendo possível enviar apenas um valor ou um array com vários (opcional)
'normal', // Contexto (opções: normal, advanced, ou side) (opcional)
'high' // Prioridade (opções: high, core, default ou low) (opcional)
);
$team_metabox->set_fields(
array(
array(
'id' => 'team_position',
'label' => 'Cargo',
'type' => 'text',
'description' => ''
),
array(
'id' => 'team_phone',
'label' => 'Telefone',
'type' => 'text',
'description' => ''
),
array(
'id' => 'team_email',
'label' => 'E-mail',
'type' => 'text',
'description' => ''
),
array(
'id' => 'team_twitter',
'label' => 'Twitter URL',
'type' => 'text',
'description' => ''
),
array(
'id' => 'team_linkedin',
'label' => 'Linkedin URL',
'type' => 'text',
'description' => ''
),
array(
'id' => 'team_github',
'label' => 'Github URL',
'type' => 'text',
'description' => ''
),
array(
'id' => 'team_wporg',
'label' => __('URL da Conta no WordPress.org','tema-brasa'),
'type' => 'text',
'description' => ''
),
)
);
// 1. customize ACF path
// add_filter('acf/settings/path', 'my_acf_settings_path');
function my_acf_settings_path( $path ) {
// update path
$path = get_stylesheet_directory() . '/inc/advanced-custom-fields/';
// return
return $path;
}
// 2. customize ACF dir
// add_filter('acf/settings/dir', 'my_acf_settings_dir');
function my_acf_settings_dir( $dir ) {
// update path
$dir = get_stylesheet_directory_uri() . '/inc/advanced-custom-fields/';
// return
return $dir;
}
// 3. Hide ACF field group menu item
// add_filter('acf/settings/show_admin', '__return_false');
// 4. Include ACF
// include_once( get_stylesheet_directory() . '/inc/advanced-custom-fields/acf.php' );
// 4. Include ACF Fields
include_once( get_stylesheet_directory() . '/inc/acf-fields.php' );
/**
* Change permalink to the old permalink on the old version of the brasa site
* @param string $permalink
* @param object $post
* @param string|null $leavename
* @return string
*/
function redirect_portfolio_to_the_old_site( $permalink, $post, $leavename = null ) {
if ( is_admin() ) {
return $permalink;
}
if ( ! is_object( $post ) || 'jetpack-portfolio' != $post->post_type ) {
return $permalink;
}
if ( $link = get_post_meta( $post->ID, 'portfolio_redirect', true ) ) {
if ( ! empty( $link ) ) {
return $link;
}
}
return $permalink;
}
add_filter( 'post_type_link', 'redirect_portfolio_to_the_old_site', 10, 3 );
/**
* Remove jetpack devicepx script
*/
function brasa_2018_jp_dequeue_devicepx() {
wp_dequeue_script( 'devicepx' );
}
add_action( 'wp_enqueue_scripts', 'brasa_2018_jp_dequeue_devicepx' );
/**
* Prefixo (Brasa Landing Page) brasalp_*
*
* Usar a verificação is_page_template( 'page-express.php' )
*/
function brasalp_footer() {
if ( is_page_template( 'page-landingpage.php' ) ) :
?>
<footer class="footer-main">
<div class="container">
<nav>
<ul>
<li><a href="https://brasa.art.br">Quem Somos</a></li>
<li><a href="https://brasa.art.br/contato">Contato</a></li>
</ul>
</nav>
<div class="credits">
<span>Desenvolvido pela </span><a class="brasa" href="https://brasa.art.br/"></a><span> com </span><a class="wordpress" href="https://brasa.art.br/category/dicas-e-truques-wordpress/">WordPress</a>
</div><!-- /.credits -->
</div><!-- /.container -->
</footer><!-- footer-main -->
<?php
endif;
}
add_action( 'wp_footer', 'brasalp_footer', 100 );