forked from pensandoodireito/dadospessoais-tema
-
Notifications
You must be signed in to change notification settings - Fork 1
/
single-texto-em-debate.php
43 lines (35 loc) · 1.41 KB
/
single-texto-em-debate.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
<?php
get_header();
// Verificação de segurança se o nonce foi postado e se é correto
if ( isset($_POST['file_nonce']) ) {
if (wp_verify_nonce($_POST['file_nonce'],'pdf-upload') && isset($_FILES['pdf_contribution'])) {
$pdf_contribution_list = get_post_meta(get_the_ID(), 'pdf_contribution_list', true);
$upload_dir = wp_upload_dir();
$file_name = md5($_FILES['pdf_contribution']['name'].$_FILES['pdf_contribution']['size']) . '.pdf';
if ( !file_exists( $upload_dir['path'] . '/' . $file_name ) ) {
move_uploaded_file($_FILES['pdf_contribution']['tmp_name'], $upload_dir['path'] . '/' . $file_name);
$current_user = wp_get_current_user();
$pdf_contribution_list[] = array( 'author' => $current_user->display_name,
'pdf_url' => $upload_dir['url'] . '/' . $file_name,
'email' => $current_user->user_email );
update_post_meta(get_the_ID(), 'pdf_contribution_list', $pdf_contribution_list);
}
}
}
?>
<div class="container">
<div class="row">
<div class="col-xs-12">
<?php get_template_part("menu", "horizontal"); ?>
</div>
</div>
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'content', 'texto-em-debate' );
endwhile;
?>
</div>
<?php
get_footer();