oad_objects(); if (!empty($keys)) { $ret = array(); foreach ($keys as $key) { foreach ((array) $this->data_loaded[$key] as $name => $var) { $ret[$name] = $this->data_loaded[$key][$name]; } } return $ret; } return $this->data_loaded; } function load_objects($data = array()) { $plugin = get_option($this->settings['option_key'], array()); $data['_plugin'] = $this->object_to_array($plugin); if (!$data['_plugin']) $data['_plugin'] = array(); $saved = $this->saved_data(); $data['_plugin_saved'] = $this->object_to_array($saved); if (!$data['_plugin_saved']) $data['_plugin_saved'] = array(); foreach ((array) $this->data_modified as $key => $item) { // Remove the defaults if (array_key_exists($key, (array) $this->data_default)) unset($this->data_modified[$key]); /* if (array_key_exists($key, $data['_plugin'])) unset($this->data_modified[$key]); if (array_key_exists($key, (array) $data['_plugin_saved'])) unset($this->data_modified[$key]); */ } $data['_other'] = $this->object_to_array($this->data_modified); if (!$data['_other']) $data['_other'] = array(); $data['_default'] = $this->object_to_array($this->data_default); if (!$data['_default']) $data['_default'] = array(); $this->data_loaded = $data; return $data; } function saved_data() { return apply_filters($this->filter, $saved); $saved = array(); $saved = apply_filters($this->filter, $saved); foreach ($saved as $key => $type) { $data[$key] = $type; $data[$key]['file'] = true; } return $data; } function elsewhere_data($data, $wpdata) { // Get the stuff defined elsewhere foreach ($wpdata as $key => $item) { if (in_array($key, (array) $this->settings['default_keys'])) continue; $item = $this->object_to_array($item); $data[$key] = $item; $data[$key]['file'] = true; $data[$key]['other'] = true; } return $data; } /* ** POPULATE ** */ function populate ($page, $options = array()) { // These are the single value variables foreach ((array) $this->settings['fields']['var'] as $field) if (array_key_exists($field, (array) $page)) $options[$field] = $page[$field]; else $options[$field] = false; // Arrays, may be associative foreach ((array) $this->settings['fields']['array'] as $k => $f) { if (!is_array($f)) { if (array_key_exists($f, (array) $page)) $options[$f] = $page[$f]; // $options[$f] = (array_key_exists($f, (array) $page)) ? $page[$f] : array(); } else { foreach((array) $f as $f2) { if (array_key_exists($f2, (array) $page[$k])) $options[$k][$f2] = $page[$k][$f2]; // $options[$k][$f2] = (array_key_exists($f2, (array) $page[$k])) ? $page[$k][$f2] : false; } } } return $options; } } } if (!is_callable('__d')) { function __d($d) { if (!defined('MORE_PLUGINS_DEV')) return false; if (!$d) return false; echo '
';
		print_r($d);
		echo '
'; } } define($more_plugins, true); ?>ta_boxes; $this->data_default = $wp_meta_boxes; } function set_modified_data() { global $wp_meta_boxes; $this->data_modified = $this->trawl_data($wp_meta_boxes); } function trawl_data($data) { // __d($data); $boxes = array(); foreach ((array) $data as $pt => $data1) { foreach ((array) $data1 as $data2) { foreach ((array) $data2 as $data3) { foreach ((array) $data3 as $box) { if ($id = $box['id']) { $boxes[$id]['label'] = $box['title']; $boxes[$id]['post_types'][] = $pt; // $box['title']; } } } } } return $boxes; } /* function read_data() { return $this->get_data(); // global $wp_ $data = get_option($this->settings['option_key'], array()); // Stuff saved to file $data = $this->saved_data($data); // Data added eslewhere // if (!$this->wp_taxonomies) $this->wp_taxonomies = $wp_taxonomies; // $data = $this->elsewhere_data($data, $this->wp_taxonomies); return $data; } */ function load_field_types () { // $field_types = mf_field_types(); } /* ** admin_init() ** */ function admin_init() { global $wp_meta_boxes, $wp_roles; if (!is_callable('add_meta_box')) return false; // Give More Types priority $plugins = get_option( 'active_plugins', array()); $more_types = 'more-types/more-types.php'; $this->load_objects(); $boxes = $this->get_objects(array('_plugin_saved', '_plugin')); // Remove boxes defined elsewhere if we're overwriting it $others = $this->get_objects(array('_other')); foreach ((array) $others as $key => $other) { $id = sanitize_title($other['label']); if (array_key_exists($id, (array) $boxes)) { foreach ((array) $other['post_types'] as $pt) { remove_meta_box($key, $pt, 'normal'); remove_meta_box($key, $pt, 'advanced'); } } } // Hook the More Fields boxes into the WP meta box framework foreach((array) $boxes as $key => $box) { if (!($box = apply_filters('mf_box', $box))) continue; // Create the capability name $slug = ($s = $box['slug']) ? $s : sanitize_title($box['label']); $capability = 'more_fields_box_' . $slug; foreach ((array) $box['more_access_cap'] as $role) { if (is_object($wp_roles)) $wp_roles->add_cap($role, $capability); } // Can the curret user see this box? if (!empty($box['more_access_cap'])) if (!current_user_can($capability)) continue; // If it's positioned to the right, then add an additional page type, not processed by WP $context = ($box['position'] == 'left') ? 'normal' : 'side'; // $context = 'normal'; // If more types is installed don't associate with any particular post type. // if (in_array($more_types, $plugins)) { // Do nothing // add_meta_box(sanitize_title($box['label']), $box['label'], 'mf_ua_callback', '', $context); // add_meta_box($key, $box['label'], 'mf_ua_callback', 'kocksukker', $context); // } else { // Add the box to the post type foreach ((array) $box['post_types'] as $b) { add_meta_box($key, $box['label'], 'mf_ua_callback', $b, $context); } // } } } } ?>