-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
189 lines (167 loc) · 6.01 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
<?php
add_filter('show_admin_bar', '__return_false');
/*
* Domegis API Data
*/
function register_domegis_data($data) {
// BASIN % OF DEFORESTED AREA
$data[] = array(
'name' => 'basin_deforested_area',
'title' => __('Deforested area', 'arp'),
'type' => 'percentage',
'post_type' => 'basin',
'required_fields' => array(
array(
'key' => 'deforestation_layer',
'name' => __('Deforestation layer ID', 'arp')
),
array(
'key' => 'basin_layer',
'name' => __('Basin layer ID', 'arp')
)
),
'sql' => 'SELECT layer1.geometry,
ROUND(
CAST(100.00 * (
ST_Area(
ST_Intersection(
ST_Multi(ST_Union(layer0.geometry)), ST_Multi(ST_Union(layer1.geometry))
)::geography
) /
ST_Area(
ST_Multi(ST_Union(layer1.geometry))::geography
)
) as numeric), 2) as percentage
FROM %deforestation_layer% as layer0,
%basin_layer% as layer1
WHERE ST_Intersects(layer0.geometry, layer1.geometry)
GROUP BY layer1.domegis_id;'
);
// LIST OF ECOREGIONS THAT INTERSECTS WITH BASIN
$data[] = array(
'name' => 'basin_ecoregions',
'title' => __('List of ecoregions', 'arp'),
'type' => 'list',
'post_type' => 'basin',
'required_fields' => array(
array(
'key' => 'ecoregions_layer',
'name' => __('Ecoregions layer ID', 'arp')
),
array(
'key' => 'basin_layer',
'name' => __('Basin layer ID', 'arp')
)
),
'sql' => 'SELECT layer0.geometry,layer0.name
FROM %ecoregions_layer% as layer0,
%basin_layer% as layer1
WHERE ST_Intersects(layer0.geometry, layer1.geometry)
GROUP BY layer0.domegis_id;'
);
return $data;
}
//add_filter('domegis_api_data', 'register_domegis_data');
function arp_setup_theme() {
load_theme_textdomain('arp', get_template_directory() . '/languages');
add_theme_support( 'custom-header' );
add_theme_support( 'post-thumbnails' );
add_image_size('wide-thumbnail', 400, 225, true);
add_image_size('highlight', 860, 392, true);
register_nav_menus(array(
'header_nav' => __('Header navigation', 'arp'),
'footer_nav' => __('Footer navigation', 'arp')
));
}
add_action('after_setup_theme', 'arp_setup_theme');
function arp_scripts() {
wp_register_style('webfont-raleway', 'https://fonts.googleapis.com/css?family=Raleway:400,700,600italic,600,500italic,500,400italic,300italic,300,200italic,200,100italic,100,800');
wp_register_style('normalize', get_template_directory_uri() . '/assets/skeleton/css/normalize.css');
wp_register_style('skeleton', get_template_directory_uri() . '/assets/skeleton/css/skeleton.css');
wp_register_style('fontawesome', get_template_directory_uri() . '/assets/fontawesome/css/font-awesome.min.css');
wp_register_style('perfect-scrollbar', get_template_directory_uri() . '/assets/perfect-scrollbar/css/perfect-scrollbar.min.css');
wp_register_style('main', get_template_directory_uri() . '/css/main.css', array('webfont-raleway', 'normalize', 'skeleton', 'fontawesome', 'perfect-scrollbar'), '0.1.9');
wp_register_script('fitvids', get_template_directory_uri() . '/assets/jquery.fitvids/jquery.fitvids.js', array('jquery'));
wp_register_script('perfect-scrollbar', get_template_directory_uri() . '/assets/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js', array('jquery'));
wp_register_script('site', get_template_directory_uri() . '/js/site.js', array('jquery', 'fitvids', 'perfect-scrollbar'), '0.1.6');
wp_enqueue_style('main');
wp_enqueue_script('site');
}
add_action('wp_enqueue_scripts', 'arp_scripts');
function arp_custom_header() {
$img = get_header_image();
if($img) { ?>
<style>
#welcome:before { background-image: url('<?php echo $img; ?>') };
</style>
<?php
}
}
add_action('wp_footer', 'arp_custom_header');
function arp_get_header_class() {
$class = '';
if(!is_page_template('homepage.php')) {
$class .= ' collapsed';
}
if(is_page_template('basins.php') || is_page_template('map.php') || is_post_type_archive('basin')) {
$class .= ' transparent';
}
return $class;
}
function arp_get_brand_class() {
$class = '';
if(!is_page_template('homepage.php')) {
$class .= ' small';
}
return $class;
}
/*
* Required plugins
*/
require_once(TEMPLATEPATH . '/inc/class-tgm-plugin-activation.php');
function arp_register_required_plugins() {
$plugins = array(
array(
'name' => 'DomeGIS',
'slug' => 'domegis-wordpress-plugin',
'required' => true,
'force_activation' => false,
'source' => 'https://github.com/aparabolica/domegis-wordpress-plugin/archive/master.zip'
)
);
if(defined('ACF_PRO_KEY')) {
$plugins[] = array(
'name' => 'Advanced Custom Fields PRO',
'slug' => 'advanced-custom-fields-pro',
'required' => true,
'force_activation' => true,
'source' => 'https://connect.advancedcustomfields.com/index.php?p=pro&a=download&k=' . ACF_PRO_KEY
);
}
$options = array(
'default_path' => '',
'menu' => 'arp-install-plugins',
'has_notices' => true,
'dismissable' => true,
'dismiss_msg' => '',
'is_automatic' => false,
'message' => ''
);
tgmpa($plugins, $options);
}
add_action('tgmpa_register', 'arp_register_required_plugins');
// ACF Settings
// define( 'ACF_LITE', true );
require_once(TEMPLATEPATH . '/inc/page-builder-hooks.php');
require_once(TEMPLATEPATH . '/inc/site-options.php');
require_once(TEMPLATEPATH . '/inc/custom-featured-image.php');
require_once(TEMPLATEPATH . '/inc/carousel.php');
require_once(TEMPLATEPATH . '/inc/basins.php');
require_once(TEMPLATEPATH . '/inc/video.php');
require_once(TEMPLATEPATH . '/inc/external-src.php');
require_once(TEMPLATEPATH . '/inc/library-page.php');
require_once(TEMPLATEPATH . '/inc/home-page.php');
require_once(TEMPLATEPATH . '/inc/map-page.php');
require_once(TEMPLATEPATH . '/inc/story-map-page.php');
require_once(TEMPLATEPATH . '/inc/embed-page.php');
require_once(TEMPLATEPATH . '/inc/domegis-data.php');