-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
210 lines (182 loc) · 5.93 KB
/
functions.php
File metadata and controls
210 lines (182 loc) · 5.93 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
<?php
/* Functions by Adrien de Bosset */
// Remove Admin Bar
show_admin_bar(false);
// Class for bootstrap menu
require_once('inc/wp_bootstrap_navwalker.php');
// Thumbmail
add_theme_support('post-thumbnails');
add_image_size('archive-miniature', 400, 300, true); //Thumbail for archives
add_image_size('slider-home', 1200, 500, true);
// Custom title for home
add_filter('wp_title', 'wpdocs_hack_wp_title_for_home');
add_action('admin_menu', 'remove_menu_pages');
// Remove menu
function remove_menu_pages()
{
if (!current_user_can('level_10')) {
remove_menu_page('edit.php?post_type=evenement');
remove_menu_page('edit.php');
remove_menu_page('edit-comments.php');
remove_menu_page('tools.php');
remove_menu_page('upload.php');
}
}
// Change User menu
add_action('admin_menu', 'my_change_admin_menu');
function my_change_admin_menu()
{
global $menu;
$menu[70][0] = 'Boutique';
$menu[70][6] = 'dashicons-cart';
}
// Change title home
function wpdocs_hack_wp_title_for_home($title)
{
if (empty($title) && (is_home() || is_front_page())) {
$title = __('Exercice', 'home') . ' | ' . get_bloginfo('Pour la home custome');
}
return $title;
}
add_action('init', 'postType');
// Custom Post type
function postType()
{
/*
register_taxonomy('type','offre', array(
'label' => 'Boutiques',
'labels' => array(
'name' => 'Boutiques',
'singular_name' => 'Boutique',
'all_items' => 'Toutes les boutiques',
'edit_item' => 'Éditer la boutique',
'view_item' => 'Voir la boutique',
'update_item' => 'Mettre à jour la boutique',
'add_new_item' => 'Ajouter une boutique',
'new_item_name' => 'Nouvelle boutique',
'search_items' => 'Rechercher une boutique',
'popular_items' => 'Les boutiques les plus utilisées'),
'hierarchical' => true
) );
*/
/* Post Type Boutique */
/*
register_post_type('boutique', array(
'label' => 'Boutiques',
'labels' => array(
'name' => 'Boutiques',
'singular_name' => 'Boutique',
'all_items' => 'Toutes les boutiques',
'add_new_item' => 'Ajouter une boutique',
'edit_item' => 'Éditer la boutique',
'new_item' => 'Nouvelle boutique',
'view_item' => 'Voir la boutique',
'search_items' => 'Rechercher parmi les boutiques',
'not_found' => 'Pas de boutique trouvée',
'not_found_in_trash' => 'Pas de boutique dans la corbeille'
),
'public' => true,
'capability_type' => 'page',
'supports' => array(
'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields', 'comments', 'author'
),
'has_archive' => true,
'menu_icon' => 'dashicons-cart',
'hierarchical' => true,
)); // End post boutique
/* Post Type Offre */
register_post_type('offre', array(
'label' => 'Offres',
'labels' => array(
'name' => 'Offres',
'singular_name' => 'Offre',
'all_items' => 'Toutes les offres',
'add_new_item' => 'Ajouter une offre',
'edit_item' => 'Éditer l\'offre',
'new_item' => 'Nouvelle offre',
'view_item' => 'Voir l\'offre',
'search_items' => 'Rechercher parmi les offres',
'not_found' => 'Pas d\'offre trouvée',
'not_found_in_trash' => 'Pas d\'offre dans la corbeille'
),
'public' => true,
'capability_type' => 'post',
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail',
'custom-fields',
'comments',
'author'
),
'has_archive' => true,
'menu_icon' => 'dashicons-tickets-alt',
'hierarchical' => true
)); // End post offre
/* Post Type Offre */
register_post_type('evenement', array(
'label' => 'Evénements',
'labels' => array(
'name' => 'Evénements',
'singular_name' => 'Evénement',
'all_items' => 'Toutes les événements',
'add_new_item' => 'Ajouter un événement',
'edit_item' => 'Éditer l\'événement',
'new_item' => 'Nouvel événement',
'view_item' => 'Voir l\'événement',
'search_items' => 'Rechercher parmi les événements',
'not_found' => 'Pas d\'événement trouvée',
'not_found_in_trash' => 'Pas d\'événement dans la corbeille'
),
'public' => true,
'capability_type' => 'post',
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail',
'custom-fields',
'comments',
'author'
),
'has_archive' => true,
'menu_icon' => 'dashicons-megaphone',
'hierarchical' => true
)); // End post offre
}
// Load js for home Menu and slider
function homeMenu()
{
if (is_home()) {
wp_enqueue_script('script-name', get_template_directory_uri() . '/js/home.js', array(), '1.0.0', true);
}
}
add_action('wp_enqueue_scripts', 'homeMenu');
// Disabled post from other user
function mypo_parse_query_useronly($wp_query)
{
if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/edit.php') !== false) {
if (!current_user_can('level_10')) {
global $current_user;
$wp_query->set('author', $current_user->id);
}
}
}
add_filter('parse_query', 'mypo_parse_query_useronly');
// Change author slug name to boutique
add_action('init', 'cng_author_base');
function cng_author_base()
{
global $wp_rewrite;
$author_slug = 'boutique'; // change slug name
$wp_rewrite->author_base = $author_slug;
}
/* Set up Menu */
add_action('after_setup_theme', 'wpt_setup');
if (!function_exists('wpt_setup')):
function wpt_setup()
{
register_nav_menu('primary', __('Primary navigation', 'wptuts'));
}
endif;