PluginProbe
WP Ultimate Post Grid / 1.7.2
WP Ultimate Post Grid v1.7.2
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 / classes / metabox / depsloader.php

depsloader.php in WP Ultimate Post Grid 1.7.2, at vendor/vafpress/classes/metabox/depsloader.php

100 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class VP_Metabox_Depsloader
4 {
5
6 /**
7 * ARRAY OF VP_METABOX_ALCHEMY OBJECT
8 * @var [type]
9 */
10 private $things;
11
12 public function __construct($things)
13 {
14 $this->things = array($things);
15 }
16
17 public function build()
18 {
19 $vp_metabox_used = false;
20 $metaboxes = $this->things;
21
22 $result = array(
23 'scripts' => array(),
24 'styles' => array(),
25 'localize_name' => 'vp_mb',
26 'localize_default' => array(),
27 'localize' => array(),
28 'use_upload' => false,
29 'use_new_media_upload' => false,
30 'main_js' => array(
31 'name' => 'vp-metabox',
32 'path' => VP_PUBLIC_URL . '/js/metabox.min.js'
33 ),
34 'main_css' => array(
35 'name' => 'vp-metabox',
36 'path' => VP_PUBLIC_URL . '/css/metabox.min.css'
37 ),
38 );
39
40 $script_always = VP_Util_Config::instance()->load('dependencies', 'scripts.always');
41 $style_always = VP_Util_Config::instance()->load('dependencies', 'styles.always');
42 $messages = VP_Util_Config::instance()->load('messages');
43
44 $result['localize']['val_msg'] = $messages['validation'];
45
46 if(is_array($metaboxes)) reset($metaboxes);
47 if(is_array($metaboxes)) foreach ($metaboxes as $key => $metabox)
48 {
49 if($metabox->can_output())
50 {
51 if(!function_exists('inner_build'))
52 {
53 function inner_build($fields, &$result)
54 {
55 $rules = VP_Util_Config::instance()->load('dependencies', 'rules');
56 foreach ($fields as $field)
57 {
58 if($field['type'] == 'group')
59 {
60 inner_build($field['fields'], $result);
61 }
62 else
63 {
64 if( array_key_exists($field['type'], $rules) )
65 {
66 $result['scripts'] = array_merge($result['scripts'], $rules[$field['type']]['js']);
67 $result['styles'] = array_merge($result['styles'], $rules[$field['type']]['css']);
68 }
69 if( $field['type'] == 'upload' )
70 {
71 $result['use_upload'] = true;
72 }
73 }
74 }
75 }
76 }
77 inner_build($metabox->template, $result);
78 // at least one metabox used, then let's load
79 $vp_metabox_used = true;
80 }
81
82 if($vp_metabox_used)
83 {
84 $result['scripts'] = array_merge($result['scripts'], $script_always);
85 $result['styles'] = array_merge($result['styles'], $style_always);
86 }
87 $result['scripts'] = array_unique($result['scripts']);
88 $result['styles'] = array_unique($result['styles']);
89 }
90 return $result;
91 }
92
93 public function can_output($hook_suffix = '')
94 {
95 if ( WPAlchemy_MetaBox::_is_post() or WPAlchemy_MetaBox::_is_page() )
96 return true;
97 return false;
98 }
99
100 }