-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
303 lines (263 loc) · 10.3 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
<?php
/**
* Include framework
*
* @since azzu 1.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since azzu 1.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 1200; /* pixels */
}
if ( !class_exists('AzuTheme') ) :
class AzuTheme
{
function init($options)
{
$this->constants($options);
$this->functions();
$this->init_detect();
$this->plugins();
$this->admin();
add_action('after_setup_theme', array( &$this, 'supports'), 15);
add_action('widgets_init', array( &$this, 'widgets' ));
}
function init_detect(){
//Mobile detection library
require_once( AZZU_FUNCTION_DIR . '/mobile-detect-function.php' );
azu_mobile_detect();
//retina & screen size detect
if ( !isset($_COOKIE['devicePixelRatio']) && !azu_is_login_page()) :
// Add hook for front-end <head></head>
add_action('wp_head','retina_detection_js');
endif;
}
function constants($options)
{
/**
* Theme init file.
*
*/
require_once( get_template_directory() . '/fw/constants.php' );
}
function functions()
{
/**
* Include core functions.
*
*/
require_once( AZZU_FUNCTION_DIR . '/core-functions.php' );
/**
* Include options framework if it is not installed like plugin.
*
*/
if ( !defined('OPTIONS_FRAMEWORK_VERSION') ) {
// Base
require_once( AZZU_LIBRARY_DIR . '/theme-options/options-framework.php' );
if ( current_user_can( 'edit_theme_options' ) ) {
// add theme options
add_filter( 'options_framework_location', 'azzu_add_theme_options' );
}
}
}
function widgets()
{
$widget_areas = apply_filters( 'azu_widget_areas', array() );
foreach ($widget_areas as $value) {
$azu_widget='azu-widget';
if($value=='Topbar')
$azu_widget.= azuf()->azu_get_alignment_class('top_bar-content_alignment');
else if($value=='Bottombar')
$azu_widget.= azuf()->azu_get_alignment_class('bottom_bar-content_alignment');
register_sidebar( array(
'name' => $value,
'id' => strtolower(AZU_WIDGET_PREFIX . sanitize_key($value)),
'description' => _x( 'Widget area created by theme', 'atheme', 'azzu'.LANG_DN ),
'before_widget' => '<div class="'.$azu_widget.' %2$s">', //id="%1$s"
'after_widget' => '</div>',
'before_title' => '<div class="widget-title"><'.AZU_WIDGET_TITLE_H.'>',
'after_title' => '</'.AZU_WIDGET_TITLE_H.'></div>',
) );
}
// widget adder
require_once(AZZU_LIBRARY_DIR.'/widget_areas/class.redux_widget_areas.php');
global $azu_widget_areas;
if ( class_exists( 'Redux_Widget_Areas' ) && $azu_widget_areas === null)
{
$azu_widget_areas = new Redux_Widget_Areas();
}
}
function plugins()
{
//////////////////////////////////
// WPBakery Visual Composer //
//////////////////////////////////
if ( class_exists( 'Vc_Manager', false ) ) {
if ( function_exists( 'vc_set_as_theme' ) ) {
vc_set_as_theme(true);
}
if ( function_exists( 'vc_set_default_editor_post_types' ) ) {
vc_set_default_editor_post_types( array( 'page', 'post', 'azu_portfolio' ) );
}
require_once locate_template('/fw/vc_plugins/vc_addons.php');
if ( !function_exists('azu_js_composer_load_bridge') ) {
function azu_js_composer_load_bridge() {
require_once locate_template('/fw/vc_plugins/vc_bridge.php');
}
}
if ( ! function_exists( 'js_composer_bridge_admin' ) ) {
function js_composer_bridge_admin( $hook ) {
// azu stuff
wp_enqueue_style( '', AZZU_URI . '/vc_plugins/assets/css/vc_bridge.css' );
}
}
add_action( 'init', 'azu_js_composer_load_bridge', 20 );
add_action( 'admin_enqueue_scripts', 'js_composer_bridge_admin', 15 );
if ( function_exists( 'vc_set_shortcodes_templates_dir' ) ) {
vc_set_shortcodes_templates_dir( get_template_directory() . '/fw/vc_plugins/templates' );
}
}
}
function supports()
{
/**
* This theme styles the visual editor to resemble the theme style.
*/
add_editor_style( array( 'ui/'. AZZU_DESIGN.'/css/editor-style.css', azuh()->azu_font_url() ) );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' ); //since wordpress 4.1
/**
* Enable support for Post Thumbnails
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 350 , 350, true);
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( apply_filters( 'azu_register_nav_menus', array() ) );
/**
* Enable support for Post Formats
*/
add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'audio', 'quote', 'link', 'gallery', 'status', 'chat' ) );
/**
* Allow shortcodes in widgets.
*
*/
add_filter( 'widget_text', 'do_shortcode' );
// create upload dir
wp_upload_dir();
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on azzu, use a find and replace
* to change 'azzu'.LANG_DN to the name of your theme in all the template files
*/
load_theme_textdomain( 'azzu'.LANG_DN, get_stylesheet_directory() . '/languages' );
}
function admin()
{
$current_page_name = azuf()->azu_get_current_page_name();
$is_backend = is_admin() || azu_is_login_page();
if ( function_exists('vc_is_inline') && vc_is_inline() ) {
$is_backend = false;
}
/**
* Include custom menu.
*
*/
require_once( AZZU_LIBRARY_DIR . '/megamenu/azumenu.php' );
/**
* customizer.
*/
require_once( AZZU_LIBRARY_DIR . '/customizer/customizer.php' );
/**
* Include admin functions.
*/
if ( $is_backend && is_admin() ) {
/**
* Include the TGM_Plugin_Activation class.
*/
require_once( AZZU_LIBRARY_DIR . '/class-tgm-plugin-activation.php' );
/**
* Attach metaboxes.
*
*/
require_once( AZZU_OPTIONS_DIR . '/page-option/metaboxes.php' );
if ( $located_file = locate_template( 'fw/options/page-option/page-option.php' ) ) {
include_once( $located_file );
}
require_once( AZZU_FUNCTION_DIR . '/admin-functions.php' );
/**
* One click demo install.
*
*/
require_once( AZZU_LIBRARY_DIR . '/one-click-demo/init.php' );
} else if ( !$is_backend ) {
/**
* Include AQResizer.
*
*/
require_once( AZZU_LIBRARY_DIR . '/aq_resizer.php' );
}
/**
* Include widgets.
*
*/
$azzu_widgets = apply_filters( 'azzu_widgets', array() );
// include widgets only for frontend and widgets admin page
if ( $azzu_widgets && ( in_array($current_page_name, array('widgets.php', 'admin-ajax.php', 'themes.php')) || !$is_backend ) ) {
foreach ( $azzu_widgets as $azzu_widget ) {
if(strpos($azzu_widget, '/') !== FALSE)
$file_path = $azzu_widget;
else
$file_path = locate_template( 'fw/widgets/' . $azzu_widget );
require_once( $file_path );
}
}
$azzu_shortcodes = apply_filters( 'azzu_shortcodes', array() );
// include shortcodes only for frontend and post admin pages
if ( $azzu_shortcodes && ( in_array( $current_page_name, array('post.php', 'post-new.php', 'admin-ajax.php') ) || !$is_backend ) ) {
/**
* Setup shortcodes.
*
*/
require_once( AZZU_SHORTCODES_DIR . '/shortcode.class.php' );
foreach ( $azzu_shortcodes as $shortcode_name ) {
if(strpos($shortcode_name, '/') !== FALSE)
$file_path = $shortcode_name. '.php';
else
$file_path = AZZU_SHORTCODES_DIR . '/' . $shortcode_name . '.php';
include_once( $file_path );
}
}
// if Layer and Revolution sliders both active
if ( defined('LS_PLUGIN_VERSION') && class_exists('UniteBaseClassRev') ) {
/**
* Layer slider compatibility settings.
*
*/
add_action( 'admin_init', 'azzu_layerslider_set_properties',9 );
}
}
}
endif; //theme
//Create theme
$itheme = new AzuTheme();
$itheme->init(array(
"theme_name" => preg_replace("/\W /", "", strtolower(wp_get_theme()->get( 'Name' )) ),
"theme_slug" => "AZU"
));