/** * registers the current content handler. Child plugins should * register this function to fire on the 'setup_custom_content' action * * @example add_action('setup_custom_content', array($handler, 'on_setup_custom_content')); * */ public function on_setup_custom_content() { if (strlen($this->get_content_type()) == 0) { trigger_error("Custom_Content_Handler must have a set content_type. Content Type was not loaded.", E_WARNING); return; } CP_Custom_Content_Core::GetInstance()->register_custom_content_type($this); }
/** * Handles adding of content_types before any content is rendered. * */ public function on_load_add_content_type_page() { if (!current_user_can('manage_content_types')) { wp_die("You do not have sufficient permissions to access this page"); } $action = !empty($_POST['action']) ? $_POST['action'] : ''; $nonce = !empty($_POST['_wpnonce']) ? $_POST['_wpnonce'] : ''; switch ($action) { case 'add_content_type': if (wp_verify_nonce($nonce, 'add_content_type')) { if (!empty($_POST['content_type'])) { $content_type = $_POST['content_type']; $content_handler = new Dynamic_Content_Handler($content_type, $_POST); $content_type = $this->add_content_handler($content_handler); if (!is_wp_error($content_type)) { $add_url = admin_url('post-new.php?post_type=' . $content_type); if (version_compare(get_wp_version(), '3.0-dev', '<')) { $add_url = CP_Custom_Content_Core::GetInstance()->get_add_custom_content_url($content_type); } $notice = sprintf(__("The content type of '{$content_type}' has been created. <a href=\"%s\">Add one now.</a>"), esc_attr($add_url)); wp_redirect($this->get_edit_content_type_url($content_type, array('notice' => $notice))); exit; } else { $_REQUEST['notice'] = $content_type->get_error_message(); } } } break; } }
/** * Registers the managemet pages for the custom taxonomy in wp 2.9 * */ public function register_management_page() { $post_type = array_shift($this->get_object_types()); if ('post' == $post_type) { add_submenu_page('edit.php', $this->get_taxonomy_label_plural(), $this->get_taxonomy_label_plural(), 'manage_categories', 'edit-tags.php?taxonomy=' . $this->get_taxonomy_name()); } elseif ('page' == $post_type) { add_submenu_page('edit-pages.php', $this->get_taxonomy_label_plural(), $this->get_taxonomy_label_plural(), 'manage_categories', 'edit-tags.php?taxonomy=' . $this->get_taxonomy_name()); } else { add_submenu_page(str_replace('admin.php?page=', '', CP_Custom_Content_Core::GetInstance()->get_manage_custom_content_url($post_type)), $this->get_taxonomy_label_plural(), $this->get_taxonomy_label_plural(), 'manage_categories', 'edit-tags.php?taxonomy=' . $this->get_taxonomy_name()); } }
<tr> <?php print_column_headers($post_type); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers($post_type, false); ?> </tr> </tfoot> <tbody> <?php CP_Custom_Content_Core::GetInstance()->manage_rows($post_type, $posts, $pagenum, $per_page); ?> </tbody> </table> <div class="tablenav"> <?php if ($page_links) { echo "<div class='tablenav-pages'>{$page_links_text}</div>"; } ?> <div class="alignleft actions"> <select name="action2"> <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?> </option>