-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
328 lines (298 loc) · 12.3 KB
/
Copy pathfunctions.php
File metadata and controls
328 lines (298 loc) · 12.3 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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<?php
// Funções para Limpar o Header
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'start_post_rel_link', 10, 0 );
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
// Função para desabilitar o editor de blocos
add_filter('use_block_editor_for_post', '__return_false', 10);
//Função para alterar o CSS da página logim
function my_custom_login_stylesheet() {
wp_enqueue_style( 'custom-login', get_stylesheet_directory_uri() . '/style.css' );
}
add_action( 'login_enqueue_scripts', 'my_custom_login_stylesheet' );
/*Função que altera a URL, trocando pelo endereço do seu site*/
function my_login_logo_url() {
return get_bloginfo( 'url' );
}
add_filter( 'login_headerurl', 'my_login_logo_url' );
/*Função que adiciona o nome do seu site, no momento que o mouse passa por cima da logo*/
function my_login_logo_url_title() {
return 'GoClasses - Voltar para Home';
}
add_filter( 'login_headertitle', 'my_login_logo_url_title' );
// Registrando novos post-types
function goclasses_post_types() {
register_post_type('materia', array(
'capability_type' => 'materia',
'map_meta_cap' => true,
'supports' => array('title'),
'rewrite' => array('slug' => 'materias'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Matérias',
'add_new_item' => 'Adicionar Nova Matéria',
'edit_item' => 'Editar Matéria',
'all_items' => 'Todas Matérias',
'singular_name' => 'Matéria'
),
'menu_icon' => 'dashicons-edit-page'
));
register_post_type('material_de_apoio', array(
'capability_type' => 'material_de_apoio',
'map_meta_cap' => true,
'supports' => array('title'),
'rewrite' => array('slug' => 'material_de_apoio'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Materiais de Apoio',
'add_new_item' => 'Adicionar Novo Material de Apoio',
'edit_item' => 'Editar Material de Apoio',
'all_items' => 'Todos Materiais de Apoio',
'singular_name' => 'Material de Apoio'
),
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-text-page'
));
register_post_type('video_aula', array(
'capability_type' => 'video_aula',
'map_meta_cap' => true,
'supports' => array('title', 'excerpt'),
'rewrite' => array('slug' => 'video_aula'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Vídeo Aulas',
'add_new_item' => 'Adicionar Nova Vídeo Aula',
'edit_item' => 'Editar Vídeo Aula',
'all_items' => 'Todas Vídeo Aulas',
'singular_name' => 'Vídeo Aula'
),
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-video-alt3'
));
register_post_type('material', array(
'capability_type' => 'material',
'map_meta_cap' => true,
'supports' => array('title', 'editor'),
'rewrite' => array('slug' => 'materiais_didaticos'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Materiais Didáticos',
'add_new_item' => 'Adicionar Novo Material',
'edit_item' => 'Editar Material',
'all_items' => 'Todos Materiais',
'singular_name' => 'Material'
),
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-book-alt'
));
register_post_type('exercicio', array(
'capability_type' => 'exercicio',
'map_meta_cap' => true,
'supports' => array('title'),
'rewrite' => array('slug' => 'exercicios'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Exercícios',
'add_new_item' => 'Adicionar Novo Exercício',
'edit_item' => 'Editar Exercício',
'all_items' => 'Todos Exercícios',
'singular_name' => 'Exercício'
),
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-list-view'
));
register_post_type('projeto', array(
'capability_type' => 'projeto',
'map_meta_cap' => true,
'supports' => array('title'),
'rewrite' => array('slug' => 'projetos'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Projetos',
'add_new_item' => 'Adicionar Novo Projeto',
'edit_item' => 'Editar Projeto',
'all_items' => 'Todos Projetos',
'singular_name' => 'Projeto'
),
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-portfolio'
));
register_post_type('projeto_giani', array(
'capability_type' => 'projeto_giani',
'map_meta_cap' => true,
'supports' => array('title', 'editor'),
'rewrite' => array('slug' => 'projetos_giani'),
'has_archive' => false,
'public' => true,
'labels' => array(
'name' => 'Projetos da Giani',
'add_new_item' => 'Adicionar Novo Projeto da Giani',
'edit_item' => 'Editar Projeto da Giani',
'all_items' => 'Todos Projetos da Giani',
'singular_name' => 'Projeto da Giani'
),
'menu_icon' => 'dashicons-welcome-learn-more'
));
register_post_type('aluno_destaque', array(
'capability_type' => 'aluno_destaque',
'map_meta_cap' => true,
'supports' => array('title', 'editor'),
'rewrite' => array('slug' => 'alunos_destaque'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Alunos Destaques',
'add_new_item' => 'Adicionar Novo Aluno Destaque',
'edit_item' => 'Editar Aluno Destaque',
'all_items' => 'Todos Alunos Destaque',
'singular_name' => 'Aluno Destaque'
),
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-groups'
));
}
add_action('init', 'goclasses_post_types');
// Removendo prefixo dos títulos do archive
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
} elseif ( is_tax() ) { //for custom post types
$title = sprintf( __( '%1$s' ), single_term_title( '', false ) );
} elseif (is_post_type_archive()) {
$title = post_type_archive_title( '', false );
}
return $title;
});
// Use GD instead of Imagick.
function cb_child_use_gd_editor($array) {
return array( 'WP_Image_Editor_GD' );
}
add_filter( 'wp_image_editors', 'cb_child_use_gd_editor' );
// Adiconando os arquivos CSS
function goclasses_css(){
// Folhas de estilo principais
wp_enqueue_style('goclasses-normalize', get_template_directory_uri() . '/css/normalize.css');
wp_enqueue_style('goclasses-reset', get_template_directory_uri() . '/css/reset.css');
wp_enqueue_style('goclasses-grid', get_template_directory_uri() . '/css/grid.css');
wp_enqueue_style('goclasses-style', get_template_directory_uri() . '/style.css');
wp_enqueue_style('goclasses-inicio', get_template_directory_uri() . '/css/inicio.css');
wp_enqueue_style('goclasses-quemsomos', get_template_directory_uri() . '/css/quemsomos.css');
wp_enqueue_style('goclasses-projetos', get_template_directory_uri() . '/css/projetos.css');
wp_enqueue_style('goclasses-material', get_template_directory_uri() . '/css/material.css');
wp_enqueue_style('goclasses-contato', get_template_directory_uri() . '/css/contato.css');
wp_enqueue_style('goclasses-index', get_template_directory_uri() . '/css/index.css');
wp_enqueue_style('goclasses-archive', get_template_directory_uri() . '/css/archive.css');
wp_enqueue_style('goclasses-single', get_template_directory_uri() . '/css/single.css');
wp_enqueue_style('goclasses-author', get_template_directory_uri() . '/css/author.css');
wp_enqueue_style('goclasses-giani', get_template_directory_uri() . '/css/giani.css');
wp_enqueue_style('goclasses-search', get_template_directory_uri() . '/css/search.css');
// Folha de estilo Font Awesome para ícones
wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css');
}
add_action('wp_enqueue_scripts', 'goclasses_css');
// Desabilitar a barra de usuário para todos os usuários, inclusive usuários admin.
show_admin_bar(false);
/**
* Redirecionar usuário para o site após login bem sucedido.
* Desenvolvido por Sergio Ronei - https://altosite.com.br
**/
function my_login_redirect( $redirect_to, $request, $user ) {
//o trecho abaixo verifica se existe algum usuário a ser checado
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//checa se o usuário é admin. Se positivo, leva o admin para o painel de administração.
if ( in_array( 'administrator', $user->roles ) ) {
//se for qualquer outro tipo de usuário, leva para a home do site.
return home_url();
} else {
return home_url();
}
} else {
return home_url();
}
}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
//Removendo itens do WP
function remove_wp_items( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'wp-logo' );
$wp_admin_bar->remove_node( 'comments' );
}
add_action( 'admin_bar_menu', 'remove_wp_items', 999 );
function remove_menu_items(){
$user = wp_get_current_user();
$allowed_roles = array('administrator', 'editor');
if( !array_intersect($allowed_roles, $user->roles ) ) {
remove_menu_page( 'index.php' );
}
}
add_action( 'admin_menu', 'remove_menu_items', 999 );
// Adicionando Nome E Sobrenome em signup
add_action( 'register_form', 'myplugin_register_form' );
function myplugin_register_form() {
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : '';
?>
<p>
<label for="first_name"><?php _e( 'Nome', 'mydomain' ) ?><br />
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" /></label>
</p>
<p>
<label for="last_name"><?php _e( 'Sobrenome', 'mydomain' ) ?><br />
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr( wp_unslash( $last_name ) ); ?>" size="25" /></label>
</p>
<?php
}
//2. Add validation. In this case, we make sure first_name is required.
add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );
function myplugin_registration_errors( $errors, $sanitized_user_login, $user_email ) {
if ( empty( $_POST['first_name'] ) || ! empty( $_POST['first_name'] ) && trim( $_POST['first_name'] ) == '' ) {
$errors->add( 'first_name_error', __( '<strong>Erro</strong>: Deve incluir um Nome.', 'mydomain' ) );
}
if ( empty( $_POST['last_name'] ) || ! empty( $_POST['last_name'] ) && trim( $_POST['first_name'] ) == '' ) {
$errors->add( 'last_name_error', __( '<strong>Erro</strong>: Deve incluir um Sobrenome.', 'mydomain' ) );
}
return $errors;
}
//3. Finally, save our extra registration user meta.
add_action( 'user_register', 'myplugin_user_register' );
function myplugin_user_register( $user_id ) {
if ( ! empty( $_POST['first_name'] ) ) {
update_user_meta( $user_id, 'first_name', trim( $_POST['first_name'] ) );
update_user_meta( $user_id, 'last_name', trim( $_POST['last_name'] ) );
}
}
//Registro apenas para email da utfpr
function is_valid_email_domain($login, $email, $errors ){
$valid_email_domains = array("alunos.utfpr.edu.br","utfpr.edu.br");// whitelist email domain lists
$valid = false;
foreach( $valid_email_domains as $d ){
$d_length = strlen( $d );
$current_email_domain = strtolower( substr( $email, -($d_length), $d_length));
if( $current_email_domain == strtolower($d) ){
$valid = true;
break;
}
}
// if invalid, return error message
if( $valid === false ){
$errors->add('domain_whitelist_error',__( '<strong>Erro</strong>: Apenas registro para email educacional da UTFPR' ));
}
}
add_action('register_post', 'is_valid_email_domain',10,3 );