PluginProbe
WP Ultimate Post Grid / 2.5.0
WP Ultimate Post Grid v2.5.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / vendor / vafpress / bootstrap.php

bootstrap.php in WP Ultimate Post Grid 2.5.0, at vendor/vafpress/bootstrap.php

344 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if( defined('VP_VERSION') )
4 return;
5
6 //////////////////////////
7 // Include Constants //
8 //////////////////////////
9 require_once 'constant.php';
10
11 //////////////////////////
12 // Include Autoloader //
13 //////////////////////////
14 require_once 'autoload.php';
15
16 //////////////////////////
17 // Load Languages //
18 //////////////////////////
19 load_theme_textdomain('wp-ultimate-recipe', VP_DIR . '/lang');
20
21 //////////////////////////
22 // Setup FileSystem //
23 //////////////////////////
24 $vpfs = VP_FileSystem::instance();
25 $vpfs->add_directories('views' , VP_VIEWS_DIR);
26 $vpfs->add_directories('config' , VP_CONFIG_DIR);
27 $vpfs->add_directories('data' , VP_DATA_DIR);
28 $vpfs->add_directories('includes', VP_INCLUDE_DIR);
29
30 //////////////////////////
31 // Include Data Source //
32 //////////////////////////
33 foreach (glob(VP_DATA_DIR . "/*.php") as $datasource)
34 {
35 require_once($datasource);
36 }
37
38 //////////////////////////
39 // TGMPA Unsetting //
40 //////////////////////////
41 add_action('after_setup_theme', 'vp_tgm_ac_check');
42
43 if( !function_exists('vp_tgm_ac_check') )
44 {
45 function vp_tgm_ac_check()
46 {
47 add_action('tgmpa_register', 'vp_tgm_ac_vafpress_check');
48 }
49 }
50
51 if( !function_exists('vp_tgm_ac_vafpress_check') )
52 {
53 function vp_tgm_ac_vafpress_check()
54 {
55 if( defined('VP_VERSION') and class_exists('TGM_Plugin_Activation') )
56 {
57 foreach (TGM_Plugin_Activation::$instance->plugins as $key => &$plugin)
58 {
59 if( $plugin['name'] === 'Vafpress Framework Plugin' )
60 {
61 unset(TGM_Plugin_Activation::$instance->plugins[$key]);
62 }
63 }
64 }
65 }
66 }
67
68 //////////////////////////
69 // Ajax Definition //
70 //////////////////////////
71 add_action('wp_ajax_vp_ajax_wrapper', 'vp_ajax_wrapper');
72
73 if( !function_exists('vp_ajax_wrapper') )
74 {
75 function vp_ajax_wrapper()
76 {
77 $function = $_POST['func'];
78 $params = $_POST['params'];
79
80 if( VP_Security::instance()->is_function_whitelisted($function) )
81 {
82 if(!is_array($params))
83 $params = array($params);
84
85 try {
86 $result['data'] = call_user_func_array($function, $params);
87 $result['status'] = true;
88 $result['message'] = __("Successful", 'wp-ultimate-recipe');
89 } catch (Exception $e) {
90 $result['data'] = '';
91 $result['status'] = false;
92 $result['message'] = $e->getMessage();
93 }
94 }
95 else
96 {
97 $result['data'] = '';
98 $result['status'] = false;
99 $result['message'] = __("Unauthorized function", 'wp-ultimate-recipe');
100 }
101
102 if (ob_get_length()) ob_clean();
103 header('Content-type: application/json');
104 echo json_encode($result);
105 die();
106 }
107 }
108
109 /////////////////////////////////
110 // Pool and Dependencies Init //
111 /////////////////////////////////
112 add_action( 'init' , 'vp_metabox_enqueue' );
113 add_action( 'current_screen' , 'vp_sg_enqueue' );
114 add_action( 'admin_enqueue_scripts', 'vp_enqueue_scripts' );
115 add_action( 'current_screen' , 'vp_sg_init_buttons' );
116 add_filter( 'clean_url' , 'vp_ace_script_attributes', 10, 1 );
117
118 if( !function_exists('vp_ace_script_attributes') )
119 {
120 function vp_ace_script_attributes( $url )
121 {
122 if ( FALSE === strpos( $url, 'ace.js' ) )
123 return $url;
124
125 return "$url' charset='utf8";
126 }
127 }
128
129 if( !function_exists('vp_metabox_enqueue') )
130 {
131 function vp_metabox_enqueue()
132 {
133 if( VP_WP_Admin::is_post_or_page() and VP_Metabox::pool_can_output() )
134 {
135 $loader = VP_WP_Loader::instance();
136 $loader->add_main_js( 'vp-metabox' );
137 $loader->add_main_css( 'vp-metabox' );
138 }
139 }
140 }
141
142 if( !function_exists('vp_sg_enqueue') )
143 {
144 function vp_sg_enqueue()
145 {
146 if( VP_ShortcodeGenerator::pool_can_output() )
147 {
148 // enqueue dummy js
149 $localize = VP_ShortcodeGenerator::build_localize();
150 wp_register_script( 'vp-sg-dummy', VP_PUBLIC_URL . '/js/dummy.js', array(), '', false );
151 wp_localize_script( 'vp-sg-dummy', 'vp_sg', $localize );
152 wp_enqueue_script( 'vp-sg-dummy' );
153
154 $loader = VP_WP_Loader::instance();
155 $loader->add_main_js( 'vp-shortcode' );
156 $loader->add_main_css( 'vp-shortcode' );
157 }
158 }
159 }
160
161 add_action('admin_footer', 'vp_post_dummy_editor');
162
163 if( !function_exists('vp_post_dummy_editor') )
164 {
165 function vp_post_dummy_editor()
166 {
167 /**
168 * If we're in post edit page, and the post type doesn't support `editor`
169 * we need to echo out a dummy editor to load all necessary js and css
170 * to be used in our own called wp editor.
171 */
172 $loader = VP_WP_Loader::instance();
173 $types = $loader->get_types();
174 $dummy = false;
175
176 if( VP_WP_Admin::is_post_or_page() )
177 {
178 $types = array_unique( array_merge( $types['metabox'], $types['shortcodegenerator'] ) );
179 if( in_array('wpeditor', $types ) )
180 {
181 if( !VP_ShortcodeGenerator::pool_supports_editor() and !VP_Metabox::pool_supports_editor() )
182 $dummy = true;
183 }
184 }
185 else
186 {
187 $types = $types['option'];
188 if( in_array('wpeditor', $types ) )
189 $dummy = true;
190 }
191
192 if( $dummy )
193 {
194 echo '<div style="display: none">';
195 add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
196 wp_editor ( '', 'vp_dummy_editor' );
197 echo '</div>';
198 }
199 }
200 }
201
202 if( !function_exists('vp_sg_init_buttons') )
203 {
204 function vp_sg_init_buttons()
205 {
206 if( VP_ShortcodeGenerator::pool_can_output() )
207 {
208 VP_ShortcodeGenerator::init_buttons();
209 }
210 }
211 }
212
213 if( !function_exists('vp_enqueue_scripts') )
214 {
215 function vp_enqueue_scripts()
216 {
217 $loader = VP_WP_Loader::instance();
218 $loader->build();
219 }
220 }
221
222 /**
223 * Easy way to get metabox values using dot notation
224 * example:
225 *
226 * vp_metabox('meta_name.field_name')
227 * vp_metabox('meta_name.group_name')
228 * vp_metabox('meta_name.group_name.0.field_name')
229 *
230 */
231
232 if( !function_exists('vp_metabox') )
233 {
234 function vp_metabox($key, $default = null, $post_id = null)
235 {
236 global $post;
237
238 $vp_metaboxes = VP_Metabox::get_pool();
239
240 if(!is_null($post_id))
241 {
242 $the_post = get_post($post_id);
243 if ( empty($the_post) ) $post_id = null;
244 }
245
246 if(is_null($post) and is_null($post_id))
247 return $default;
248
249 $keys = explode('.', $key);
250 $temp = NULL;
251
252 foreach ($keys as $idx => $key)
253 {
254 if($idx == 0)
255 {
256 if(array_key_exists($key, $vp_metaboxes))
257 {
258 $temp = $vp_metaboxes[$key];
259 if(!is_null($post_id))
260 $temp->the_meta($post_id);
261 else
262 $temp->the_meta();
263 }
264 else
265 {
266 return $default;
267 }
268 }
269 else
270 {
271 if(is_object($temp) and get_class($temp) === 'VP_Metabox')
272 {
273 $temp = $temp->get_the_value($key);
274 }
275 else
276 {
277 if(is_array($temp) and array_key_exists($key, $temp))
278 {
279 $temp = $temp[$key];
280 }
281 else
282 {
283 return $default;
284 }
285 }
286 }
287 }
288 return $temp;
289 }
290 }
291
292 /**
293 * Easy way to get option values using dot notation
294 * example:
295 *
296 * vp_option('option_key.field_name')
297 *
298 */
299
300 if( !function_exists('vp_option') )
301 {
302 function vp_option($key, $default = null)
303 {
304 $vp_options = VP_Option::get_pool();
305
306 if(empty($vp_options))
307 return $default;
308
309 $keys = explode('.', $key);
310 $temp = NULL;
311
312 foreach ($keys as $idx => $key)
313 {
314 if($idx == 0)
315 {
316 if(array_key_exists($key, $vp_options))
317 {
318 $temp = $vp_options[$key];
319 $temp = $temp->get_options();
320 }
321 else
322 {
323 return $default;
324 }
325 }
326 else
327 {
328 if(is_array($temp) and array_key_exists($key, $temp))
329 {
330 $temp = $temp[$key];
331 }
332 else
333 {
334 return $default;
335 }
336 }
337 }
338 return $temp;
339 }
340 }
341
342 /**
343 * EOF
344 */