function __construct(&$schema) { $this->pods = PodPool::init($this, $schema); foreach ($this->pods as $name => $pod) { $x = array('label' => $pod->st_display_name, 'labels' => $pod->labels, 'singular_label' => $pod->st_display_name_singular, 'public' => true, 'show_ui' => !$pod->f_struct, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array("slug" => $name), 'query_var' => $name, 'supports' => array('somthingrandom')); register_post_type(strtolower($name), array_merge($x, $pod->custom_post_type_params)); if ($pod->rg_index_column || true) { add_filter('manage_edit-' . $name . '_columns', array(&$this, 'edit_columns')); add_action('manage_' . $name . '_posts_custom_column', array(&$this, 'custom_columns')); add_filter("manage_edit-" . $name . "_sortable_columns", array(&$this, 'sortable_columns')); } add_action('add_meta_boxes', array(&$this, 'register_meta_boxes')); } add_action('wp_ajax_validate_form', array(&$this, 'ajax_validate_form')); add_action('wp_ajax_before_delete_post', array(&$this, 'ajax_before_delete_post')); add_action('wp_ajax_plupload_action', array(&$this, 'ajax_plupload_action')); if (defined('DOING_AJAX') && DOING_AJAX) { return; } add_action('trash_post', array(&$this, 'before_delete_post')); add_action('delete_post', array(&$this, 'before_delete_post')); $this->pluginUrl = WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)); add_action('admin_head', array(&$this, 'admin_head')); add_action('admin_print_styles', array(&$this, 'add_styles')); add_action('admin_print_scripts', array(&$this, 'register_scripts')); add_filter('title_save_pre', array(&$this, 'title_save_pre')); }
public static function &init(&$anise, &$schema) { self::$schema = self::process_schema($schema); $pods = array(); foreach (self::$schema as $name => $schema_def) { $pods[strtolower($name)] = self::register_pod(strtolower($name), new CompoundPod($anise, $schema_def, self::$schema)); } return $pods; }
public function __get($varName) { if ($varName == 'pod') { if (!$this->podImpl) { $this->podImpl = PodPool::get_pod($this->type); } return $this->podImpl; } }
protected function reg() { PodPool::register_pod($this->st_name, $this); }
public function before_delete($post_id) { $mp_post_id_c_reference = ReferencePod::get_dependencies_of($post_id); if ($mp_post_id_c_reference) { $rgpost_id_by_type = array(); foreach ($mp_post_id_c_reference as $post_idT => $c) { $status = get_post_status($post_idT); if ($status && $status != 'trash') { $post_type = get_post_type($post_idT); if (!$rgpost_id_by_type[$post_type]) { $rgpost_id_by_type[$post_type] = array($post_idT); } else { $rgpost_id_by_type[$post_type][] = $post_idT; } } } if ($rgpost_id_by_type) { echo '<p>Cannot delete "' . get_the_title($post_id) . '", because there are references to it.</p>'; foreach ($rgpost_id_by_type as $post_type => $rgpost_idT) { /**@var CompoundPod pod*/ $pod = PodPool::get_pod($post_type); if ($pod) { echo '<p>In "' . $pod->st_display_name . '": '; } echo '<ul>'; foreach ($rgpost_idT as $post_idT) { echo '<li>'; edit_post_link(get_the_title($post_idT), '<span>', '</span>', $post_idT); echo '</li>'; } echo '</ul></p>'; } } } }
static function ajax_add_new_item() { ListFieldPod::editor_for_item(PodPool::get_pod($_POST['post_type']), $_POST['id'], uniqid('0x'), ''); exit; }