/** * Renders the group subnav * * @package CollabPress * @subpackage CP BP * @since 1.2 */ function render_subnav() { ?> <div class="item-list-tabs no-ajax" id="subnav" role="navigation"> <ul> <li<?php if ('list' == $this->current_view) { ?> class="current"<?php } ?> ><a href="<?php echo esc_html($this->cp_link); ?> "><?php _e('Dashboard', 'collabpress'); ?> </a></li> <?php if ($project_name = cp_bp()->get_current_item_project_name()) { ?> <li<?php if ('project' == $this->current_view) { ?> class="current"<?php } ?> ><a href="<?php echo esc_html($this->cp_link . '/' . cp_bp()->get_current_item_project_slug()); ?> "> → <?php echo $project_name; ?> </a></li> <?php if ($task_list_name = cp_bp()->get_current_item_task_list_name()) { ?> <li<?php if ('task_list' == $this->current_view) { ?> class="current"<?php } ?> ><a href="<?php echo esc_html($this->cp_link . '/' . cp_bp()->get_current_item_project_slug() . '/' . cp_bp()->get_current_item_task_list_slug()); ?> "> → <?php echo $task_list_name; ?> </a></li> <?php } ?> <?php if ($task_name = cp_bp()->get_current_item_task_name()) { ?> <li<?php if ('task' == $this->current_view) { ?> class="current"<?php } ?> ><a href="<?php echo esc_html($this->cp_link . '/' . cp_bp()->get_current_item_project_slug() . '/' . cp_bp()->get_current_item_task_slug()); ?> "> → <?php echo $task_name; ?> </a></li> <?php } ?> <?php } else { ?> <?php } ?> </ul> </div> <?php }
/** * Get the proper link for a CP project * * @package CollabPress * @subpackage CP BP * @since 1.2 * * @param */ function cp_bp_get_project_permalink($project_id = false, $project = false) { global $post; // Only run another query if we have to if ($project_id && !$project && (isset($post->ID) && $project_id != $post->ID || !isset($post->ID))) { $project = get_post($project_id); } else { if ($project_id && !$project && isset($post->ID) && $project_id == $post->ID) { $project = $post; } } if (empty($project)) { return false; } // Check the post type if ('cp-projects' != $project->post_type) { return false; } // Get the associated item. This defaults to the project author, but can be overridden via // the cp_bp_get_project_permalink_item_id filter (eg for groups) $parent_item = apply_filters('cp_bp_get_project_permalink_parent_item', array('item_id' => $project->post_author, 'item_type' => 'user', 'item_link' => bp_core_get_user_domain($project->post_author), 'item_cp_slug' => cp_bp()->item_cp_slug), $project); // Assemble the permalink $link = $parent_item['item_link'] . $parent_item['item_cp_slug'] . '/' . $project->post_name; return apply_filters('cp_bp_get_project_permalink', $link, $project); }
<?php global $cp_project; global $cp_task_list; // Add Task if (isset($_POST['cp-add-task']) && isset($_POST['cp-task'])) { //check nonce for security check_admin_referer('cp-add-task'); $add_task = array('post_title' => sanitize_text_field($_POST['cp-task']), 'post_status' => 'publish', 'post_type' => 'cp-tasks'); $task_id = wp_insert_post($add_task); //add task status update_post_meta($task_id, '_cp-task-status', 'open'); $cp_bp_integration = cp_bp(); // Where we get the project_id from depends on whether this is a BP installation if (isset($_GET['project'])) { $project_id = $cp_project->id; } else { if (is_object($cp_bp_integration) && method_exists($cp_bp_integration, 'get_current_item_project')) { $project_id = $cp_bp_integration->get_current_item_project(); } else { $project_id = NULL; } } if ($project_id) { update_post_meta($task_id, '_cp-project-id', $project_id); } // Where we get the task list from depends on whether this is a BP installation if (isset($_GET['task-list'])) { $task_list_id = $cp_task_list->id; } else { if (is_object($cp_bp_integration) && method_exists($cp_bp_integration, 'get_current_item_task_list')) {
<?php global $cp_project; // Add Task List if (isset($_POST['cp-add-task-list']) && isset($_POST['cp-task-list'])) { //check nonce for security check_admin_referer('cp-add-task-list'); $add_task_list = array('post_title' => sanitize_text_field($_POST['cp-task-list']), 'post_status' => 'publish', 'post_type' => 'cp-task-lists'); $task_list_id = wp_insert_post($add_task_list); if (isset($_GET['project']) || isset(cp_bp()->current_view) && 'project' == cp_bp()->current_view) { update_post_meta($task_list_id, '_cp-project-id', $cp_project->id); } if (isset($_POST['cp-task-list-description'])) { update_post_meta($task_list_id, '_cp-task-list-description', esc_html($_POST['cp-task-list-description'])); } // Add Activity cp_add_activity(__('added', 'collabpress'), __('task list', 'collabpress'), $current_user->ID, $task_list_id); do_action('cp_task_list_added', $task_list_id); } // Edit Task List if (isset($_POST['cp-edit-task-list']) && $_POST['cp-edit-task-list-id']) { //check nonce for security check_admin_referer('cp-edit-task-list' . absint($_POST['cp-edit-task-list-id'])); //verify user has permission to edit task lists and post ID is a task list CPT if (cp_check_permissions('settings_user_role') && 'cp-task-lists' === get_post_type(absint($_POST['cp-edit-task-list-id']))) { // The ID $tasklistID = absint($_POST['cp-edit-task-list-id']); $tasklist = array(); $tasklist['ID'] = $tasklistID; $tasklist['post_title'] = sanitize_text_field($_POST['cp-task-list']); wp_update_post($tasklist);