-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
335 lines (264 loc) · 10.5 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
<?php
/*
* =====================================================
*
* functions.php
*
* The Theme's Functions
*
* =====================================================
*/
/* ------------------------------------------------------
*
* 1 - CONSTANTS
*
* ------------------------------------------------------
*/
// A constant for the path of the theme root
define('THEME_ROOT', get_stylesheet_directory_uri());
// A constant for the path of the theme default images folder
define('IMAGES', THEME_ROOT . '/images');
// A constant for the path of thee theme default css folder
define('CSS', THEME_ROOT . '/css');
// A constant for the path of the theme default Javascript folder
define('JS', THEME_ROOT . '/assets/js');
/* ------------------------------------------------------
*
* 2 - THEME SETUP
*
* ------------------------------------------------------
*/
if (!function_exists('aftv_theme_setup')) {
function aftv_theme_setup() {
// Make the theme available for translation
$lang_dir = THEME_ROOT . '/languages';
load_textdomain('afrique-television', $lang_dir);
// Enable support for Post Formats
$aftv_supported_format = array(
'image',
'video',
'gallery',
'audio',
);
add_theme_support('post-formats', $aftv_supported_format);
// Add theme support for post thubnails
add_theme_support('post-thumbnails');
//Add Custom Background support
$defaults = array(
'default-image' => '',
'default-preset' => 'default',
'default-position-x' => 'left',
'default-position-y' => 'top',
'default-size' => 'auto',
'default-repeat' => 'repeat',
'default-attachment' => 'scroll',
'default-color' => '',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
add_theme_support('custom-background', $defaults);
/*
* Let Wordpress Generate of the website
* https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/
*/
add_theme_support( 'title-tag' );
// Register Navigation Menus
register_nav_menus(array(
'aftv-header-menu' => __('Menu principal', 'afrique-television'),
'aftv-drawer-menu' => __('Menu latteral', 'afrique-television'),
'aftv-legacy-menu' => __('Menu de Copyright', 'afrique-television')
));
// Add feed links support
add_theme_support( 'automatic-feed-links' );
}
//Load Aftv theme setup after Wordpress theme setup
add_action('after_setup_theme', 'aftv_theme_setup');
}
if (!function_exists('aftv_custom_logo_setup')) {
// Add custom logo support
function aftv_custom_logo_setup() {
$parameters = array(
'height' => 41,
'width' => 197,
'flex-height' => true,
'flex-width' => true,
'header-text' => array('site-title'),
);
add_theme_support('custom-logo', $parameters);
}
add_action('after_setup_theme', 'aftv_custom_logo_setup');
}
/* ------------------------------------------------------
*
* 4 - LOAD AFTV SCRIPTS
*
* ------------------------------------------------------
*/
if (!function_exists('aftv_scripts')) {
function aftv_scripts() {
// Load Material Design Lite STYLESHEET
wp_enqueue_style('MDL_STYLE', 'https://code.getmdl.io/1.3.0/material.red-orange.min.css');
// Load Material Design Lite Fonts
wp_enqueue_style('MDL_FONTS', 'http://fonts.googleapis.com/css?family=Roboto:300,400,500,700');
//Load Material design Icons
wp_enqueue_style('MDL_ICONS', 'https://fonts.googleapis.com/icon?family=Material+Icons');
// Load the theme styleSheet
wp_enqueue_style('MAIN_STYLE', get_stylesheet_uri());
//Load Material Design Lite Javascript
wp_enqueue_script('MDL_JS', 'https://code.getmdl.io/1.3.0/material.min.js', array(), 1.0, TRUE);
// Load The Tv player JS
wp_enqueue_script('WEB-TV_JS', JS . '/aftv-web-tv.js', array(), 1.0, TRUE);
}
}
add_action('wp_enqueue_scripts', 'aftv_scripts');
/* ------------------------------------------------------
*
* 5 - AFTV SIDEBARS
*
* ------------------------------------------------------
*/
function aftv_widgets_config() {
register_sidebar(array(
'name' => __('Sidebar de Pub','afrique-television'),
'id' => 'sidebar-1',
'description' => __('Sidebar pour afficher des pub normalement sur le front-page','afrique-television'),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => ''
));
register_sidebar(array(
'name' => __('Footer Sidebar 1','afrique-television'),
'id' => 'sidebar-2',
'description' => __('Sidebar numero 1 pour le pied de page','afrique-television'),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h1 class="mdl-mega-footer__heading">',
'after_title' => '</h1>'
));
register_sidebar(array(
'name' => __('Footer Sidebar 2','afrique-television'),
'id' => 'sidebar-3',
'description' => __('Sidebar numero 2 pour le pied de page','afrique-television'),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h1 class="mdl-mega-footer__heading">',
'after_title' => '</h1>'
));
register_sidebar(array(
'name' => __('Footer Sidebar 3','afrique-television'),
'id' => 'sidebar-4',
'description' => __('Sidebar numero 3 pour le pied de page','afrique-television'),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h1 class="mdl-mega-footer__heading">',
'after_title' => '</h1>'
));
register_sidebar(array(
'name' => __('Footer Sidebar 4','afrique-television'),
'id' => 'sidebar-5',
'description' => __('Sidebar numero 4 pour le pied de page','afrique-television'),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h1 class="mdl-mega-footer__heading">',
'after_title' => '</h1>'
));
register_sidebar(array(
'name' => __('Pages Sidebar','afrique-television'),
'id' => 'sidebar-6',
'description' => __('Sidebar pour les differentes pages','afrique-television'),
'before_widget' => '<div id="%1$s" class="aftv-widget__container %2$s" >',
'after_widget' => '</div>',
'before_title' => '<h1 class="aftv-cat-page__sidebar-title mdl-card__title-text">',
'after_title' => '</h1>'
));
register_sidebar( array(
'name' => __('Date based archive Sidebar','afrique-television'),
'id' => 'sidebar-7',
'description' => __('Sidebar pour les archives basées sur les dates','afrique-television'),
'before_widget' => '<div id="%1$s" class="aftv-widget__container %2$s" >',
'after_widget' => '</div>',
'before_title' => '<h1 class="aftv-cat-page__sidebar-title mdl-card__title-text">',
'after_title' => '</h1>'
));
// Full page content Ad Sidebar
register_sidebar(array(
'name' => __('Full Page width Ad','afrique-television'),
'id' => 'sidebar-8',
'description' =>__('Put an Ad in this sidebar to make it fits the content of the page','afrique-television'),
'before_widget' => '<div class="mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">',
'after_widget' => '</div>',
'before_title' => '',
'after_title' => ''
));
// Third width content Ad Sidebar
register_sidebar(array(
'name' => __('Third Width content Ad','afrique-television'),
'id' => 'sidebar-9',
'description' => __('Put An Ad in this sidebar to make it fits the third part of the width of the page','afrique-television'),
'before_widget' => '<div class="mdl-cell mdl-cell--8-col mdl-cell--8-tablet mdl-cell--4-phone">',
'after_widget' => '</div>',
'before_title' => '',
'after_title' => ''
));
// Quarter Width content Sidebar
register_sidebar(array(
'name' => __('Quarter width content Ad Sidebar','afrique-television'),
'id' => 'sidebar-10',
'description' => __('Put An Ad in this sidebar to make it fits the Quarter part of the width of the page','afrique-television'),
'before_widget' => '<div class="mdl-cell mdl-cell--4-col mdl-cell--8-col mdl-cell--4-phone">',
'after_widget' => '</div>',
'before_title' => '',
'after_title' => ''
));
}
add_action('widgets_init', 'aftv_widgets_config');
/* ------------------------------------------------------
*
* 6 - SHORTCODE FOR CATEGORIES CONTENT DISPLAY IN PAGES
*
* ------------------------------------------------------
*/
//Include the category page function handler file
/*require_once get_template_directory().'/inc/aftv-cat-page-template.php';
function aftv_display_pageof_category($atts){
$category = (int)$atts['id'];
return aftv_show_catpage($category);
}
add_shortcode('tstsho', 'aftv_display_pageof_category');
*/
/* ------------------------------------------------------
*
* 7 - UTILTIES
*
* ------------------------------------------------------
*/
// Add a class to my Menu links.
/*
* if (!function_exists('aftv_add_menu_link_class')) {
$navClass = "mdl-navigation";
function aftv_add_menu_link_class($navClass) {
return preg_replace('/<a/', '<a class="mdl-navigation__link"', $navClass);
}
add_filter('wp_nav_menu', 'aftv_add_menu_link_class');
}
*/
// Display posts Captions
if (!function_exists('aftv_post_thumbnail_caption')) {
function aftv_post_thumbnail_caption() {
echo get_post(get_post_thumbnail_id())->post_excerpt;
}
}
// Enable Shortcodes In Wordpress Text Widgets
add_filter('widget_text','do_shortcode');
// Include AFTV navigation menus walker
require_once(get_template_directory() . '/inc/aftv-menu-walker.php');
// Include Our custom Menu WIDGET
require_once(get_template_directory().'/inc/aftv-custom-menu-widget.php');
// Register The footer navigation menu widget
add_action( 'widgets_init', function() { register_widget( 'AFTV_Nav_Menu_Widget' ); } );
// Add content Width Feature
if ( ! isset( $content_width ) ){
$content_width = 900;
}