project_id = $project_id; $project = get_post( $project_id ); $this->project_name = $project->post_title; add_action( 'admin_init', array ( $this, 'init' ) ); add_action( 'admin_menu', array( $this, 'dashboard_hooks' ) ); } function init() { foreach ( array('projects', 'parts', 'library_items', 'imported_items') as $type ) { add_meta_box('anthologize', 'Anthologize', array($this,'item_meta_box'), $type, 'side', 'high'); } add_action('save_post',array( $this, 'item_meta_save' )); do_action( 'anthologize_admin_init' ); } function dashboard_hooks() { global $menu; $menu[57] = array( 1 => read, 2 => 'separator-anthologize', 4 => 'wp-menu-separator' ); $plugin_pages = array(); // Adds the top-level Anthologize Dashboard menu button $this->add_admin_menu_page( array( 'menu_title' => __( 'Anthologize', 'anthologize' ), 'page_title' => __( 'Anthologize', 'anthologize' ), 'access_level' => 10, 'file' => 'anthologize', 'function' => array( $this, 'display'), 'position' => 56 ) ); // Creates the submenu items $plugin_pages[] = add_submenu_page( 'anthologize', __('My Projects','anthologize'), __('My Projects','anthologize'), 'manage_options', 'anthologize', array ( $this, 'display' ) ); $plugin_pages[] = add_submenu_page( 'anthologize', __('New Project','anthologize'), __('New Project','anthologize'), 'manage_options', dirname( __FILE__ ) . '/class-new-project.php'); $plugin_pages[] = add_submenu_page( 'anthologize', __( 'Export Project', 'anthologize' ), __( 'Export Project', 'anthologize' ), 'manage_options', dirname( __FILE__ ) . '/class-export-panel.php' ); $plugin_pages[] = add_submenu_page( 'anthologize', __( 'Import Content', 'anthologize' ), __( 'Import Content', 'anthologize' ), 'manage_options', dirname( __FILE__ ) . '/class-import-feeds.php' ); foreach ( $plugin_pages as $plugin_page ) { add_action( "admin_print_styles", array( $this, 'load_styles' ) ); add_action( "admin_print_scripts-$plugin_page", array( $this, 'load_scripts' ) ); } } // Borrowed, with much love, from BuddyPress. Allows us to put Anthologize way up top. function add_admin_menu_page( $args = '' ) { global $menu, $admin_page_hooks, $_registered_pages; $defaults = array( 'page_title' => '', 'menu_title' => '', 'access_level' => 2, 'file' => false, 'function' => false, 'icon_url' => false, 'position' => 100 ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $file = plugin_basename( $file ); $admin_page_hooks[$file] = sanitize_title( $menu_title ); $hookname = get_plugin_page_hookname( $file, '' ); if (!empty ( $function ) && !empty ( $hookname )) add_action( $hookname, $function ); if ( empty($icon_url) ) $icon_url = 'images/generic.png'; elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') ) $icon_url = 'https://' . substr($icon_url, 7); do { $position++; } while ( !empty( $menu[$position] ) ); $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url ); unset( $menu[$position][5] ); $_registered_pages[$hookname] = true; return $hookname; } function load_scripts() { wp_enqueue_script( 'anthologize-js', WP_PLUGIN_URL . '/anthologize/js/project-organizer.js' ); wp_enqueue_script( 'jquery'); wp_enqueue_script( 'jquery-ui-core'); wp_enqueue_script( 'jquery-ui-sortable'); wp_enqueue_script( 'jquery-ui-draggable'); wp_enqueue_script( 'blockUI-js', WP_PLUGIN_URL . '/anthologize/js/jquery.blockUI.js' ); wp_enqueue_script( 'anthologize_admin-js', WP_PLUGIN_URL . '/anthologize/js/anthologize_admin.js' ); wp_enqueue_script( 'anthologize-sortlist-js', WP_PLUGIN_URL . '/anthologize/js/anthologize-sortlist.js' ); } function load_styles() { wp_enqueue_style( 'anthologize-css', WP_PLUGIN_URL . '/anthologize/css/project-organizer.css' ); } function load_project_organizer( $project_id ) { require_once( dirname( __FILE__ ) . '/class-project-organizer.php' ); $project_organizer = new Anthologize_Project_Organizer( $project_id ); $project_organizer->display(); } function display_no_project_id_message() { ?>

ID; } $args = array( 'post_parent' => $project_id, 'post_type' => 'parts', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => ASC ); $items_query = new WP_Query( $args ); if ( $posts = $items_query->get_posts() ) { return $posts; } } function get_project_items($project_id = null) { global $post; if (!$project_id) { $project_id = $post->ID; } $parts = $this->get_project_parts($project_id); $items = array(); if ($parts) { foreach ($parts as $part) { $args = array( 'post_parent' => $part->ID, 'post_type' => 'library_items', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => ASC ); $items_query = new WP_Query( $args ); // May need optimization if ( $posts = $items_query->get_posts() ) { foreach($posts as $post) { $items[] = $post; } } } } return $items; } function display() { // print_r($_GET); die(); $project = get_post( $_GET['project_id'] ); if ( $_GET['action'] == 'delete' && $project ) { wp_delete_post($project->ID); } if ( $_GET['action'] == 'edit' && $project ) { $this->load_project_organizer( $_GET['project_id'] ); } if ( !isset( $_GET['action'] ) || $_GET['action'] == 'list-projects' || ( $_GET['action'] == 'edit' && !$project ) || ( $_GET['action'] == 'delete') ) { ?>

display_no_project_id_message(); } query_posts( 'post_type=projects' ); if ( have_posts() ) { ?>

' . __('Edit Project') . ''; $controlActions[] = ''.__('Manage Parts') . ''; $controlActions[] = ''.__('Delete Project') . ''; ?>
get_project_parts(); echo count($parts); ?> get_project_items(); echo count($items); ?>

post_parent; $location = 'admin.php?page=anthologize&action=edit&project_id='.$arg; if ( isset( $_POST['return_to_project'] ) ) $location = 'admin.php?page=anthologize&action=edit&project_id=' . $_POST['return_to_project']; return $location; } /** * item_meta_box * * Displays form for editing item metadata associated with * Anthologize. Includes hidden fields for post_parent and * menu_order because WP sets those values to 0 if those * fields are not present on the form. **/ function item_meta_box() { global $post; $meta = get_post_meta( $post->ID, 'anthologize_meta', TRUE ); $imported_item_meta = get_post_meta( $post->ID, 'imported_item_meta', true ); $author_name = get_post_meta( $post->ID, 'author_name', true ); ?>

$value ) : ?> ' . $value . ''; break; case 'link': $dt = __( 'Source URL:', 'anthologize' ); $dd = '' . $value . ''; break; /*case 'authors': $dt = __( 'Author:', 'anthologize' ); $ddv = $value[0]; $dd = $ddv->name; break; todo: fixme */ case 'created_date': $dt = __( 'Date created:', 'anthologize' ); $dd = $value; break; default: continue; break; } ?>