-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsingle.php
145 lines (123 loc) · 4.59 KB
/
single.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
<?php
global $post;
//Redirection vers nouveau blog wedogood
$post_category_list = get_the_category($post->ID);
$post_category = $post_category_list[0]->slug;
if ($post_category == "wedogood") {
$post_name = $post->post_name;
$post_date = get_the_date( 'Y/m/d', $post->ID );
$new_url = 'http://blog.wedogood.co/' . $post_date . '/' . $post_name;
wp_redirect($new_url);
exit();
}
//Blocage pour pages qui sont censées êtes sous un parent (et qui se retrouvent mystérieusement avec le template "single")
if ( $post->post_type == 'page' && $post->post_parent ) {
global $wp_query;
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 ); exit();
}
//Blocage pour actualités de projets pas encore publiés
global $campaign_id, $is_campaign, $is_campaign_page;
$this_category = get_the_category();
$this_category = $this_category[0];
$this_category_name = $this_category->name;
$name_exploded = explode('cat', $this_category_name);
if (count($name_exploded) > 1) {
$campaign_id = $name_exploded[1];
}
if (isset($campaign_id)) {
$is_campaign = true;
$is_campaign_page = true;
$campaign_post = get_post($campaign_id);
$campaign = atcf_get_campaign($campaign_post);
if ( ($campaign->campaign_status() == ATCF_Campaign::$campaign_status_preparing || $campaign->campaign_status() == ATCF_Campaign::$campaign_status_validated) && !$campaign->current_user_can_edit()) {
wp_redirect(home_url());
}
}
?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
// Articles du blog WDG
$category = get_the_category();
if ($category[0]->slug == 'wedogood' || $category[0]->slug == 'revue-de-presse') :
$page_blog = ($category[0]->slug == 'wedogood') ? get_page_by_path('blog') : get_page_by_path('espace-presse');
?>
<div id="content">
<div class="padder">
<?php
$page_title = ($category[0]->slug == 'wedogood') ? "Actualités" : "Espace presse";
// locate_template( array( 'common/basic-header.php' ), true );
?>
<div id="post_bottom_bg">
<div id="post_bottom_content" class="center">
<div class="left two-thirds" style="margin-left: 175px;">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-content">
<div><br /><< <a href="<?php echo get_permalink($page_blog->ID); ?>"><?php _e($page_title, 'yproject'); ?></a></div>
<h2 class="posttitle"><?php the_title(); ?></h2>
<p class="date"><?php echo get_the_date(); ?></p>
<?php the_content(); ?>
<?php if ($category[0]->slug == 'wedogood') comments_template(); ?>
</div>
</div>
</div>
</div>
<div style="clear: both"></div>
</div>
</div><!-- .padder -->
</div><!-- #content -->
<?php
//Autres articles
else:
?>
<?php
global $campaign_id, $post;
date_default_timezone_set("Europe/Paris");
$this_category = get_the_category();
$this_category = $this_category[0];
$this_category_name = $this_category->name;
$name_exploded = explode('cat', $this_category_name);
if (count($name_exploded) > 1) {
$campaign_id = $name_exploded[1];
}
if (isset($campaign_id)) {
$campaign_post = get_post($campaign_id);
$campaign = atcf_get_campaign($campaign_post);
}
$edit_version = $campaign->edit_version();
$classes = 'version-' . $edit_version;
$post = $campaign_post;
?>
<div id="content" style="margin-top: -15px;" class="<?php echo $classes; ?>">
<div class="padder">
<div class="page" id="blog-archives" role="main">
<?php locate_template( array("projects/single/banner.php"), true ); ?>
<div id="post_bottom_bg">
<div id="post_bottom_content" class="center margin-height">
<?php $postlist_link = get_permalink($campaign->ID); ?>
<a href="<?php echo esc_url($postlist_link); ?>"><< Revenir à la page du projet</a>
<?php wp_reset_query(); ?>
<div class="post-content">
<h2 class="posttitle"><?php the_title(); ?></h2>
<p class="date"><?php echo get_the_date(); ?></p>
<?php the_content(); ?>
<?php comments_template(); ?>
</div>
</div>
</div>
</div>
</div><!-- .padder -->
</div><!-- #content -->
<?php
endif;
?>
<?php endwhile; else: ?>
<div id="content">
<div class="padder center">
<p><?php _e( 'Désolé, aucun article correspondant.', 'yproject' ); ?></p>
</div><!-- .padder -->
</div><!-- #content -->
<?php endif; ?>
<?php get_footer(); ?>