-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
367 lines (367 loc) · 15.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
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
<?php
require_once( get_theme_file_path("/lib/tgm-plugin/class-tgm-plugin-activation.php") );
require_once( get_theme_file_path("/inc/tgm.php") );
require_once( get_theme_file_path("/inc/customizer.php") );
require_once( get_theme_file_path("/inc/customizer-page.php") );
require_once( get_theme_file_path( "/lib/csf/cs-framework.php" ) );
require_once( get_theme_file_path( "/inc/mj-wp-breadcrumb/mj-wp-breadcrumb.php" ) );
require_once( get_theme_file_path( "/inc/metaboxes/page-testimonials.php" ) );
define( 'CS_ACTIVE_FRAMEWORK', false ); // default true
define( 'CS_ACTIVE_METABOX', true ); // default true
define( 'CS_ACTIVE_TAXONOMY', false ); // default true
define( 'CS_ACTIVE_SHORTCODE', false ); // default true
define( 'CS_ACTIVE_CUSTOMIZE', true ); // default true
if ( site_url() == "http://localhost" ) {
define( "VERSION", time() );
} else {
define( "VERSION", wp_get_theme()->get( "Version" ) );
}
function educulture_theme_setup() {
load_theme_textdomain( 'educulture', get_template_directory() . '/languages' );
add_theme_support( 'automatic-feed-links' );
$educulture_custom_header_details = array(
'header-text' => true,
'default-text-color' => '#222',
'width' => 1200,
'height' => 600,
'flex-height' => true,
'flex-width' => true,
);
add_theme_support( "custom-header", $educulture_custom_header_details );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'educulture' ),
) );
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'gallery',
'caption',
'comment-list',
) );
$educulture_custom_logo_defaults = array(
"width" => '100px',
"height" => '60px',
);
add_theme_support( "custom-logo", $educulture_custom_logo_defaults );
add_theme_support( 'custom-background', apply_filters( 'educulture_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
// custom Image size.
add_image_size( "educulture-blog-image", 400, 300,array("center","center"), true);
}
add_action( 'after_setup_theme', 'educulture_theme_setup' );
function educulture_add_editor_styles() {
add_editor_style( '/lib/custom-editor-style.css' );
}
add_action( 'admin_init', 'educulture_add_editor_styles' );
function educulture_content_width() {
$GLOBALS['content_width'] = apply_filters( 'educulture_content_width', 1170 );
}
add_action( 'after_setup_theme', 'educulture_content_width', 0 );
function educulture_assets(){
wp_enqueue_style('google-fonts','//fonts.googleapis.com/css?family=Work+Sans:100,200,300,400,500,600,700,800,900');
wp_enqueue_style('google-fonts-swap','//fonts.googleapis.com/css?family=Fredericka+the+Great');
wp_enqueue_style('fonts-awesome','//stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
wp_enqueue_style('iconic-bootstrap-css',get_theme_file_uri('/assets/css/open-iconic-bootstrap.min.css'));
wp_enqueue_style('carousel-css',get_theme_file_uri('/assets/css/owl.carousel.min.css'));
wp_enqueue_style('animate-css',get_theme_file_uri('/assets/css/animate.css'));
wp_enqueue_style('theme-default-css',get_theme_file_uri('/assets/css/owl.theme.default.min.css'));
wp_enqueue_style('magnific-css',get_theme_file_uri('/assets/css/magnific-popup.css'));
wp_enqueue_style('ionicons-css',get_theme_file_uri('/assets/css/ionicons.min.css'));
wp_enqueue_style('flaticon-css',get_theme_file_uri('/assets/css/flaticon.css'));
wp_enqueue_style('icomoon-css',get_theme_file_uri('/assets/css/icomoon.css'));
wp_enqueue_style('aos-css',get_theme_file_uri('/assets/css/aos.css'));
wp_enqueue_style('educulture-design-css',get_theme_file_uri('/assets/css/style.css'),null,VERSION);
wp_enqueue_style('educulture-css',get_stylesheet_uri(),null,VERSION);
$heading_icon_color = get_theme_mod( 'educulture_heading_color', '#dd2d6a' );
$heading_title_color = get_theme_mod( 'educulture_title_color', '#dd2d6a' );
$heading_sub_title_color = get_theme_mod( 'educulture_sub_title_color', '#000' );
$heading_button_color = get_theme_mod( 'educulture_button_color', '#fff' );
$heading_button_bg_color = get_theme_mod( 'educulture_button_bg_color', '#fda638' );
$about_section_icon_bg = get_theme_mod( 'educulture_about_section_bg', '#1EAAF1' );
$faq_section_bg = get_theme_mod( 'educulture_faq_section_bg', '#fff' );
$faq_section_color = get_theme_mod( 'educulture_faq_section_color', '#000' );
$topbar_background_color = get_theme_mod( 'educulture_topbar_background_color', '#000' );
$heading_style = <<<EOD
.heading-section h2 {
color: {$heading_icon_color};
}
.owl-carousel.home-slider .slider-item .slider-text h1{
color: {$heading_title_color};
}
.owl-carousel.home-slider .slider-item .slider-text p{
color: {$heading_sub_title_color};
}
.btn.btn-secondary{
color: {$heading_button_color};
}
.btn.btn-secondary{
background: {$heading_button_bg_color};
border: {$heading_button_bg_color};
}
.btn.btn-secondary:hover, .btn.btn-secondary:focus, .btn.btn-secondary:active {
border: {$heading_button_bg_color};
color: {$heading_button_color};
}
.services-2 .icon{
background: {$about_section_icon_bg};
color: {};
}
.acc> h3{
background: {$faq_section_bg};
color: {$faq_section_color};
}
.social-topbar{
background: {$topbar_background_color};
}
EOD;
wp_add_inline_style( 'educulture-css', $heading_style );
wp_enqueue_script('jquery-js',get_theme_file_uri('/assets/js/jquery.min.js'),null,'default',true);
wp_enqueue_script('bootstrap-js',get_theme_file_uri('/assets/js/bootstrap.min.js'),['jquery'],'default',true);
wp_enqueue_script('migrate-js',get_theme_file_uri('/assets/js/jquery-migrate-3.0.1.min.js'),['jquery'],'default',true);
wp_enqueue_script('carousel-js',get_theme_file_uri('/assets/js/owl.carousel.min.js'),['jquery'],VERSION,true);
wp_enqueue_script('easing-js',get_theme_file_uri('/assets/js/jquery.easing.1.3.js'),['jquery'],VERSION,true);
wp_enqueue_script('popper-js',get_theme_file_uri('/assets/js/popper.min.js'),['jquery'],VERSION,true);
wp_enqueue_script('waypoints-js',get_theme_file_uri('/assets/js/jquery.waypoints.min.js'),['jquery'],VERSION,true);
wp_enqueue_script('stellar-js',get_theme_file_uri('/assets/js/jquery.stellar.min.js'),['jquery'],VERSION,true);
wp_enqueue_script('magnific-js',get_theme_file_uri('/assets/js/jquery.magnific-popup.min.js'),['jquery'],VERSION,true);
wp_enqueue_script('aos-js',get_theme_file_uri('/assets/js/aos.js'),['jquery'],VERSION,true);
wp_enqueue_script('animateNumber-js',get_theme_file_uri('/assets/js/jquery.animateNumber.min.js'),['jquery'],VERSION,true);
wp_enqueue_script('scrollax-js',get_theme_file_uri('/assets/js/scrollax.min.js'),['jquery'],VERSION,true);
wp_enqueue_script('faq-js',get_theme_file_uri('/assets/js/faq.js'),['jquery'],VERSION,true);
wp_enqueue_script( 'educulture-reservation-js', get_template_directory_uri() . '/assets/js/reservation.js', array( 'jquery' ), VERSION, true );
$ajaxurl = admin_url( 'admin-ajax.php' );
wp_localize_script( 'educulture-reservation-js', 'educultureurl', array( 'ajaxurl' => $ajaxurl ) );
if ( is_singular() ){ wp_enqueue_script( "comment-reply" );}
wp_enqueue_script('main-js',get_theme_file_uri('/assets/js/main.js'),['jquery'],VERSION,true);
}
add_action('wp_enqueue_scripts','educulture_assets');
function educulture_customizer_assets() {
wp_enqueue_script( "educulture-customizer-js", get_theme_file_uri( "/assets/js/customizer.js" ), array(
'jquery',
'customize-preview'
), time(), true );
wp_enqueue_script( "educulture-customizer-about-js", get_theme_file_uri( "/assets/js/customizer-page.js" ), array(
'jquery',
'customize-preview'
), time(), true );
}
add_action( "customize_preview_init", 'educulture_customizer_assets' );
function educulture_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Single page Sidebar', 'educulture' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'educulture' ),
'before_widget' => '<section id="%1$s" class="p-2 widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => esc_html__( 'Blog Sidebar', 'educulture' ),
'id' => 'sidebar-blog',
'description' => esc_html__( 'Add widgets here.', 'educulture' ),
'before_widget' => '<div id="%1$s" class="p-2 widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
;register_sidebar( array(
'name' => esc_html__( 'Footer Sidebar one', 'educulture' ),
'id' => 'footer-sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'educulture' ),
'before_widget' => '<div id="%1$s" class="pl-2 list-unstyled text-light widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="footer-heading mb-4 text-light widget-title">',
'after_title' => '</h3>',
) );
;register_sidebar( array(
'name' => esc_html__( 'Footer Sidebar Two', 'educulture' ),
'id' => 'footer-sidebar-2',
'description' => esc_html__( 'Add widgets here.', 'educulture' ),
'before_widget' => '<div id="%1$s" class="list-unstyled pl-2 text-light widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="footer-heading mb-4 text-light widget-title">',
'after_title' => '</h3>',
) );
;register_sidebar( array(
'name' => esc_html__( 'Footer Sidebar three', 'educulture' ),
'id' => 'footer-sidebar-3',
'description' => esc_html__( 'Add widgets here.', 'educulture' ),
'before_widget' => '<div id="%1$s" class="pl-2 text-light widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="footer-heading mb-4 widget-title text-light">',
'after_title' => '</h3>',
) );
;register_sidebar( array(
'name' => esc_html__( 'Footer Sidebar four', 'educulture' ),
'id' => 'footer-sidebar-4',
'description' => esc_html__( 'Add widgets here.', 'educulture' ),
'before_widget' => '<div id="%1$s" class="pl-2 text-light widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="footer-heading mb-4 text-light widget-title">',
'after_title' => '</h3>',
) );
;register_sidebar( array(
'name' => esc_html__( 'Google Map', 'educulture' ),
'id' => 'google-map',
'description' => esc_html__( 'Add widgets here.', 'educulture' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title mb-5">',
'after_title' => '</h3>',
) );
;register_sidebar( array(
'name' => esc_html__( 'Topbar Social Icon', 'educulture' ),
'id' => 'socialicon',
'description' => esc_html__( 'Add Social Icon widgets here', 'educulture' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'educulture_widgets_init' );
function educulture_csf_init(){
CSFramework_metabox::instance(array());
CSFramework_Customize::instance(array());
}
add_action('init', 'educulture_csf_init');
function educulture_about_page_template_banner() {
if ( is_page() ) {
if ( current_theme_supports( "custom-header" ) ) {
?>
<style>
.hero-wrap-2 {
background-image: url(<?php echo header_image();
?>);
background-size: cover;
}
</style>
<?php
}
}
}
add_action( "wp_head", "educulture_about_page_template_banner", 11 );
function educulture_excerpt_more( $more ) {
if ( ! is_single() ) {
$more = sprintf( '<a class="read-more" href="%1$s">%2$s</a>',
get_permalink( get_the_ID() ),
__( 'Read More', 'educulture' )
);
}
return $more;
}
add_filter( 'excerpt_more', 'educulture_excerpt_more' );
function educulture_custom_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'educulture_custom_excerpt_length', 999 );
function educulture_search_form( $form ) {
$homedir = home_url( "/" );
$label = __( "Search for:", "educulture" );
$button_label = __( "Search", "educulture" );
$newform = <<<FORM
<form role="search" method="get" class="search-form" action="{$homedir}">
<label>
<span class="hide-content">{$label}</span>
<input type="search" class="form-control" placeholder="Type Keywords" value="" name="s"
title="{$label}" autocomplete="off">
</label>
<input type="submit" class="btn btn-primary btn-sm" value="{$button_label}">
</form>
FORM;
return $newform;
}
add_filter( "get_search_form", "educulture_search_form" );
function educulture_process_reservation() {
if ( check_ajax_referer( 'reservation', 'rn' ) ) {
$name = sanitize_text_field( $_POST['name'] );
$email = sanitize_text_field( $_POST['email'] );
$country = sanitize_text_field( $_POST['country'] );
$phone = sanitize_text_field( $_POST['phone'] );
$data = array(
'name' => $name,
'email' => $email,
'phone' => $phone,
'country' => $country,
);
//print_r( $data );
$reservation_arguments = array(
'post_type' => 'reservation',
'post_author' => 1,
'post_date' => date( 'Y-m-d H:i:s' ),
'post_status' => 'publish',
'post_title' => sprintf( '%s - Apply for %s Email: %s Mobile Number: %s', $name, $country, $email, $phone),
'meta_input' => $data
);
$reservations = new WP_Query( array(
'post_type' => 'reservation',
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'OR',
'email_check' => array(
'key' => 'email',
'value' => $email
),
'date_check' => array(
'key' => 'phone',
'value' => $phone
),
)
) );
if ( $reservations->found_posts > 0 ) {
echo 'Duplicate';
} else {
$wp_error = '';
wp_insert_post( $reservation_arguments, $wp_error );
//transient check
$reservation_count = get_transient('res_count')?get_transient('res_count'):0;
//transient check end
if ( ! $wp_error ) {
$reservation_count++;
set_transient('res_count',$reservation_count,0);
echo "Successful";
}
}
} else {
echo 'Not allowed';
}
die();
}
add_action( 'wp_ajax_reservation', 'educulture_process_reservation' );
add_action( 'wp_ajax_nopriv_reservation', 'educulture_process_reservation' );
function educulture_change_menu($menu){
$reservation_count = get_transient('res_count')?get_transient('res_count'):0;
if($reservation_count>0){
$menu[11][0] = "Reservation <span class='awaiting-mod'>{$reservation_count}</span> ";
}
return $menu;
}
add_filter('add_menu_classes','educulture_change_menu');
function educulture_admin_scripts($screen){
$_screen = get_current_screen();
if('edit.php'==$screen && 'reservation'==$_screen->post_type){
delete_transient('res_count');
}
}
add_action('admin_enqueue_scripts','educulture_admin_scripts');
// Add Menu Class li Tag
function tanem_menu_item_class($classes, $item)
{
$classes[] = 'nav-item';
return $classes;
}
add_filter('nav_menu_css_class', 'tanem_menu_item_class', 10, 2);
// Add Menu Class a Tag
function add_link_atts($atts)
{
$atts['class'] = "nav-link";
return $atts;
}
add_filter('nav_menu_link_attributes', 'add_link_atts', 100, 1);