-
Notifications
You must be signed in to change notification settings - Fork 5
/
functions.php
184 lines (159 loc) · 6.91 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
<?php
require_once(STYLESHEETPATH . '/inc/lightbox/lightbox.php');
require_once(STYLESHEETPATH . '/inc/artguides/artguides.php');
require_once(STYLESHEETPATH . '/inc/artists/artists.php');
require_once(STYLESHEETPATH . '/inc/artworks/artworks.php');
require_once(STYLESHEETPATH . '/inc/geolocator/geolocator.php');
require_once(STYLESHEETPATH . '/inc/views.php');
include_once(STYLESHEETPATH . '/inc/instagram/instagram.php');
include_once(STYLESHEETPATH . '/inc/mobile-map-list/mobile-map-list.php');
include_once(STYLESHEETPATH . '/inc/slider.php'); // Featured slider
/*
* Advanced Custom Fields
*/
function afdm_acf_path() {
return get_stylesheet_directory_uri() . '/inc/acf/';
}
add_filter('acf/helpers/get_dir', 'afdm_acf_path');
define('ACF_LITE', false);
require_once(STYLESHEETPATH . '/inc/acf/acf.php');
include_once(STYLESHEETPATH . '/inc/acf/add-ons/acf-qtranslate/acf-qtranslate.php');
function afdm_setup() {
load_child_theme_textdomain('arteforadomuseu', get_stylesheet_directory() . '/languages');
add_theme_support('post-thumbnails');
add_image_size('page-featured', 680, 270, true);
add_image_size('featured-squared', 400, 400, true);
}
add_action('after_setup_theme', 'afdm_setup');
function afdm_scripts() {
wp_deregister_script('jeo-site');
wp_enqueue_style('afdm-main', get_stylesheet_directory_uri() . '/css/main.css', array(), '1.7');
wp_enqueue_script('responsive-nav', get_stylesheet_directory_uri(). '/lib/responsive-nav.min.js', '', '1.0');
wp_enqueue_script('afdm', get_stylesheet_directory_uri(). '/js/arteforadomuseu.js', array('responsive-nav', 'shadowbox'), '0.1.10');
}
function afdm_after_markers_scripts() {
if(!is_single()) {
wp_enqueue_script('afdm-filter', get_stylesheet_directory_uri() . '/js/arteforadomuseu.filterCategories.js', array('jquery', 'jeo.markers'), '0.0.5');
wp_localize_script('afdm-filter', 'afdmFilter', array(
'categories' => array(
array(
'slug' => 'colaborativo',
'title' => 'Apenas obras colaborativas'
)
)
));
}
}
function afdm_register_lib() {
wp_register_style('jquery-wysiwyg', get_stylesheet_directory_uri() . '/lib/jquery.wysiwyg.css');
wp_register_script('jquery-wysiwyg', get_stylesheet_directory_uri() . '/lib/jquery.wysiwyg.js', array('jquery'));
wp_register_script('jquery-jeditable', get_stylesheet_directory_uri() . '/lib/jquery.jeditable.mini.js', array('jquery'));
wp_register_script('jquery-jeditable-wysiwyg', get_stylesheet_directory_uri() . '/lib/jquery.jeditable.wysiwyg.js', array('jquery', 'jquery-jeditable', 'jquery-wysiwyg'));
wp_register_script('jquery-autosize', get_stylesheet_directory_uri() . '/lib/jquery.autosize-min.js', array('jquery'), '1.16.7');
wp_register_script('jquery-ui-datepicker-pt-BR', get_stylesheet_directory_uri() . '/lib/jquery.ui.datepicker.pt-BR.js', array('jquery-ui-datepicker'));
wp_register_script('jquery-chosen', get_stylesheet_directory_uri() . '/lib/jquery.chosen.min.js', array('jquery'), '0.9.14');
wp_register_style('jquery-chosen', get_stylesheet_directory_uri() . '/lib/chosen.css');
wp_deregister_script('jquery-form');
wp_register_script('jquery-form', get_stylesheet_directory_uri() . '/lib/jquery.form.js', array('jquery'), '3.34.0-test1');
wp_register_script('shadowbox', get_stylesheet_directory_uri() . '/lib/shadowbox/shadowbox.js', array('jquery'), '3.0.3');
wp_enqueue_style('shadowbox', get_stylesheet_directory_uri() . '/lib/shadowbox/shadowbox.css');
wp_register_style('jquery-tag-it', get_stylesheet_directory_uri() . '/lib/jquery.tagit.css');
wp_register_script('jquery-tag-it', get_stylesheet_directory_uri() . '/lib/tag-it.min.js', array('jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position', 'jquery-ui-autocomplete'), '2.0');
}
add_action('wp_enqueue_scripts', 'afdm_register_lib', 15);
add_action('jeo_enqueue_scripts', 'afdm_scripts', 15);
add_action('jeo_markers_enqueue_scripts', 'afdm_scripts', 10);
add_action('admin_footer', 'afdm_register_lib', 10);
function afdm_marker_extent() {
return true;
}
add_action('jeo_use_marker_extent', 'afdm_marker_extent');
add_filter('show_admin_bar', '__return_false');
function afdm_prevent_admin_access() {
if (!current_user_can('edit_others_posts') && !defined('DOING_AJAX')) {
wp_redirect(home_url());
exit();
}
}
add_action('admin_init', 'afdm_prevent_admin_access', 0);
function afdm_get_user_menu() {
?>
<div class="user-meta hide-if-mobile">
<?php
if(!is_user_logged_in()) :
?>
<span class="dropdown-title login clearfix"><span class="lsf icon"></span> <span class="icon-title"><?php _e('Login', 'arteforadomuseu'); ?></span></span>
<div class="dropdown-content">
<div class="login-content">
<p><?php _e('Login with: ', 'arteforadomuseu'); ?></p>
<?php do_action('oa_social_login'); ?>
</div>
</div>
<?php
else :
?>
<span class="dropdown-title login clearfix"><span class="lsf icon"></span> <span class="user-name"><?php echo wp_get_current_user()->display_name; ?></span></span>
<div class="dropdown-content">
<div class="logged-in">
<p><?php _e('Hello', 'arteforadomuseu'); ?>, <?php echo wp_get_current_user()->display_name; ?>. <a class="logout" href="<?php echo wp_logout_url(home_url()); ?>" title="<?php _e('Logout', 'arteforadomuseu'); ?>"><?php _e('Logout', 'arteforadomuseu'); ?> <span class="lsf"></span></a></p>
<ul class="user-actions">
<?php do_action('afdm_logged_in_user_menu_items'); ?>
<?php if(current_user_can('edit_others_posts')) : ?>
<li><a href="<?php echo get_admin_url(); ?>"><?php _e('Dashboard', 'arteforadomuseu'); ?></a></li>
<?php endif; ?>
</ul>
</div>
</div>
<?php
endif;
?>
</div>
<?php
}
function afdm_city_not_found_message() {
global $wp_query;
if(get_query_var('city_not_found')) {
?>
<div class="content-message">
<p>
<?php _e('We couldn\'t find anything for your city.', 'arteforadomuseu'); ?><br />
<?php _e('Showing all cities results', 'arteforadomuseu'); ?>
</p>
<?php if(is_user_logged_in()) { ?>
<p><a href="#" class="button add_artwork"><?php _e('Click here to add an artwork', 'arteforadomuseu'); ?></a></p>
<?php } else { ?>
<p><a href="#"><?php _e('Login to submit an artwork!', 'arteforadomuseu'); ?></a></p>
<?php } ?>
</div>
<?php
}
}
add_action('afdm_before_content', 'afdm_city_not_found_message');
function afdm_flush_rewrite() {
global $pagenow;
if(is_admin() && $_REQUEST['activated'] && $pagenow == 'themes.php') {
global $wp_rewrite;
$wp_rewrite->init();
$wp_rewrite->flush_rules();
}
}
add_action('init', 'afdm_flush_rewrite');
function w3c_banner() {
?>
<a class="w3c-banner" href="http://www.blog.arteforadomuseu.com.br/?p=8" target="_blank">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/w3c_banner.png" />
</a>
<style>
a.w3c-banner {
position: fixed;
top: 0;
right: 0;
z-index: 99999;
}
a.w3c-banner img {
display: block;
}
</style>
<?php
}
add_action('wp_footer', 'w3c_banner');