-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
383 lines (326 loc) · 16.2 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_theme_support( 'post-thumbnails' );
// Register Custom Post Type
function cpt_patrimoine() {
$labels = array(
'name' => _x( 'Patrimoines', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Patrimoine', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Le patrimoine', 'text_domain' ),
'name_admin_bar' => __( 'Le patrimoine', 'text_domain' ),
'archives' => __( 'Archives', 'text_domain' ),
'parent_item_colon' => __( 'Parent :', 'text_domain' ),
'all_items' => __( 'Tout le patrimoine', 'text_domain' ),
'add_new_item' => __( 'Ajouter un élément au patrimoine', 'text_domain' ),
'add_new' => __( 'Ajouter', 'text_domain' ),
'new_item' => __( 'Nouvel élément', 'text_domain' ),
'edit_item' => __( 'Modifier', 'text_domain' ),
'update_item' => __( 'Mettre à jour', 'text_domain' ),
'view_item' => __( 'Voir un élément', 'text_domain' ),
'search_items' => __( 'Rechercher', 'text_domain' ),
'not_found' => __( 'Aucune élément trouvé', 'text_domain' ),
'not_found_in_trash' => __( 'Aucune élément trouvé dans la corbeille', 'text_domain' ),
'featured_image' => __( 'Image à la une', 'text_domain' ),
'set_featured_image' => __( 'Mettre l\'image à la une', 'text_domain' ),
'remove_featured_image' => __( 'Effacer l\'image à la une', 'text_domain' ),
'use_featured_image' => __( 'Utiliser l\'image à la une', 'text_domain' ),
'insert_into_item' => __( 'Insérer', 'text_domain' ),
'uploaded_to_this_item' => __( 'Ajouter à cet élément', 'text_domain' ),
'items_list' => __( 'Liste des éléments du patrimoine', 'text_domain' ),
'items_list_navigation' => __( 'Navigation', 'text_domain' ),
'filter_items_list' => __( 'Filtre de la liste des éléments du patrimoine', 'text_domain' ),
);
$args = array(
'label' => __( 'Patrimoine', 'text_domain' ),
'description' => __( 'Le patrimoine', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'page-attributes', ),
'taxonomies' => array('post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-multisite',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'archive-patrimoine',
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'rewrite' => array('slug' => 'patrimoine'),
);
register_post_type( 'post_type_patrimoine', $args );
}
add_action( 'init', 'cpt_patrimoine', 0 );
if ( ! function_exists( 'patrimoine_taxonomy' ) ) {
// Register Custom Taxonomy
function patrimoine_taxonomy() {
$labels = array(
'name' => _x( 'Patrimoine-categories', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Patrimoine-categorie', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Catégories du patrimoine', 'text_domain' ),
'all_items' => __( 'Toutes les catégories', 'text_domain' ),
'parent_item' => __( 'Parent', 'text_domain' ),
'parent_item_colon' => __( 'Parent :', 'text_domain' ),
'new_item_name' => __( 'Nouvelle catégorie', 'text_domain' ),
'add_new_item' => __( 'Ajouter une catégorie', 'text_domain' ),
'edit_item' => __( 'Modifier une catégorie', 'text_domain' ),
'update_item' => __( 'Mettre à jour', 'text_domain' ),
'view_item' => __( 'Voir la catégorie', 'text_domain' ),
'separate_items_with_commas' => __( 'Séparer les catégories par des virgules', 'text_domain' ),
'add_or_remove_items' => __( 'Ajouter ou supprimer la catégorie', 'text_domain' ),
'choose_from_most_used' => __( 'Choisir par les plus utilisées', 'text_domain' ),
'popular_items' => __( 'Plus populaires', 'text_domain' ),
'search_items' => __( 'Rechercher une catégorie', 'text_domain' ),
'not_found' => __( 'Aucune catégorie trouvée', 'text_domain' ),
'no_terms' => __( 'Aucune catégorie', 'text_domain' ),
'items_list' => __( 'Liste des catégories', 'text_domain' ),
'items_list_navigation' => __( 'Navigation', 'text_domain' ),
);
$rewrite = array(
'slug' => 'categorie-du-patrimoine',
'with_front' => true,
'hierarchical' => true,
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => $rewrite,
);
register_taxonomy( 'patrimoine_category', array( 'post_type_patrimoine' ), $args );
}
add_action( 'init', 'patrimoine_taxonomy', 0 );
}
if ( ! function_exists('custom_post_realisation') ) {
// Register Custom Post Type
function custom_post_realisation() {
$labels = array(
'name' => _x( 'Realisations', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Realisation', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Réalisations', 'text_domain' ),
'name_admin_bar' => __( 'Réalisations', 'text_domain' ),
'archives' => __( 'Archives', 'text_domain' ),
'parent_item_colon' => __( 'Parent:', 'text_domain' ),
'all_items' => __( 'Toutes les réalisations', 'text_domain' ),
'add_new_item' => __( 'Ajouter une réalisation', 'text_domain' ),
'add_new' => __( 'Ajouter', 'text_domain' ),
'new_item' => __( 'Nouvelle réalisation', 'text_domain' ),
'edit_item' => __( 'Modifier', 'text_domain' ),
'update_item' => __( 'Mettre à jour', 'text_domain' ),
'view_item' => __( 'Voir la réalisation', 'text_domain' ),
'search_items' => __( 'Rechercher', 'text_domain' ),
'not_found' => __( 'Aucune réalisation trouvée', 'text_domain' ),
'not_found_in_trash' => __( 'Aucune réalisation trouvée dans la corbeille', 'text_domain' ),
'featured_image' => __( 'Image à la une', 'text_domain' ),
'set_featured_image' => __( 'Mettre l\'image à la une', 'text_domain' ),
'remove_featured_image' => __( 'Supprimer l\'image à la une', 'text_domain' ),
'use_featured_image' => __( 'Utiliser l\'image à la une', 'text_domain' ),
'insert_into_item' => __( 'Insérer', 'text_domain' ),
'uploaded_to_this_item' => __( 'Ajouter à la réalisation', 'text_domain' ),
'items_list' => __( 'Liste des réalisations', 'text_domain' ),
'items_list_navigation' => __( 'Navigation', 'text_domain' ),
'filter_items_list' => __( 'Filter les réalisations', 'text_domain' ),
);
$args = array(
'label' => __( 'Realisation', 'text_domain' ),
'description' => __( 'Les réalisations', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'page-attributes', ),
'taxonomies' => array('post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-tools',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'archive-realisation',
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'rewrite' => array('slug' => 'realisation'),
);
register_post_type( 'post_type_realisatio', $args );
}
add_action( 'init', 'custom_post_realisation', 0 );
}
// Register Custom Taxonomy
function realisation_taxonomy() {
$labels = array(
'name' => _x( 'Realisation-categories', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Realisation-categorie', 'Taxonomy Singular Name', 'text_domain' ),
'menu_name' => __( 'Catégories des réalisations', 'text_domain' ),
'all_items' => __( 'Toutes les catégories', 'text_domain' ),
'parent_item' => __( 'Parent', 'text_domain' ),
'parent_item_colon' => __( 'Parent :', 'text_domain' ),
'new_item_name' => __( 'Nouvelle catégorie', 'text_domain' ),
'add_new_item' => __( 'Ajouter une catégorie', 'text_domain' ),
'edit_item' => __( 'Modifier une catégorie', 'text_domain' ),
'update_item' => __( 'Mettre à jour', 'text_domain' ),
'view_item' => __( 'Voir la catégorie', 'text_domain' ),
'separate_items_with_commas' => __( 'Séparer les catégories par des virgules', 'text_domain' ),
'add_or_remove_items' => __( 'Ajouter ou supprimer la catégorie', 'text_domain' ),
'choose_from_most_used' => __( 'Choisir par les plus utilisées', 'text_domain' ),
'popular_items' => __( 'Plus populaires', 'text_domain' ),
'search_items' => __( 'Rechercher une catégorie', 'text_domain' ),
'not_found' => __( 'Aucune catégorie trouvée', 'text_domain' ),
'no_terms' => __( 'Aucune catégorie', 'text_domain' ),
'items_list' => __( 'Liste des catégories', 'text_domain' ),
'items_list_navigation' => __( 'Navigation', 'text_domain' ),
);
$rewrite = array(
'slug' => 'categorie-des-realisations',
'with_front' => true,
'hierarchical' => true,
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => $rewrite,
);
register_taxonomy( 'realisation_category', array( 'post_type_realisatio' ), $args );
}
add_action( 'init', 'realisation_taxonomy', 0 );
function cpt_path() {
$labels = array(
'name' => _x( 'Parcours', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Parcours', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Parcours interactif', 'text_domain' ),
'name_admin_bar' => __( 'Parcours interactif', 'text_domain' ),
'archives' => __( 'Archives', 'text_domain' ),
'parent_item_colon' => __( 'Parent :', 'text_domain' ),
'all_items' => __( 'Tous les parcours', 'text_domain' ),
'add_new_item' => __( 'Ajouter un parcours', 'text_domain' ),
'add_new' => __( 'Ajouter', 'text_domain' ),
'new_item' => __( 'Nouvel élément', 'text_domain' ),
'edit_item' => __( 'Modifier', 'text_domain' ),
'update_item' => __( 'Mettre à jour', 'text_domain' ),
'view_item' => __( 'Voir un élément', 'text_domain' ),
'search_items' => __( 'Rechercher', 'text_domain' ),
'not_found' => __( 'Aucune élément trouvé', 'text_domain' ),
'not_found_in_trash' => __( 'Aucune élément trouvé dans la corbeille', 'text_domain' ),
'featured_image' => __( 'Image à la une', 'text_domain' ),
'set_featured_image' => __( 'Mettre l\'image à la une', 'text_domain' ),
'remove_featured_image' => __( 'Effacer l\'image à la une', 'text_domain' ),
'use_featured_image' => __( 'Utiliser l\'image à la une', 'text_domain' ),
'insert_into_item' => __( 'Insérer', 'text_domain' ),
'uploaded_to_this_item' => __( 'Ajouter à cet élément', 'text_domain' ),
'items_list' => __( 'Liste des parcours', 'text_domain' ),
'items_list_navigation' => __( 'Navigation', 'text_domain' ),
'filter_items_list' => __( 'Filtre de la liste des éléments', 'text_domain' ),
);
$args = array(
'label' => __( 'Parcours', 'text_domain' ),
'description' => __( 'Les parcours interactif', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-location',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'archive-parcours',
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'rewrite' => array('slug' => 'parcours'),
);
register_post_type( 'post_type_path', $args );
}
add_action( 'init', 'cpt_path', 0 );
function test(){
wp_enqueue_script ( "lightboxVideo", get_stylesheet_directory_uri()."/lightbox/videoLightbox.js", array("jquery"));
}
add_action( 'wp_enqueue_scripts', 'test' );
function add_script() {
wp_register_script ( 'script-jf', get_stylesheet_directory_uri().'/js/script.js', array('jquery'));
wp_enqueue_script ( 'script-jf');
$pluginDir = get_stylesheet_directory_uri();
wp_localize_script( 'script-jf', 'pluginDir', $pluginDir );
wp_localize_script('script-jf', 'ajaxurl', admin_url( 'admin-ajax.php' ) );
}
add_action('wp_enqueue_scripts', 'add_script');
add_action( 'wp_ajax_listing_ajax_action', 'listing_ajax_action' );
add_action( 'wp_ajax_nopriv_listing_ajax_action', 'listing_ajax_action' );
function listing_ajax_action() {
$param = $_POST['cat_id'];
$query = new WP_Query( array(
'post_type' => array('post_type_realisatio','post_type_patrimoine'),
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'realisation_category',
'field' => 'term_id',
'terms' => $param,
),
array(
'taxonomy' => 'patrimoine_category',
'field' => 'term_id',
'terms' => $param,
)
)
) );
if('post_type_realisatio') {
$taxname = get_term_by('id', $param, 'realisation_category');
}
if('post_type_patrimoine') {
$taxname = get_term_by('id', $param, 'patrimoine_category');
}
$c = '<div id="ficheInfo" class="blockInfo">
<h3>'. $taxname->name .'</h3>
<p>'. category_description($param) . '</p>
</div>';
$c .= '<div id="contenuRecherche">';
$c .= '<div id="accordion">';
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
$daterel = '';
if( get_field('date_de_la_realisation') ):
$daterel = get_field("date_de_la_realisation");
$daterel .= ' - ';
endif;
$c .= '<div id="dropDownSelect">
<div id="laFleche"><i class="fa fa-chevron-down"><h1>'. $daterel .' '. get_the_title() . '</h1></i></div>
</div>
<article class="listing-post-single">
<div id="txtContenu">
<div class="linkContent">
<p>' . get_the_excerpt() . '</p>
</div>
<a class="batman" href="'. get_the_permalink() . '">Continuer la lecture</a>
</div>
<div id="imgContenu">
'. get_the_post_thumbnail($sizes) . '
</div>
<div id="division"></div>
</article>';
endwhile;
$c .= '</div>';
else :
$c .= '<article class="listing-post-single"><div id="txtContenu">' . 'Aucun élément trouvé' . '</div></article>';
endif;
$c .= '</div>';
echo $c;
die();
}