-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
244 lines (183 loc) · 6.31 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
<?php
/**
Option Tree, to be added eventuall from parent theme (JM, 4/7/14)
*/
// Required: set 'ot_child_theme_mode' filter to true.
//add_filter( 'ot_child_theme_mode', '__return_true' );
/* this addresses a bug w/ white text in visual composer textarea */
function tinymce_black_text() {
echo '<style type="text/css">
.js .tmce-active .wp-editor-area{color: #000000!important}
</style>';
}
add_action('admin_head', 'tinymce_black_text');
function edit_title_placeholder(){
?>
<script>
jQuery( document ).ready(function() {
jQuery("label#title-prompt-text").html("Enter the title of your research project here");
});
</script>
<?php
}
add_action('admin_head', 'edit_title_placeholder');
function hide_revslider_metabox(){
?>
<script>
jQuery( document ).ready(function() {
jQuery("#mymetabox_revslider_0").hide();
});
</script>
<?php
}
add_action('admin_head', 'hide_revslider_metabox');
/* Allows iframes in posts: */
/* http://ecolosites.eelv.fr/how-to-finally-allow-iframes-in-wordpress-or-any-other-tag/ */
add_filter( 'wp_kses_allowed_html', 'esw_author_cap_filter',1,1 );
function esw_author_cap_filter( $allowedposttags ) {
//Here put your conditions, depending your context
if ( !current_user_can( 'publish_posts' ) )
return $allowedposttags;
// Here add tags and attributes you want to allow
$allowedposttags['iframe']=array(
'align' => true,
'width' => true,
'height' => true,
'frameborder' => true,
'name' => true,
'src' => true,
'id' => true,
'class' => true,
'style' => true,
'scrolling' => true,
'marginwidth' => true,
'marginheight' => true,
);
return $allowedposttags;
}
/* end iframes in posts */
/**
* Create Metaboxes
*
* @link http://www.billerickson.net/wordpress-metaboxes/
* @param array
* @return array
*
*/
function be_create_metaboxes( $meta_boxes ) {
$meta_boxes[] = array(
'id' => 'rotator-options',
'title' => 'Project Fields',
'pages' => array('portfolio'),
'context' => 'normal',
'priority' => 'low',
'show_names' => true,
'fields' => array(
/* array(
'name' => 'Required Fields',
'desc' => 'Please enter the information below',
'type' => 'title',
), */
array(
'name' => 'Research Question',
'desc' => '',
'id' => 'wdi_research_question',
'type' => 'text',
//'attributes'=>array('maxlength'=>140)
),
array(
'name' => 'Project Abstract: Enter your abstract here (150 - 250 words)',
'id' => 'wdi_project_abstract',
'type' => 'wysiwyg',
),
/* array(
'name' => 'Optional Fields',
'desc' => 'You are welcome to add the supporting information below',
'type' => 'title',
), */
array(
'name' => 'Blank Canvas: This is an open canvas area for additional text, images, charts, videos, etc. about your project',
'id' => 'wdi_canvas',
'type' => 'wysiwyg',
//'type' => 'textarea_code'
),
array(
'name' => 'Upload supporting files here (pdf, txt, csv, excel, etc.) Upload as many supporting files as you like.',
'desc' => '',
'id' => 'wdi_file_list',
'type' => 'file_list',
),
/*
array(
'name' => 'Additional Links',
'desc' => 'To add a link, please follow these instructions:<ul><li>--use the format <a href=\'URL\'>LINKTEXT</a> </li><li>--change URL to the actual URL, and change LINKTEXT to the text displaying the link</li><li>--example: <a href=\'http://www.onlinecharttool.com/\'>Charts and Graphs</a>. This will display as <a href=\'http://www.onlinecharttool.com/\'>Charts and Graphs</a></li></ul>',
'id' => 'wdi_test_text',
'type' => 'text',
'repeatable'=>true
),
*/
array(
'name' => 'Link 1: Add a link to a supporting or related web site.',
'id' => 'wdi_project_link1',
'type' => 'wysiwyg',
'options' => array('textarea_rows' => 1)
),
array(
'name' => 'Link 2: Add a link to a supporting or related web site.',
'id' => 'wdi_project_link2',
'type' => 'wysiwyg',
'options' => array('textarea_rows' => 1)
),
array(
'name' => 'Link 3: Add a link to a supporting or related web site.',
'id' => 'wdi_project_link3',
'type' => 'wysiwyg',
'options' => array('textarea_rows' => 1)
),
array(
'name' => 'Link 4: Add a link to a supporting or related web site.',
'id' => 'wdi_project_link4',
'type' => 'wysiwyg',
'options' => array('textarea_rows' => 1)
),
),
);
return $meta_boxes;
}
add_filter( 'cmb_meta_boxes' , 'be_create_metaboxes' );
/**
* Initialize Metabox Class
* see /lib/metabox/example-functions.php for more information
*
*/
function be_initialize_cmb_meta_boxes() {
if ( !class_exists( 'cmb_Meta_Box' ) ) {
require_once( 'lib/metabox/init.php' );
}
}
add_action( 'init', 'be_initialize_cmb_meta_boxes', 9999 );
function custom_admin_js() {
$url = get_option('siteurl');
$url = get_bloginfo('template_directory') . '-child/admin.js';
echo '"<script type="text/javascript" src="'. $url . '"></script>"';
}
add_action('admin_footer', 'custom_admin_js');
//load the script for custom sorting of portfolios
function custom_sorting_js() {
$url = get_template_directory_uri() . '-child/sorting.js';
wp_enqueue_script( 'custom_sorting', $url);
}
add_action('wp_enqueue_scripts', 'custom_sorting_js');
add_filter( 'admin_post_thumbnail_html', 'add_featured_image_instruction');
function add_featured_image_instruction( $content ) {
return $content .= '<p>The Featured Image is a thumbnail image used on the home page and in the "Projects" page. Click the link above to add or change the image for this post. </p>';
}
// this function initializes the iframe elements
function getSubnet(){
$remote=$_SERVER ["REMOTE_ADDR"];
$x=explode(".",$remote);
if ($x[0]=="149" && $x[1]=="175" && $x[2]=="20"){$user="staff";}
else{$user="public";}
return $user;
}
?>